@ThreadSafe public class MVStoreAtomicKVStore extends MVMapKVStore implements AtomicKVStore
Modifier and Type | Field and Description |
---|---|
protected Logger |
log |
static org.h2.mvstore.MVMap.Builder<byte[],byte[]> |
MAP_BUILDER
The
MVMap.Builder used by this class. |
Constructor and Description |
---|
MVStoreAtomicKVStore() |
Modifier and Type | Method and Description |
---|---|
protected void |
commitOrRollback()
Commit outstanding changes, unless there is an exception when doing so, in which case rollback changes.
|
protected void |
doClose() |
protected void |
doCloseImmediately() |
protected void |
doOpen() |
protected void |
finalize()
Finalize this instance.
|
org.h2.mvstore.MVMap<byte[],byte[]> |
getMVMap()
Get the underlying
MVMap associated with this instance. |
org.h2.mvstore.MVStore |
getMVStore()
Get the underlying
MVStore associated with this instance. |
void |
mutate(Mutations mutations,
boolean sync)
Apply a set of mutations to this instance atomically.
|
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.
|
void |
setBuilder(org.h2.mvstore.MVStore.Builder builder)
|
void |
setBuilderConfig(String builderConfig)
Configure the
MVStore.Builder that will be used to construct the MVStore when start() is invoked
using the specified configuration string. |
void |
setMapName(String mapName)
Configure the name of the
MVMap to use. |
MVMapSnapshot |
snapshot()
Acquire a read-only, snapshot view of this instance based on the current state.
|
void |
start() |
void |
stop() |
String |
toString() |
get, getAtLeast, getAtMost, getRange
adjustCounter, decodeCounter, encodeCounter
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
start, stop
adjustCounter, apply, decodeCounter, encodeCounter, get, getAtLeast, getAtMost, getRange, getRange, getRange, removeRange
public static final org.h2.mvstore.MVMap.Builder<byte[],byte[]> MAP_BUILDER
MVMap.Builder
used by this class.
Note this builder is configured with MVMap.Builder#singleWriter
.
protected final Logger log
public org.h2.mvstore.MVMap<byte[],byte[]> getMVMap()
MVMap
associated with this instance.MVMap
protected void doOpen()
protected void doClose()
protected void doCloseImmediately()
public void put(byte[] key, byte[] value)
KVStore
put
in interface KVStore
put
in class MVMapKVStore
key
- keyvalue
- valuepublic void remove(byte[] key)
KVStore
remove
in interface KVStore
remove
in class MVMapKVStore
key
- keypublic void removeRange(byte[] minKey, byte[] maxKey)
KVStore
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:
minKey
starts with 0xff
, then no change occursmaxKey
starts with 0xff
, then this method behaves as if maxKey
were nullremoveRange
in interface KVStore
removeRange
in class AbstractKVStore
minKey
- minimum key (inclusive), or null for no minimummaxKey
- maximum key (exclusive), or null for no maximumpublic MVMapSnapshot snapshot()
AtomicKVStore
The returned KVStore
view should remain constant even if this instance is subsequently mutated.
Note: callers are required to close
the returned instance when no longer in use.
snapshot
in interface AtomicKVStore
public void mutate(Mutations mutations, boolean sync)
AtomicKVStore
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.
mutate
in interface AtomicKVStore
mutations
- the mutations to applysync
- if true, caller requires that the changes be durably persistedprotected void commitOrRollback()
public void setBuilder(org.h2.mvstore.MVStore.Builder builder)
builder
- builder for the MVStore
, or null to use a default builderIllegalStateException
- if this instance is already start()
edpublic void setBuilderConfig(String builderConfig)
MVStore.Builder
that will be used to construct the MVStore
when start()
is invoked
using the specified configuration string.builderConfig
- MVStore.Builder
configuration string, or null to use a default builderIllegalStateException
- if this instance is already start()
edMVStore.Builder#fromString
public void setMapName(String mapName)
MVMap
to use.
Default value is MVStoreKVImplementation.DEFAULT_MAP_NAME
.
mapName
- map name, or null to use MVStoreKVImplementation.DEFAULT_MAP_NAME
IllegalStateException
- if this instance is already start()
edpublic org.h2.mvstore.MVStore getMVStore()
MVStore
associated with this instance.MVStore
IllegalStateException
- if this instance is not start()
ed@PostConstruct public void start()
@PreDestroy public void stop()
protected void finalize() throws Throwable
stop()
to close any unclosed iterators.public String toString()
toString
in class MVMapKVStore
Copyright © 2022. All rights reserved.