public class BaseStringBinaryKeyValueStore<K,V> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Function<String,K> |
keyObjectConverter |
protected Function<K,String> |
keyToByteArrayConverter |
protected KeyValueStore<String,byte[]> |
store
Store that does the actual writing to DB (likely).
|
protected Function<byte[],V> |
valueObjectConverter |
protected Function<V,byte[]> |
valueSerializer |
| Constructor and Description |
|---|
BaseStringBinaryKeyValueStore(KeyValueStore<String,byte[]> store) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the store.
|
boolean |
isClosed() |
boolean |
isOpen() |
V |
load(K key)
Get a value from the key value store.
|
KeyValueIterable<K,V> |
loadAll()
Load all of the key / values from the store.
|
Map<K,V> |
loadAllByKeys(Collection<K> keys) |
Collection<K> |
loadAllKeys() |
void |
put(K key,
V value)
Put a value in the key/value store.
|
void |
putAll(Map<K,V> values)
Put all of these values in the key value store.
|
void |
remove(K key)
Remove a key from the store.
|
void |
removeAll(Iterable<K> keys)
Remove all of these values from the key value store.
|
KeyValueIterable<K,V> |
search(K startKey)
Search for a key in the key / value store.
|
protected K |
toKeyObject(String key)
Convert a binary array to a String.
|
protected String |
toKeyString(K key)
Convert a String key to bytes.
|
protected byte[] |
toValueBytes(V v)
Converts an object to a byte array.
|
protected V |
toValueObject(byte[] value)
Use serializer to read this byte array as an object.
|
protected final KeyValueStore<String,byte[]> store
public BaseStringBinaryKeyValueStore(KeyValueStore<String,byte[]> store)
public void remove(K key)
key - public KeyValueIterable<K,V> search(K startKey)
startKey - public KeyValueIterable<K,V> loadAll()
public Collection<K> loadAllKeys()
public Map<K,V> loadAllByKeys(Collection<K> keys)
public void close()
protected K toKeyObject(String key)
key - keyprotected V toValueObject(byte[] value)
value - value readprotected byte[] toValueBytes(V v)
v - object to convertprotected String toKeyString(K key)
key - key to convertpublic void put(K key, V value)
key - keyvalue - valuepublic void putAll(Map<K,V> values)
values - valuespublic void removeAll(Iterable<K> keys)
keys - public boolean isOpen()
public boolean isClosed()
Copyright © 2014. All Rights Reserved.