Class SnapshotLevelDBKVStore
- All Implemented Interfaces:
CloseableKVStore,KVStore,Closeable,AutoCloseable
KVStore view of a LevelDB Snapshot.
Instances must be close()'d when no longer needed to avoid leaking resources associated with iterators.
This class ensures that the configured Snapshot is closed when this instance is closed.
All mutation operations throw UnsupportedOperationException.
-
Constructor Summary
ConstructorsConstructorDescriptionSnapshotLevelDBKVStore(org.iq80.leveldb.DB db, boolean verifyChecksums) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidadjustCounter(ByteData key, long amount) Adjust the counter at the given key by the given amount.voidclose()Close this instance.voidSet the value associated with the given key.voidRemove the key/value pair with the given key, if it exists.voidremoveRange(ByteData minKey, ByteData maxKey) Remove all key/value pairs whose keys are in a given range.Methods inherited from class io.permazen.kv.leveldb.LevelDBKVStore
finalize, get, getDB, getRange, toStringMethods inherited from class io.permazen.kv.AbstractKVStore
decodeCounter, encodeCounter, getAtLeast, getAtMostMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.permazen.kv.KVStore
apply, decodeCounter, encodeCounter, get, getAtLeast, getAtMost, getRange, getRange, getRange, removeRange
-
Constructor Details
-
SnapshotLevelDBKVStore
public SnapshotLevelDBKVStore(org.iq80.leveldb.DB db, boolean verifyChecksums) Constructor.- Parameters:
db- LevelDB database to snapshotverifyChecksums- whether to verify checksums on reads- Throws:
NullPointerException- ifdbis null
-
-
Method Details
-
close
public void close()Description copied from class:LevelDBKVStoreClose this instance.This closes any unclosed iterators returned from
getRange(). This does not close the underlyingDBor any associatedWriteBatch.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableKVStore- Overrides:
closein classLevelDBKVStore
-
put
Description copied from interface:KVStoreSet the value associated with the given key.- Specified by:
putin interfaceKVStore- Overrides:
putin classLevelDBKVStore- Parameters:
key- keyvalue- value
-
remove
Description copied from interface:KVStoreRemove the key/value pair with the given key, if it exists.- Specified by:
removein interfaceKVStore- Overrides:
removein classLevelDBKVStore- Parameters:
key- key
-
removeRange
Description copied from interface:KVStoreRemove all key/value pairs whose keys are in a given range.The
minKeymust 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
0xffare not supported by this instance, then:- If
minKeystarts with0xff, then no change occurs - If
maxKeystarts with0xff, then this method behaves as ifmaxKeywere null
- Specified by:
removeRangein interfaceKVStore- Overrides:
removeRangein classAbstractKVStore- Parameters:
minKey- minimum key (inclusive), or null for no minimummaxKey- maximum key (exclusive), or null for no maximum
- If
-
adjustCounter
Description copied from interface:KVStoreAdjust 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:
adjustCounterin interfaceKVStore- Overrides:
adjustCounterin classAbstractKVStore- Parameters:
key- keyamount- amount to adjust counter value by
-