K
- The type of the keyN
- The type of the namespaceT
- The type of the values that aggregated into the stateACC
- The type of the value stored in the state (the accumulator type)R
- The type of the value returned from the statepublic class RocksDBAggregatingState<K,N,T,ACC,R> extends AbstractRocksDBState<K,N,AggregatingState<T,R>,AggregatingStateDescriptor<T,ACC,R>,ACC> implements InternalAggregatingState<N,T,R>
AggregatingState
implementation that stores state in RocksDB.backend, columnFamily, keySerializationDataOutputView, keySerializationStream, stateDesc
Constructor and Description |
---|
RocksDBAggregatingState(org.rocksdb.ColumnFamilyHandle columnFamily,
TypeSerializer<N> namespaceSerializer,
AggregatingStateDescriptor<T,ACC,R> stateDesc,
RocksDBKeyedStateBackend<K> backend)
Creates a new
RocksDBFoldingState . |
Modifier and Type | Method and Description |
---|---|
void |
add(T value)
Updates the operator state accessible by
AppendingState.get() by adding the given value
to the list of values. |
R |
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 RocksDBAggregatingState(org.rocksdb.ColumnFamilyHandle columnFamily, TypeSerializer<N> namespaceSerializer, AggregatingStateDescriptor<T,ACC,R> stateDesc, RocksDBKeyedStateBackend<K> backend)
RocksDBFoldingState
.namespaceSerializer
- The serializer for the namespace.stateDesc
- The state identifier for the state. This contains the state name and aggregation function.public R get() throws IOException
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
get
in interface AppendingState<T,R>
null
if the state is empty.IOException
public void add(T 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<T,R>
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,T,R>
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.