public interface ContextualStore extends Store
ContextualStore is a Store created by ContextualEnvironment.
Just like ContextualEnvironment, it is aware of transaction
started in current thread. ContextualStore overloads all Store's methods with the ones that don't
accept transaction instance.ContextualEnvironment,
Transaction,
Store| Modifier and Type | Method and Description |
|---|---|
boolean |
add(@NotNull ByteIterable key,
@NotNull ByteIterable value)
Adds key/value pair to the
ContextualStore if the key doesn't exist. |
long |
count() |
boolean |
delete(@NotNull ByteIterable key)
For stores without key duplicates, deletes single key/value pair and returns
true if a pair was deleted. |
boolean |
exists(@NotNull ByteIterable key,
@NotNull ByteIterable value)
Checks if specified key/value pair exists in the
ContextualStore. |
@Nullable ByteIterable |
get(@NotNull ByteIterable key)
For stores without key duplicates, it returns not-null value or null if the key doesn't exist.
|
@NotNull ContextualEnvironment |
getEnvironment() |
Cursor |
openCursor()
Opens cursor over the @{code Store}.
|
boolean |
put(@NotNull ByteIterable key,
@NotNull ByteIterable value)
Puts specified key/value pair into the
ContextualStore and returns the result. |
void |
putRight(@NotNull ByteIterable key,
@NotNull ByteIterable value)
Can be used if it is a priori known that the key is definitely greater than any other key in the
ContextualStore. |
@NotNull @NotNull ContextualEnvironment getEnvironment()
getEnvironment in interface Store@Nullable @Nullable ByteIterable get(@NotNull @NotNull ByteIterable key)
key - requested keyboolean exists(@NotNull
@NotNull ByteIterable key,
@NotNull
@NotNull ByteIterable value)
ContextualStore.key - keyvalue - valuetrue if the key/value pair exists in the ContextualStoreboolean put(@NotNull
@NotNull ByteIterable key,
@NotNull
@NotNull ByteIterable value)
ContextualStore and returns the result. For stores with key duplicates,
it returns true if the pair didn't exist in the ContextualStore. For stores without key duplicates,
it returns true if the key didn't exist or the new value differs from the existing one.
| With duplicates | Without duplicates | |
|---|---|---|
| The key exists | Adds pair, if the value didn't exist | Overwrites value |
| The key doesn't exist | Adds pair | Adds pair |
key - not null keyvalue - not null valuetrue if specified pair was added or value by the key was overwritten.void putRight(@NotNull
@NotNull ByteIterable key,
@NotNull
@NotNull ByteIterable value)
ContextualStore.
In that case, no search is been done before insertion, so putRight() can perform several times faster
than put(ByteIterable, ByteIterable). It can be useful for auto-generated keys.key - keyvalue - valueboolean add(@NotNull
@NotNull ByteIterable key,
@NotNull
@NotNull ByteIterable value)
ContextualStore if the key doesn't exist. For stores with and without key duplicates,
it returns true if and only if the key doesn't exists. So it never overwrites value of existing key.
| With duplicates | Without duplicates | |
|---|---|---|
| The key exists | Returns false | Returns false |
| The key doesn't exist | Adds pair, returns true | Adds pair, returns true |
key - keyvalue - valuetrue if key/value pair was addedboolean delete(@NotNull
@NotNull ByteIterable key)
true if a pair was deleted.
For stores with key duplicates, it deletes all pairs with the given key and returns true if any was deleted.
To delete particular key/value pair, use cursors.key - keytrue if a key/value pair was deleted.long count()
ContextualStore