Class MVStoreAtomicKVStore
- All Implemented Interfaces:
KVStore
,AtomicKVStore
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Logger
static final org.h2.mvstore.MVMap.Builder<byte[],
byte[]> TheMVMap.Builder
used by this class. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Apply a set of mutations to this instance atomically.protected void
Commit outstanding changes, unless there is an exception when doing so, in which case rollback changes.protected void
doClose()
protected void
protected void
doOpen()
protected void
finalize()
Finalize this instance.org.h2.mvstore.MVMap<byte[],
byte[]> getMVMap()
Get the underlyingMVMap
associated with this instance.org.h2.mvstore.MVStore
Get the underlyingMVStore
associated with this instance.void
put
(byte[] key, byte[] value) Set the value associated with the given key.Create a read-only "snapshot" view of this instance equal to its current state.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.void
setBuilder
(org.h2.mvstore.MVStore.Builder builder) Configure theMVStore.Builder
that will be used to construct theMVStore
whenstart()
is invoked.void
setBuilderConfig
(String builderConfig) Configure theMVStore.Builder
that will be used to construct theMVStore
whenstart()
is invoked using the specified configuration string.void
setMapName
(String mapName) Configure the name of theMVMap
to use.void
start()
Start this instance.void
stop()
Stop this instance.toString()
Methods inherited from class io.permazen.kv.mvstore.MVMapKVStore
get, getAtLeast, getAtMost, getRange
Methods inherited from class io.permazen.kv.AbstractKVStore
adjustCounter, decodeCounter, encodeCounter
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.permazen.kv.mvcc.AtomicKVStore
apply, start, stop
Methods inherited from interface io.permazen.kv.KVStore
adjustCounter, decodeCounter, encodeCounter, get, getAtLeast, getAtMost, getRange, getRange, getRange, removeRange
-
Field Details
-
MAP_BUILDER
public static final org.h2.mvstore.MVMap.Builder<byte[],byte[]> MAP_BUILDERTheMVMap.Builder
used by this class.Note this builder is configured with
MVMap.Builder.singleWriter
. -
log
-
-
Constructor Details
-
MVStoreAtomicKVStore
public MVStoreAtomicKVStore()
-
-
Method Details
-
getMVMap
public org.h2.mvstore.MVMap<byte[],byte[]> getMVMap()Get the underlyingMVMap
associated with this instance.- Returns:
- the associated underlying
MVMap
-
doOpen
protected void doOpen() -
doClose
protected void doClose() -
doCloseImmediately
protected void doCloseImmediately() -
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 classMVMapKVStore
- 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 classMVMapKVStore
- 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 classAbstractKVStore
- Parameters:
minKey
- minimum key (inclusive), or null for no minimummaxKey
- maximum key (exclusive), or null for no maximum
- If
-
readOnlySnapshot
Description copied from interface:AtomicKVStore
Create a read-only "snapshot" view of this instance equal to its current state.The returned
CloseableKVStore
should be treated as read-only. It may not actually be read-only, but if it's not, then any changes should have no effect on this instance. The returnedCloseableKVStore
must be completely independent from this instance (subsequent changes to either one do not affect the other).The returned
CloseableKVStore
should be promplyclose()
'd when no longer needed to release any underlying resources.- Specified by:
readOnlySnapshot
in interfaceAtomicKVStore
- Returns:
- read-only, snapshot view of this instance
-
apply
Description copied from interface:AtomicKVStore
Apply a set of mutations to this instance atomically.If this method returns normally, all of the given mutations will have been applied. If this method returns abnormally, then none of the given mutations will have been applied.
In any case, other threads observing this instance will never see a partial application of the given mutations.
This method is required to apply the mutations in this order: removes, puts, adjusts.
If
sync
is true, the implementation must durably persist the changes before returning.- Specified by:
apply
in interfaceAtomicKVStore
- Parameters:
mutations
- the mutations to applysync
- if true, caller requires that the changes be durably persisted
-
commitOrRollback
protected void commitOrRollback()Commit outstanding changes, unless there is an exception when doing so, in which case rollback changes. -
setBuilder
public void setBuilder(org.h2.mvstore.MVStore.Builder builder) Configure theMVStore.Builder
that will be used to construct theMVStore
whenstart()
is invoked.- Parameters:
builder
- builder for theMVStore
, or null to use a default builder- Throws:
IllegalStateException
- if this instance is alreadystart()
ed
-
setBuilderConfig
Configure theMVStore.Builder
that will be used to construct theMVStore
whenstart()
is invoked using the specified configuration string.- Parameters:
builderConfig
-MVStore.Builder
configuration string, or null to use a default builder- Throws:
IllegalStateException
- if this instance is alreadystart()
ed- See Also:
-
MVStore.Builder.fromString(java.lang.String)
-
setMapName
Configure the name of theMVMap
to use.Default value is
MVStoreKVImplementation.DEFAULT_MAP_NAME
.- Parameters:
mapName
- map name, or null to useMVStoreKVImplementation.DEFAULT_MAP_NAME
- Throws:
IllegalStateException
- if this instance is alreadystart()
ed
-
getMVStore
public org.h2.mvstore.MVStore getMVStore()Get the underlyingMVStore
associated with this instance.- Returns:
- the associated underlying
MVStore
- Throws:
IllegalStateException
- if this instance is notstart()
ed
-
start
@PostConstruct public void start()Start this instance. -
stop
@PreDestroy public void stop()Stop this instance. -
finalize
Finalize this instance. Invokesstop()
to close any unclosed iterators. -
toString
- Overrides:
toString
in classMVMapKVStore
-