K
- The type of the key.N
- The type of the namespace.V
- The type of the values in the list state.public class RocksDBListState<K,N,V> extends AbstractRocksDBState<K,N,ListState<V>,ListStateDescriptor<V>,List<V>> implements InternalListState<N,V>
ListState
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 |
---|
RocksDBListState(org.rocksdb.ColumnFamilyHandle columnFamily,
TypeSerializer<N> namespaceSerializer,
ListStateDescriptor<V> stateDesc,
RocksDBKeyedStateBackend<K> backend)
Creates a new
RocksDBListState . |
Modifier and Type | Method and Description |
---|---|
void |
add(V value)
Updates the operator state accessible by
AppendingState.get() by adding the given value
to the list of values. |
Iterable<V> |
get()
Returns the current value for the state.
|
void |
mergeNamespaces(N target,
Collection<N> sources)
Merges the state of the current key for the given source namespaces into the state of
the target namespace.
|
clear, getSerializedValue, readKeyWithGroupAndNamespace, setCurrentNamespace, writeCurrentKeyWithGroupAndNamespace, writeKeyWithGroupAndNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSerializedValue, setCurrentNamespace
public RocksDBListState(org.rocksdb.ColumnFamilyHandle columnFamily, TypeSerializer<N> namespaceSerializer, ListStateDescriptor<V> stateDesc, RocksDBKeyedStateBackend<K> backend)
RocksDBListState
.namespaceSerializer
- The serializer for the namespace.stateDesc
- The state identifier for the state. This contains name
and can create a default state value.public Iterable<V> get()
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
get
in interface AppendingState<V,Iterable<V>>
null
if the state is empty.public void add(V value) throws IOException
AppendingState
AppendingState.get()
by adding the given value
to the list of values. The next time AppendingState.get()
is called (for the same state
partition) the returned state will represent the updated list.add
in interface AppendingState<V,Iterable<V>>
value
- The new value for the state.IOException
- Thrown if the system cannot access the state.public void mergeNamespaces(N target, Collection<N> sources) throws Exception
InternalMergingState
mergeNamespaces
in interface InternalMergingState<N,V,Iterable<V>>
target
- The target namespace where the merged state should be stored.sources
- The source namespaces whose state should be merged.Exception
- The method may forward exception thrown internally (by I/O or functions).Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.