Class UnmodifiableKVStore

java.lang.Object
io.permazen.kv.util.ForwardingKVStore
io.permazen.kv.util.UnmodifiableKVStore
All Implemented Interfaces:
KVStore

public class UnmodifiableKVStore extends ForwardingKVStore
Provides a read-only view of an underlying KVStore.

Attempts to invoke any of the mutating KVStore methods result in an UnsupportedOperationException.

  • Constructor Details

  • Method Details

    • delegate

      protected KVStore delegate()
      Description copied from class: ForwardingKVStore
      Get the underlying KVStore.
      Specified by:
      delegate in class ForwardingKVStore
      Returns:
      underlying KVStore
    • put

      public void put(byte[] key, byte[] value)
      Description copied from interface: KVStore
      Set the value associated with the given key.
      Specified by:
      put in interface KVStore
      Overrides:
      put in class ForwardingKVStore
      Parameters:
      key - key
      value - value
    • remove

      public void remove(byte[] key)
      Description copied from interface: KVStore
      Remove the key/value pair with the given key, if it exists.
      Specified by:
      remove in interface KVStore
      Overrides:
      remove in class ForwardingKVStore
      Parameters:
      key - key
    • removeRange

      public void removeRange(byte[] minKey, byte[] maxKey)
      Description copied from interface: KVStore
      Remove all key/value pairs whose keys are in a given range.

      The minKey must be less than or equal to maxKey; if they equal (and not null) then nothing happens; if they are both null then all entries are deleted.

      If keys starting with 0xff are not supported by this instance, then:

      • If minKey starts with 0xff, then no change occurs
      • If maxKey starts with 0xff, then this method behaves as if maxKey were null
      Specified by:
      removeRange in interface KVStore
      Overrides:
      removeRange in class ForwardingKVStore
      Parameters:
      minKey - minimum key (inclusive), or null for no minimum
      maxKey - maximum key (exclusive), or null for no maximum
    • adjustCounter

      public void adjustCounter(byte[] key, long amount)
      Description copied from interface: KVStore
      Adjust the counter at the given key by the given amount.

      Ideally this operation should behave in a lock-free manner, so that concurrent transactions can invoke it without conflict. However, when lock-free behavior occurs (if at all) depends on the implementation.

      If there is no value associated with key, or key's value is not a valid counter encoding as would be acceptable to decodeCounter(), then how this operation affects key's value is undefined.

      Specified by:
      adjustCounter in interface KVStore
      Overrides:
      adjustCounter in class ForwardingKVStore
      Parameters:
      key - key
      amount - amount to adjust counter value by