K
- The type of the key.N
- The type of the namespace.UK
- The type of the keys in the map state.UV
- The type of the values in the map state.public class RocksDBMapState<K,N,UK,UV> extends AbstractRocksDBState<K,N,MapState<UK,UV>,MapStateDescriptor<UK,UV>,Map<UK,UV>> implements InternalMapState<N,UK,UV>
MapState
implementation that stores state in RocksDB.
RocksDBStateBackend
must ensure that we set the
StringAppendOperator
on the column family that we use for our state since
we use the merge()
call.
backend, columnFamily, keySerializationDataOutputView, keySerializationStream, stateDesc
Constructor and Description |
---|
RocksDBMapState(org.rocksdb.ColumnFamilyHandle columnFamily,
TypeSerializer<N> namespaceSerializer,
MapStateDescriptor<UK,UV> stateDesc,
RocksDBKeyedStateBackend<K> backend)
Creates a new
RocksDBMapState . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes the value mapped under the current key.
|
boolean |
contains(UK userKey)
Returns whether there exists the given mapping.
|
Iterable<Map.Entry<UK,UV>> |
entries()
Returns all the mappings in the state
|
UV |
get(UK userKey)
Returns the current value associated with the given key.
|
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace)
Returns the serialized value for the given key and namespace.
|
Iterator<Map.Entry<UK,UV>> |
iterator()
Iterates over all the mappings in the state.
|
Iterable<UK> |
keys()
Returns all the keys in the state
|
void |
put(UK userKey,
UV userValue)
Associates a new value with the given key.
|
void |
putAll(Map<UK,UV> map)
Copies all of the mappings from the given map into the state.
|
void |
remove(UK userKey)
Deletes the mapping of the given key.
|
Iterable<UV> |
values()
Returns all the values in the state.
|
readKeyWithGroupAndNamespace, setCurrentNamespace, writeCurrentKeyWithGroupAndNamespace, writeKeyWithGroupAndNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setCurrentNamespace
public RocksDBMapState(org.rocksdb.ColumnFamilyHandle columnFamily, TypeSerializer<N> namespaceSerializer, MapStateDescriptor<UK,UV> stateDesc, RocksDBKeyedStateBackend<K> backend)
RocksDBMapState
.namespaceSerializer
- The serializer for the namespace.stateDesc
- The state identifier for the state.public UV get(UK userKey) throws IOException, org.rocksdb.RocksDBException
MapState
get
in interface MapState<UK,UV>
userKey
- The key of the mappingIOException
org.rocksdb.RocksDBException
public void put(UK userKey, UV userValue) throws IOException, org.rocksdb.RocksDBException
MapState
put
in interface MapState<UK,UV>
userKey
- The key of the mappinguserValue
- The new value of the mappingIOException
org.rocksdb.RocksDBException
public void putAll(Map<UK,UV> map) throws IOException, org.rocksdb.RocksDBException
MapState
putAll
in interface MapState<UK,UV>
map
- The mappings to be stored in this stateIOException
org.rocksdb.RocksDBException
public void remove(UK userKey) throws IOException, org.rocksdb.RocksDBException
MapState
remove
in interface MapState<UK,UV>
userKey
- The key of the mappingIOException
org.rocksdb.RocksDBException
public boolean contains(UK userKey) throws IOException, org.rocksdb.RocksDBException
MapState
contains
in interface MapState<UK,UV>
userKey
- The key of the mappingIOException
org.rocksdb.RocksDBException
public Iterable<Map.Entry<UK,UV>> entries() throws IOException, org.rocksdb.RocksDBException
MapState
entries
in interface MapState<UK,UV>
IOException
org.rocksdb.RocksDBException
public Iterable<UK> keys() throws IOException, org.rocksdb.RocksDBException
MapState
keys
in interface MapState<UK,UV>
IOException
org.rocksdb.RocksDBException
public Iterable<UV> values() throws IOException, org.rocksdb.RocksDBException
MapState
values
in interface MapState<UK,UV>
IOException
org.rocksdb.RocksDBException
public Iterator<Map.Entry<UK,UV>> iterator() throws IOException, org.rocksdb.RocksDBException
MapState
iterator
in interface MapState<UK,UV>
IOException
org.rocksdb.RocksDBException
public void clear()
State
public byte[] getSerializedValue(byte[] serializedKeyAndNamespace) throws Exception
InternalKvState
If no value is associated with key and namespace, null
is returned.
getSerializedValue
in interface InternalKvState<N>
getSerializedValue
in class AbstractRocksDBState<K,N,MapState<UK,UV>,MapStateDescriptor<UK,UV>,Map<UK,UV>>
serializedKeyAndNamespace
- Serialized key and namespacenull
if no value is associated with the key and namespace.Exception
- Exceptions during serialization are forwardedCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.