K
- The type of the key.N
- The type of the namespace.V
- The type of value that the state state stores.public class RocksDBReducingState<K,N,V> extends AbstractRocksDBState<K,N,V,ReducingState<V>> implements InternalReducingState<K,N,V>
ReducingState
implementation that stores state in RocksDB.backend, columnFamily, defaultValue, keySerializationDataOutputView, keySerializationStream, writeOptions
Constructor and Description |
---|
RocksDBReducingState(org.rocksdb.ColumnFamilyHandle columnFamily,
TypeSerializer<N> namespaceSerializer,
TypeSerializer<V> valueSerializer,
V defaultValue,
ReduceFunction<V> reduceFunction,
RocksDBKeyedStateBackend<K> backend)
Creates a new
RocksDBReducingState . |
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. |
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<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.
|
clear, getDefaultValue, getSerializedValue, setCurrentNamespace, writeCurrentKeyWithGroupAndNamespace, writeKeyWithGroupAndNamespace, writeKeyWithGroupAndNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSerializedValue, setCurrentNamespace
public RocksDBReducingState(org.rocksdb.ColumnFamilyHandle columnFamily, TypeSerializer<N> namespaceSerializer, TypeSerializer<V> valueSerializer, V defaultValue, ReduceFunction<V> reduceFunction, RocksDBKeyedStateBackend<K> backend)
RocksDBReducingState
.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.reduceFunction
- The reduce function used for reducing 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,V>
public TypeSerializer<N> getNamespaceSerializer()
InternalKvState
TypeSerializer
for the type of namespace this state is associated to.getNamespaceSerializer
in interface InternalKvState<K,N,V>
public TypeSerializer<V> getValueSerializer()
InternalKvState
TypeSerializer
for the type of value this state holds.getValueSerializer
in interface InternalKvState<K,N,V>
public V get()
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
get
in interface AppendingState<V,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,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,V,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–2019 The Apache Software Foundation. All rights reserved.