T
- element typepublic abstract class AnalyticHelper<T> extends RichOutputFormat<T>
GraphAnalytic
computes over a DataSet and returns the results via Flink accumulators.
This computation is cheaply performed in a terminating RichOutputFormat
.
This class simplifies the creation of analytic helpers by providing pass-through methods for
adding and getting accumulators. Each accumulator name is prefixed with a random string since
Flink accumulators share a per-job global namespace. This class also provides empty
implementations of OutputFormat.open(int, int)
and OutputFormat.close()
.
Constructor and Description |
---|
AnalyticHelper() |
Modifier and Type | Method and Description |
---|---|
<V,A extends Serializable> |
addAccumulator(String name,
Accumulator<V,A> accumulator)
Adds an accumulator by prepending the given name with a random string.
|
void |
configure(Configuration parameters)
Configures this output format.
|
<A> A |
getAccumulator(ExecutionEnvironment env,
String accumulatorName)
Gets the accumulator with the given name.
|
void |
open(int taskNumber,
int numTasks)
Opens a parallel instance of the output format to store the result of its parallel instance.
|
getRuntimeContext, setRuntimeContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, writeRecord
public void configure(Configuration parameters)
OutputFormat
This method is always called first on a newly instantiated output format.
parameters
- The configuration with all parameters.public void open(int taskNumber, int numTasks) throws IOException
OutputFormat
When this method is called, the output format it guaranteed to be configured.
taskNumber
- The number of the parallel instance.numTasks
- The number of parallel tasks.IOException
- Thrown, if the output could not be opened due to an I/O problem.public <V,A extends Serializable> void addAccumulator(String name, Accumulator<V,A> accumulator)
V
- Type of values that are added to the accumulatorA
- Type of the accumulator result as it will be reported to the clientname
- The name of the accumulatoraccumulator
- The accumulatorpublic <A> A getAccumulator(ExecutionEnvironment env, String accumulatorName)
null
, if no accumulator with that
name was produced.A
- The generic type of the accumulator valueaccumulatorName
- The name of the accumulatorCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.