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,List<V>,ListState<V>> implements InternalListState<K,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, defaultValue, keySerializationDataOutputView, keySerializationStream, writeOptions
Constructor and Description |
---|
RocksDBListState(org.rocksdb.ColumnFamilyHandle columnFamily,
TypeSerializer<N> namespaceSerializer,
TypeSerializer<List<V>> valueSerializer,
List<V> defaultValue,
TypeSerializer<V> elementSerializer,
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. |
void |
addAll(List<V> values)
Updates the operator state accessible by
AppendingState.get() by adding the given values
to existing list of values. |
Iterable<V> |
get()
Returns the current value for the state.
|
TypeSerializer<K> |
getKeySerializer()
Returns the
TypeSerializer for the type of key this state is associated to. |
TypeSerializer<N> |
getNamespaceSerializer()
Returns the
TypeSerializer for the type of namespace this state is associated to. |
TypeSerializer<List<V>> |
getValueSerializer()
Returns the
TypeSerializer for the type of value this state holds. |
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.
|
void |
update(List<V> values)
Updates the operator state accessible by
AppendingState.get() by updating existing values to
to the given list of values. |
clear, getDefaultValue, getSerializedValue, setCurrentNamespace, writeCurrentKeyWithGroupAndNamespace, writeKeyWithGroupAndNamespace, writeKeyWithGroupAndNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSerializedValue, setCurrentNamespace
public RocksDBListState(org.rocksdb.ColumnFamilyHandle columnFamily, TypeSerializer<N> namespaceSerializer, TypeSerializer<List<V>> valueSerializer, List<V> defaultValue, TypeSerializer<V> elementSerializer, RocksDBKeyedStateBackend<K> backend)
RocksDBListState
.columnFamily
- The RocksDB column family that this state is associated to.namespaceSerializer
- The serializer for the namespace.valueSerializer
- The serializer for the state.defaultValue
- The default value for the state.elementSerializer
- The serializer for elements of the list state.backend
- The backend for which this state is bind to.public TypeSerializer<K> getKeySerializer()
InternalKvState
TypeSerializer
for the type of key this state is associated to.getKeySerializer
in interface InternalKvState<K,N,List<V>>
public TypeSerializer<N> getNamespaceSerializer()
InternalKvState
TypeSerializer
for the type of namespace this state is associated to.getNamespaceSerializer
in interface InternalKvState<K,N,List<V>>
public TypeSerializer<List<V>> getValueSerializer()
InternalKvState
TypeSerializer
for the type of value this state holds.getValueSerializer
in interface InternalKvState<K,N,List<V>>
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.
If null is passed in, the state value will remain unchanged.
add
in interface AppendingState<V,Iterable<V>>
value
- The new value for the state.IOException
public void mergeNamespaces(N target, Collection<N> sources) throws Exception
InternalMergingState
mergeNamespaces
in interface InternalMergingState<K,N,V,List<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).public void update(List<V> values) throws Exception
InternalListState
AppendingState.get()
by updating existing values to
to the given list of values. The next time AppendingState.get()
is called (for the same state
partition) the returned state will represent the updated list.
If `null` or an empty list is passed in, the state value will be nullpublic void addAll(List<V> values) throws Exception
InternalListState
AppendingState.get()
by adding the given values
to existing list of values. The next time AppendingState.get()
is called (for the same state
partition) the returned state will represent the updated list.
If `null` or an empty list is passed in, the state value remains unchangedCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.