public interface ChronicleHash<K,E extends HashEntry<K>,SC extends HashSegmentContext<K,?>,EQC extends ExternalHashQueryContext<K>> extends Closeable
ChronicleMap and ChronicleSet.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases the off-heap memory, used by this hash container and resources, used by replication,
if any.
|
File |
file()
Returns the file this hash container mapped to, i.
|
void |
forEachEntry(Consumer<? super E> action)
Performs the given action for each entry in this
ChronicleHash until all entries have
been processed or the action throws an Exception. |
boolean |
forEachEntryWhile(Predicate<? super E> predicate)
Checks the given predicate on each entry in this
ChronicleHash until all entries
have been processed or the predicate returns false for some entry, or throws
an Exception. |
boolean |
isOpen()
Tells whether or not this
ChronicleHash (on-heap instance) is open. |
Class<K> |
keyClass() |
long |
longSize()
Returns the number of entries in this store.
|
EQC |
queryContext(BytesStore keyBytes,
long offset,
long size)
Returns a context to perform arbitrary operations with the given key, provided in the
serialized form.
|
EQC |
queryContext(Data<K> key)
Returns a context to perform arbitrary operations with the given key, provided in
Data form. |
EQC |
queryContext(K key)
Returns a context to perform arbitrary operations with the given key in this store.
|
SC |
segmentContext(int segmentIndex)
Returns a context of the segment with the given index.
|
int |
segments()
Returns the number of segments in this
ChronicleHash. |
File file()
ChronicleHashBuilder.create() call, or null if it is purely in-memory,
i. e. if it is created by ChronicleHashBuilder.create() call.ChronicleMap or ChronicleSet is mapped to,
or null if it is not mapped to any fileChronicleHashBuilder.createPersistedTo(File)long longSize()
@NotNull EQC queryContext(K key)
try (ExternalHashQueryContext<K> q = hash.queryContext(key)) {
// ... do something
}
See documentation to HashQueryContext interface and methods in MapMethods
interface for examples of using contexts. Also see
Working with an entry within a context section in the Chronicle Map tutorial.
key - the queried keyHashQueryContext,
MapQueryContext,
ExternalHashQueryContext,
MapMethods@NotNull EQC queryContext(Data<K> key)
Data form. Equivalent to queryContext(Object), but accepts Data
instead of object key. This method is useful, when you already have Data, calling
this method instead of queryContext(Object) might help to avoid unnecessary
deserialization.
See documentation to HashQueryContext interface and methods in MapMethods
interface for examples of using contexts. Also see
Working with an entry within a context section in the Chronicle Map tutorial.
key - the queried key as Data@NotNull EQC queryContext(BytesStore keyBytes, long offset, long size)
queryContext(Object) and queryContext(Data) for more
information on contexts semantics and usage patterns.keyBytes - the bytes store with the key bytes to queryoffset - actual offset of the key bytes within the given BytesStoresize - length of the key bytes sequence within the given BytesStoreSC segmentContext(int segmentIndex)
segments()- 1.HashSegmentContextint segments()
ChronicleHash.boolean forEachEntryWhile(Predicate<? super E> predicate)
ChronicleHash until all entries
have been processed or the predicate returns false for some entry, or throws
an Exception. Exceptions thrown by the predicate are relayed to the caller.
The order in which the entries will be processed is unspecified. It might differ from
the order of iteration via Iterator returned by any method of this
ChronicleHash or it's collection view.
If the ChronicleHash is empty, this method returns true immediately.
predicate - the predicate to be checked for each entrytrue if the predicate returned true for all entries of
the ChronicleHash, false if it returned false for the entryvoid forEachEntry(Consumer<? super E> action)
ChronicleHash until all entries have
been processed or the action throws an Exception. Exceptions thrown by the action are
relayed to the caller.
The order in which the entries will be processed is unspecified. It might differ from
the order of iteration via Iterator returned by any method of this
ChronicleHash or it's collection view.
action - the action to be performed for each entryvoid close()
ChronicleMap or ChronicleSet instances mapping the same data.
If you won't call this method, memory would be held at least until next garbage
collection. This could be a problem if, for example, you target rare garbage collections,
but load and drop ChronicleHashes regularly.
After this method call behaviour of all methods of ChronicleMap
or ChronicleSet is undefined. Any method call on the map might throw
any exception, or even JVM crash. Shortly speaking, don't call use map closing.
close in interface AutoCloseableclose in interface Closeableboolean isOpen()
ChronicleHash (on-heap instance) is open.true is close() is not yet calledCopyright © 2016. All rights reserved.