{@code
* try (ExternalHashQueryContext q = hash.queryContext(key)) {
* // ... do something
* }}
* See {@link HashQueryContext} and {@link MapMethods} for a lot of inspiration about using this
* functionality.
*
* @param key the queried key
* @return the context to perform operations with the key
* @see HashQueryContext
* @see MapQueryContext
* @see ExternalHashQueryContext
* @see MapMethods
*/
@NotNull
EQC queryContext(K key);
/**
* Equivalent to {@link #queryContext(Object)}, but accepts {@code Data} instead of key as
* an object. Useful, when you already have {@code Data}, calling this method instead of {@link
* #queryContext(Object)} might help to avoid unnecessary deserialization.
*
* @param key the queried key as {@code Data}
* @return the context to perform operations with the key
*/
@NotNull EQC queryContext(DataThe order in which the entries will be processed is unspecified. It might differ from * the order of iteration via {@code Iterator} returned by any method of this * {@code ChronicleHash} or it's collection view. * *
If the {@code ChronicleHash} is empty, this method returns {@code true} immediately. * * @param predicate the predicate to be checked for each entry * @return {@code true} if the predicate returned {@code true} for all entries of * the {@code ChronicleHash}, {@code false} if it returned {@code false} for the entry */ boolean forEachEntryWhile(Predicate super E> predicate); /** * Performs the given action for each entry in this {@code ChronicleHash} until all entries have * been processed or the action throws an {@code 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 {@code Iterator} returned by any method of this * {@code ChronicleHash} or it's collection view. * * @param action the action to be performed for each entry */ void forEachEntry(Consumer super E> action); /** * Releases the off-heap memory, used by this hash container and resources, used by replication, * if any. However, if hash container (hence off-heap memory, used by it) is mapped to the file * and there are other instances mapping the same data on the server across JVMs, the memory * won't be actually freed on operation system level. I. e. this method call doesn't affect * other {@link ChronicleMap} or {@link 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 {@code ChronicleHash}es regularly. * *
* TODO what about commit guarantees, when ChronicleMap is used with memory-mapped files, if * {@code ChronicleMap}/{@code ChronicleSet} closed/not? * *
After this method call behaviour of all methods of {@code ChronicleMap} * or {@code 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. */ @Override void close(); /** * Tells whether or not this {@code ChronicleHash} (on-heap instance) is open. * * @return {@code true} is {@link #close()} is not yet called */ boolean isOpen(); }