K
- Type of the keysOUT
- Type of the output elements.@PublicEvolving public abstract class KeyedStateReaderFunction<K,OUT> extends AbstractRichFunction
For every key readKey(Object, Context, Collector)
is invoked. This can produce zero
or more elements as output.
NOTE: State descriptors must be eagerly registered in open(Configuration)
. Any
attempt to dynamically register states inside of readKey
will result in a RuntimeException
.
NOTE: A KeyedStateReaderFunction
is always a RichFunction
. Therefore, access to the RuntimeContext
is always available and setup and teardown
methods can be implemented. See RichFunction.open(OpenContext)
and RichFunction.close()
.
Modifier and Type | Class and Description |
---|---|
static interface |
KeyedStateReaderFunction.Context
Context that
KeyedStateReaderFunction 's can use for getting additional data about an
input record. |
Constructor and Description |
---|
KeyedStateReaderFunction() |
Modifier and Type | Method and Description |
---|---|
abstract void |
open(Configuration parameters)
Initialization method for the function.
|
abstract void |
readKey(K key,
KeyedStateReaderFunction.Context ctx,
Collector<OUT> out)
Process one key from the restored state backend.
|
close, getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
open
public abstract void open(Configuration parameters) throws Exception
readKey(Object, Context,
Collector)
and thus suitable for one time setup work.
This is the only method that my register state descriptors within a KeyedStateReaderFunction
.
open
in interface RichFunction
open
in class AbstractRichFunction
parameters
- The configuration containing the parameters attached to the contract.Exception
- Implementations may forward exceptions, which are caught by the runtime.
When the runtime catches an exception, it aborts the task and lets the fail-over logic
decide whether to retry the task execution.Configuration
,
FLIP-344: Remove parameter in RichFunction#open public abstract void readKey(K key, KeyedStateReaderFunction.Context ctx, Collector<OUT> out) throws Exception
This function can read partitioned state from the restored state backend and output zero
or more elements using the Collector
parameter.
key
- The input value.out
- The collector for returning result values.Exception
- This method may throw exceptions. Throwing an exception will cause the
operation to fail and may trigger recovery.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.