public class KeyValueFileStore<K extends util.object.Identifiable,V> extends java.lang.Object implements KeyValueStore<K,V>
KeyValueStore
backed by a TaskFileStore
.
Each value is stored in a file and the file is keyed by the corresponding
task ID. Values are (de-)serialised using provided readers/writers.Constructor and Description |
---|
KeyValueFileStore(TaskFileStore<K> store,
SourceReader<java.io.InputStream,V> reader,
SinkWriter<V,java.io.OutputStream> writer)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
modify(K key,
java.util.function.Function<V,V> operation)
Updates the value associated to the specified key.
|
void |
put(K key,
V value)
Maps a key to a value.
|
void |
remove(K key)
Deletes the mapping identified by the specified key.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get
public KeyValueFileStore(TaskFileStore<K> store, SourceReader<java.io.InputStream,V> reader, SinkWriter<V,java.io.OutputStream> writer)
store
- the file store to use to persist the key-value pairs.reader
- deserialises the input stream.writer
- serialises to the output stream.public void put(K key, V value)
KeyValueStore
put
in interface KeyValueStore<K extends util.object.Identifiable,V>
key
- identifies the mapping.value
- the value to store.public void modify(K key, java.util.function.Function<V,V> operation)
KeyValueStore
modify
in interface KeyValueStore<K extends util.object.Identifiable,V>
key
- identifies the mapping.operation
- is given the current value, does something with it and
then returns the new value.public void remove(K key)
KeyValueStore
remove
in interface KeyValueStore<K extends util.object.Identifiable,V>
key
- identifies the mapping.