public interface TableStore<T extends Metadata> extends CommonStore, net.openhft.chronicle.core.io.Closeable
Modifier and Type | Method and Description |
---|---|
default net.openhft.chronicle.core.values.LongValue |
acquireValueFor(CharSequence key)
Acquire
LongValue mapped to underlying file, providing atomic operations on the value that is shared
across threads and/or JVMs. |
net.openhft.chronicle.core.values.LongValue |
acquireValueFor(CharSequence key,
long defaultValue) |
<R> R |
doWithExclusiveLock(Function<TableStore<T>,? extends R> code)
Acquires file-system level lock on the underlying file, to prevent concurrent access from multiple processes.
|
<A> void |
forEachKey(A accumulator,
TableStoreIterator<A> tsIterator) |
T |
metadata() |
default boolean |
readOnly() |
bytes, dump, file, shortDump
usesSelfDescribingMessage, writeMarshallable, writeValue
default net.openhft.chronicle.core.values.LongValue acquireValueFor(CharSequence key)
LongValue
mapped to underlying file, providing atomic operations on the value that is shared
across threads and/or JVMs.
Note: The implementation of this method is not required to guarantee that if the value does not exist in the file,
it will create one and only one value in the file in case of concurrent access. On the contrary, it's possible
that different threads or processes acquire LongValue
s pointing to different fields in the underlying
file. To prevent this, it is advised to use doWithExclusiveLock(Function)
to wrap calls to this method,
which will ensure exclusive access to file while initially acquiring values.
Additionally, if this call is not guarded with doWithExclusiveLock(Function)
it may potentially overwrite
incomplete records done by other instances leading to data corruption.
If the value isn't found, it is created with Long.MIN_VALUE
value by default. To specify other default
value, use acquireValueFor(CharSequence, long)
key
- the key of the valueLongValue
object pointing to particular location in mapped underlying filenet.openhft.chronicle.core.values.LongValue acquireValueFor(CharSequence key, long defaultValue)
<A> void forEachKey(A accumulator, TableStoreIterator<A> tsIterator)
<R> R doWithExclusiveLock(Function<TableStore<T>,? extends R> code)
acquireValueFor(CharSequence)
calls, to atomically acquire
multiple values.R
- result typecode
- code block to execute using locked table storeT metadata()
default boolean readOnly()
Copyright © 2020. All rights reserved.