org.apache.samza.storage.kv
Interface KeyValueStore<K,V>

Type Parameters:
K - The key type
V - The value type

public interface KeyValueStore<K,V>

A key-value store that supports put/get/delete and range queries.


Method Summary
 KeyValueIterator<K,V> all()
          Return an iterator over all keys in the database.
 void close()
           
 void delete(K key)
          Delete the value from the store (if there is one)
 void flush()
           
 V get(K key)
          Get the value corresponding to this key
 void put(K key, V value)
          Update the value associated with this key
 void putAll(java.util.List<Entry<K,V>> entries)
          Update all the given key/value pairs
 KeyValueIterator<K,V> range(K from, K to)
          Get an iterator over a given range of keys.
 

Method Detail

get

V get(K key)
Get the value corresponding to this key

Parameters:
key - The key to fetch
Returns:
The value or null if no value is found.
Throws:
java.lang.NullPointerException - If null is used for key.

put

void put(K key,
         V value)
Update the value associated with this key

Parameters:
key - They key to associate the value to
value - The value
Throws:
java.lang.NullPointerException - If null is used for key or value.

putAll

void putAll(java.util.List<Entry<K,V>> entries)
Update all the given key/value pairs

Parameters:
entries - A list of entries to put into the store.
Throws:
java.lang.NullPointerException - If null is used for any key or value.

delete

void delete(K key)
Delete the value from the store (if there is one)

Parameters:
key - The key
Throws:
java.lang.NullPointerException - If null is used for key.

range

KeyValueIterator<K,V> range(K from,
                            K to)
Get an iterator over a given range of keys. This iterator MUST be closed after use.

Parameters:
from - The first key that could be in the range
to - The last key that could be in the range
Returns:
The iterator for this range.
Throws:
java.lang.NullPointerException - If null is used for from or to.

all

KeyValueIterator<K,V> all()
Return an iterator over all keys in the database. This iterator MUST be closed after use.

Returns:
An iterator of all key/value pairs in the store.

close

void close()

flush

void flush()