Class Database<K,V>
- Type Parameters:
K- the type of key stored in pmemkv datastoreV- the type of value stored in pmemkv datastore
This generic class allows to store data of any type (as both key and value). In most cases user needs to implement Converter interface, which provides functionality of converting between key and value types, and ByteBuffer.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder is used to build instances of pmemkv Database class. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final longprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcountAbove(K key) Returns number of currently stored key/value pairs in the pmemkv datastore, whose keys are greater than the given key.longcountAll()Returns number of currently stored key/value pairs in the pmemkv datastore.longcountBelow(K key) Returns number of currently stored key/value pairs in the pmemkv datastore, whose keys are less than the given key.longcountBetween(K key1, K key2) Returns number of currently stored key/value pairs in the pmemkv datastore, whose keys are greater than the key1 and less than the key2.private longdatabase_count_above_buffer(long ptr, int kb, ByteBuffer k) private longdatabase_count_all(long ptr) private longdatabase_count_below_buffer(long ptr, int kb, ByteBuffer k) private longdatabase_count_between_buffer(long ptr, int kb1, ByteBuffer k1, int kb2, ByteBuffer k2) private booleandatabase_exists_buffer(long ptr, int kb, ByteBuffer k) private voiddatabase_get_above_buffer(long ptr, int kb, ByteBuffer k, GetAllBufferJNICallback cb) private voiddatabase_get_all_buffer(long ptr, GetAllBufferJNICallback cb) private voiddatabase_get_below_buffer(long ptr, int kb, ByteBuffer k, GetAllBufferJNICallback cb) private voiddatabase_get_between_buffer(long ptr, int kb1, ByteBuffer k1, int kb2, ByteBuffer k2, GetAllBufferJNICallback cb) private voiddatabase_get_buffer_with_callback(long ptr, int kb, ByteBuffer k, GetKeysBuffersJNICallback cb) private byte[]database_get_bytes(long ptr, int kb, ByteBuffer k) private voiddatabase_get_keys_above_buffer(long ptr, int kb, ByteBuffer k, GetKeysBuffersJNICallback cb) private voiddatabase_get_keys_below_buffer(long ptr, int kb, ByteBuffer k, GetKeysBuffersJNICallback cb) private voiddatabase_get_keys_between_buffer(long ptr, int kb1, ByteBuffer k1, int kb2, ByteBuffer k2, GetKeysBuffersJNICallback cb) private voiddatabase_get_keys_buffer(long ptr, GetKeysBuffersJNICallback cb) private voiddatabase_put_buffer(long ptr, int kb, ByteBuffer k, int vb, ByteBuffer v) private booleandatabase_remove_buffer(long ptr, int kb, ByteBuffer k) private longdatabase_start(String engine, long config) private voiddatabase_stop(long ptr) booleanVerifies the presence of an element with a given key in the pmemkv datastore.voidget(K key, ValueCallback<V> callback) Executes a callback function on the value for a given keyvoidgetAbove(K key, KeyValueCallback<K, V> callback) Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are greater than the given key.voidgetAll(KeyValueCallback<K, V> callback) Executes callback function for every key/value pair stored in the pmemkv datastore.voidgetBelow(K key, KeyValueCallback<K, V> callback) Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are less than the given key.voidgetBetween(K key1, K key2, KeyValueCallback<K, V> callback) Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are greater than the key1 and less than the key2.Gets copy of value of a given key.private ByteBuffervoidgetKeys(KeyCallback<K> callback) Executes callback function for every key stored in the pmemkv datastore.voidgetKeysAbove(K key, KeyCallback<K> callback) Executes callback function for every key stored in the pmemkv datastore, whose keys are greater than the given key.voidgetKeysBelow(K key, KeyCallback<K> callback) Executes callback function for every key stored in the pmemkv datastore, whose keys are less than the given key.voidgetKeysBetween(K key1, K key2, KeyCallback<K> callback) Executes callback function for every key stored in the pmemkv datastore, whose keys are greater than the key1 and less than the key2.voidInserts the key/value pair into the pmemkv datastore.booleanRemoves key/value pair from the pmemkv datastore for given key.voidstop()Stops the running engine.booleanstopped()Checks if engine is stopped
-
Field Details
-
keyConverter
-
valueConverter
-
pointer
private final long pointer -
stopped
private boolean stopped
-
-
Constructor Details
-
Database
-
-
Method Details
-
getDirectBuffer
-
stop
public void stop()Stops the running engine.- Since:
- 1.0
-
stopped
public boolean stopped()Checks if engine is stopped- Returns:
- true if engine is stopped, false if it is running.
- Since:
- 1.0
-
getKeys
Executes callback function for every key stored in the pmemkv datastore.- Parameters:
callback- Function to be called for each key.- Since:
- 1.0
-
getKeysAbove
Executes callback function for every key stored in the pmemkv datastore, whose keys are greater than the given key.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key- Sets the lower bound for querying.callback- Function to be called for each key.- Since:
- 1.0
-
getKeysBelow
Executes callback function for every key stored in the pmemkv datastore, whose keys are less than the given key.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key- Sets the upper bound for querying.callback- Function to be called for each key.- Since:
- 1.0
-
getKeysBetween
Executes callback function for every key stored in the pmemkv datastore, whose keys are greater than the key1 and less than the key2.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key1- Sets the lower bound for querying.key2- Sets the upper bound for querying.callback- Function to be called for each key.- Since:
- 1.0
-
countAll
public long countAll()Returns number of currently stored key/value pairs in the pmemkv datastore.- Returns:
- Total number of elements in the datastore.
- Since:
- 1.0
-
countAbove
Returns number of currently stored key/value pairs in the pmemkv datastore, whose keys are greater than the given key.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key- Sets the lower bound for querying.- Returns:
- Number of key/value pairs in the datastore, whose keys are greater than the given key.
- Since:
- 1.0
-
countBelow
Returns number of currently stored key/value pairs in the pmemkv datastore, whose keys are less than the given key.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key- Sets the upper bound for querying.- Returns:
- Number of key/value pairs in the datastore, whose keys are less than the given key.
- Since:
- 1.0
-
countBetween
Returns number of currently stored key/value pairs in the pmemkv datastore, whose keys are greater than the key1 and less than the key2.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key1- Sets the lower bound for querying.key2- Sets the upper bound for querying.- Returns:
- Number of key/value pairs in the datastore, between given keys.
- Since:
- 1.0
-
getAll
Executes callback function for every key/value pair stored in the pmemkv datastore.- Parameters:
callback- Function to be called for each key/value pair.- Since:
- 1.0
-
getAbove
Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are greater than the given key.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key- Sets the lower bound for querying.callback- Function to be called for each specified key/value pair.
-
getBelow
Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are less than the given key.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key- Sets the upper bound for querying.callback- Function to be called for each specified key/value pair.
-
getBetween
Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are greater than the key1 and less than the key2.Comparison mechanism is based on binary comparison of bytes - by a function equivalent to std::string::compare in C++
- Parameters:
key1- Sets the lower bound for querying.key2- Sets the upper bound for querying.callback- Function to be called for each specified key/value pair.
-
exists
Verifies the presence of an element with a given key in the pmemkv datastore.- Parameters:
key- to query for.- Returns:
- true if key exists in the datastore, false otherwise
-
get
Executes a callback function on the value for a given key- Parameters:
key- key to query for.callback- Function to be called for each specified key/value pair.
-
getCopy
Gets copy of value of a given key.- Parameters:
key- key to query for.- Returns:
- Copy of value associated with the given key or null if not found
-
put
Inserts the key/value pair into the pmemkv datastore.- Parameters:
key- the keyvalue- data to be inserted for specified key
-
remove
Removes key/value pair from the pmemkv datastore for given key.- Parameters:
key- key to query for, to be removed.- Returns:
- true if element was removed, false if element didn't exist before removal.
-
database_start
-
database_stop
private void database_stop(long ptr) -
database_get_keys_buffer
-
database_get_keys_above_buffer
private void database_get_keys_above_buffer(long ptr, int kb, ByteBuffer k, GetKeysBuffersJNICallback cb) -
database_get_keys_below_buffer
private void database_get_keys_below_buffer(long ptr, int kb, ByteBuffer k, GetKeysBuffersJNICallback cb) -
database_get_keys_between_buffer
private void database_get_keys_between_buffer(long ptr, int kb1, ByteBuffer k1, int kb2, ByteBuffer k2, GetKeysBuffersJNICallback cb) -
database_count_all
private long database_count_all(long ptr) -
database_count_above_buffer
-
database_count_below_buffer
-
database_count_between_buffer
private long database_count_between_buffer(long ptr, int kb1, ByteBuffer k1, int kb2, ByteBuffer k2) -
database_get_all_buffer
-
database_get_above_buffer
-
database_get_below_buffer
-
database_get_between_buffer
private void database_get_between_buffer(long ptr, int kb1, ByteBuffer k1, int kb2, ByteBuffer k2, GetAllBufferJNICallback cb) -
database_exists_buffer
-
database_get_buffer_with_callback
private void database_get_buffer_with_callback(long ptr, int kb, ByteBuffer k, GetKeysBuffersJNICallback cb) -
database_get_bytes
-
database_put_buffer
-
database_remove_buffer
-