T
- element typepublic abstract class AnalyticHelper<T>
extends org.apache.flink.api.common.io.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,
org.apache.flink.api.common.accumulators.Accumulator<V,A> accumulator)
Adds an accumulator by prepending the given name with a random string.
|
void |
configure(org.apache.flink.configuration.Configuration parameters) |
<A> A |
getAccumulator(org.apache.flink.api.java.ExecutionEnvironment env,
String accumulatorName)
Gets the accumulator with the given name.
|
void |
open(int taskNumber,
int numTasks) |
getRuntimeContext, setRuntimeContext
public void configure(org.apache.flink.configuration.Configuration parameters)
public void open(int taskNumber, int numTasks) throws IOException
IOException
public <V,A extends Serializable> void addAccumulator(String name, org.apache.flink.api.common.accumulators.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(org.apache.flink.api.java.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–2017 The Apache Software Foundation. All rights reserved.