Class Database<K,V>
- java.lang.Object
-
- io.pmem.pmemkv.Database<K,V>
-
- Type Parameters:
K- the type of key stored in pmemkv datastoreV- the type of value stored in pmemkv datastore
public class Database<K,V> extends Object
Main Java binding pmemkv class, which is a local/embedded key-value datastore optimized for persistent memory. Rather than being tied to a single language or backing implementation, pmemkv provides different options for language bindings and storage engines.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:
- Pmemkv
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDatabase.Builder<K,V>Builder is used to build instances of pmemkv Database class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcountAbove(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.booleanexists(K key)Verifies 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.VgetCopy(K key)Gets copy of value of a given key.voidgetKeys(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.voidput(K key, V value)Inserts the key/value pair into the pmemkv datastore.booleanremove(K key)Removes key/value pair from the pmemkv datastore for given key.voidstop()Stops the running engine.booleanstopped()Checks if engine is stopped
-
-
-
Method Detail
-
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
public void getKeys(KeyCallback<K> callback)
Executes callback function for every key stored in the pmemkv datastore.- Parameters:
callback- Function to be called for each key.- Since:
- 1.0
-
getKeysAbove
public void getKeysAbove(K key, KeyCallback<K> callback)
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
public void getKeysBelow(K key, KeyCallback<K> callback)
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
public void getKeysBetween(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.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
public long countAbove(K key)
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
public long countBelow(K key)
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
public long countBetween(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.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
public void getAll(KeyValueCallback<K,V> callback)
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
public void getAbove(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.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
public void getBelow(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.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
public void getBetween(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.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
public boolean exists(K key)
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
public void get(K key, ValueCallback<V> callback)
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
public V getCopy(K key)
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
public void put(K key, V value)
Inserts the key/value pair into the pmemkv datastore.- Parameters:
key- the keyvalue- data to be inserted for specified key
-
remove
public boolean remove(K key)
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.
-
-