N
- The type of the namespace.T
- The type of the values stored in this ReducingState
.W
- Generic type that extends both the underlying ValueState
and KvState
.public class GenericReducingState<N,T,W extends ValueState<T> & KvState<N>> extends Object implements ReducingState<T>, KvState<N>
ReducingState
based on a wrapped ValueState
.Constructor and Description |
---|
GenericReducingState(ValueState<T> wrappedState,
ReduceFunction<T> reduceFunction)
Creates a new
ReducingState that wraps the given ValueState . |
Modifier and Type | Method and Description |
---|---|
void |
add(T value) |
void |
clear() |
T |
get() |
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace)
Returns the serialized value for the given key and namespace.
|
void |
setCurrentNamespace(N namespace)
Sets the current namespace, which will be used when using the state access methods.
|
public GenericReducingState(ValueState<T> wrappedState, ReduceFunction<T> reduceFunction)
ReducingState
that wraps the given ValueState
. The
ValueState
must have a default value of null
.wrappedState
- The wrapped ValueState
reduceFunction
- The ReduceFunction
to use for combining values.public void setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<N>
namespace
- The namespace.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace) throws Exception
KvState
If no value is associated with key and namespace, null
is returned.
getSerializedValue
in interface KvState<N>
serializedKeyAndNamespace
- Serialized key and namespacenull
if no value is associated
with the key and namespace.Exception
- Exceptions during serialization are forwardedpublic T get() throws Exception
get
in interface AppendingState<T,T>
Exception
public void add(T value) throws Exception
add
in interface AppendingState<T,T>
Exception
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.