Class ClickHouseFreezableMap<K,V>

java.lang.Object
com.clickhouse.data.ClickHouseFreezableMap<K,V>
All Implemented Interfaces:
Map<K,V>

public class ClickHouseFreezableMap<K,V> extends Object implements Map<K,V>
Freezable map. Once the map is freezed, all writes will be discarded without any error.
  • Constructor Details

    • ClickHouseFreezableMap

      protected ClickHouseFreezableMap(Map<K,V> map, K... keys)
  • Method Details

    • of

      public static <K, V> ClickHouseFreezableMap<K,V> of(Map<K,V> map, K... whiteListedKeys)
      Creates a freezable map with initial data and optional whitelisted keys.
      Type Parameters:
      K - type of the key
      V - type of the value
      Parameters:
      map - non-null map with initial data
      whiteListedKeys - optional whitelisted keys
      Returns:
      non-null freezable map
    • isMutable

      protected boolean isMutable(Object key)
      Checks whether the given key can be used in mutation(e.g. put(), remove()), regardless the map is freezed or not.
      Parameters:
      key - non-null key
      Returns:
      true if the given key can be used in mutation; false otherwise
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • get

      public V get(Object key)
      Specified by:
      get in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • freeze

      public ClickHouseFreezableMap<K,V> freeze()
      Freezes the map to discard write operations.
      Returns:
      this map
    • unfreeze

      public ClickHouseFreezableMap<K,V> unfreeze()
      Unfreezes the map to accept write operations.
      Returns:
      this map
    • isFreezed

      public boolean isFreezed()
      Checks whether the map is freezed or not.
      Returns:
      true if the map is freezed; false otherwise
    • isWhiteListed

      public boolean isWhiteListed(K key)
      Checks whether the given key is whitelisted, meaning corresponding entry can be changed even the map is freezed.
      Parameters:
      key - non-null key
      Returns:
      true if the key is whitelisted; false otherwise