Package io.permazen.kv.util
Class UnmodifiableKVStore
java.lang.Object
io.permazen.kv.util.ForwardingKVStore
io.permazen.kv.util.UnmodifiableKVStore
- All Implemented Interfaces:
KVStore
Provides a read-only view of an underlying
KVStore
.
Attempts to invoke any of the mutating KVStore
methods result in an UnsupportedOperationException
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustCounter
(byte[] key, long amount) Adjust the counter at the given key by the given amount.protected KVStore
delegate()
Get the underlyingKVStore
.void
put
(byte[] key, byte[] value) Set the value associated with the given key.void
remove
(byte[] key) Remove the key/value pair with the given key, if it exists.void
removeRange
(byte[] minKey, byte[] maxKey) Remove all key/value pairs whose keys are in a given range.Methods inherited from class io.permazen.kv.util.ForwardingKVStore
apply, decodeCounter, encodeCounter, get, getAtLeast, getAtMost, getRange
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.permazen.kv.KVStore
getRange, getRange, removeRange
-
Constructor Details
-
UnmodifiableKVStore
Constructor.- Parameters:
kvstore
- the underlyingKVStore
- Throws:
IllegalArgumentException
- ifkvstore
is null
-
-
Method Details
-
delegate
Description copied from class:ForwardingKVStore
Get the underlyingKVStore
.- Specified by:
delegate
in classForwardingKVStore
- 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 interfaceKVStore
- Overrides:
put
in classForwardingKVStore
- Parameters:
key
- keyvalue
- 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 interfaceKVStore
- Overrides:
remove
in classForwardingKVStore
- 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 tomaxKey
; 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 with0xff
, then no change occurs - If
maxKey
starts with0xff
, then this method behaves as ifmaxKey
were null
- Specified by:
removeRange
in interfaceKVStore
- Overrides:
removeRange
in classForwardingKVStore
- Parameters:
minKey
- minimum key (inclusive), or null for no minimummaxKey
- maximum key (exclusive), or null for no maximum
- If
-
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
, orkey
's value is not a valid counter encoding as would be acceptable todecodeCounter()
, then how this operation affectskey
's value is undefined.- Specified by:
adjustCounter
in interfaceKVStore
- Overrides:
adjustCounter
in classForwardingKVStore
- Parameters:
key
- keyamount
- amount to adjust counter value by
-