Java Code Examples for com.google.cloud.dataflow.sdk.transforms.Combine#CombineFn

The following examples show how to use com.google.cloud.dataflow.sdk.transforms.Combine#CombineFn . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlinkGroupAlsoByWindowWrapper.java    From flink-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
protected <AggInputT, AggOutputT> Aggregator<AggInputT, AggOutputT> createAggregatorInternal(String name, Combine.CombineFn<AggInputT, ?, AggOutputT> combiner) {
	Accumulator acc = getRuntimeContext().getAccumulator(name);
	if (acc != null) {
		AccumulatorHelper.compareAccumulatorTypes(name,
				SerializableFnAggregatorWrapper.class, acc.getClass());
		return (Aggregator<AggInputT, AggOutputT>) acc;
	}

	SerializableFnAggregatorWrapper<AggInputT, AggOutputT> accumulator =
			new SerializableFnAggregatorWrapper<>(combiner);
	getRuntimeContext().addAccumulator(name, accumulator);
	return accumulator;
}
 
Example 2
Source File: FlinkAbstractParDoWrapper.java    From flink-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
protected <AggInputT, AggOutputT> Aggregator<AggInputT, AggOutputT> createAggregatorInternal(String name, Combine.CombineFn<AggInputT, ?, AggOutputT> combiner) {
	Accumulator acc = getRuntimeContext().getAccumulator(name);
	if (acc != null) {
		AccumulatorHelper.compareAccumulatorTypes(name,
				SerializableFnAggregatorWrapper.class, acc.getClass());
		return (Aggregator<AggInputT, AggOutputT>) acc;
	}

	SerializableFnAggregatorWrapper<AggInputT, AggOutputT> accumulator =
			new SerializableFnAggregatorWrapper<>(combiner);
	getRuntimeContext().addAccumulator(name, accumulator);
	return accumulator;
}
 
Example 3
Source File: CombineFnAggregatorWrapper.java    From flink-dataflow with Apache License 2.0 4 votes vote down vote up
public CombineFnAggregatorWrapper(Combine.CombineFn<? super AI, AA, AR> combiner) {
	this.combiner = combiner;
	this.aa = combiner.createAccumulator();
}
 
Example 4
Source File: CombineFnAggregatorWrapper.java    From flink-dataflow with Apache License 2.0 4 votes vote down vote up
@Override
public Combine.CombineFn getCombineFn() {
	return combiner;
}
 
Example 5
Source File: SerializableFnAggregatorWrapper.java    From flink-dataflow with Apache License 2.0 4 votes vote down vote up
public SerializableFnAggregatorWrapper(Combine.CombineFn<AI, ?, AO> combiner) {
	this.combiner = combiner;
	resetLocal();
}
 
Example 6
Source File: SerializableFnAggregatorWrapper.java    From flink-dataflow with Apache License 2.0 4 votes vote down vote up
@Override
public Combine.CombineFn<AI, ?, AO> getCombineFn() {
	return combiner;
}
 
Example 7
Source File: FlinkStateInternals.java    From flink-dataflow with Apache License 2.0 4 votes vote down vote up
private FlinkInMemoryKeyedCombiningValue(ByteString stateKey,
                                         Combine.CombineFn<InputT, AccumT, OutputT> combineFn,
                                         Coder<AccumT> accumCoder,
                                         final StateContext<?> stateContext) {
	this(stateKey, withKeyAndContext(combineFn), accumCoder, stateContext);
}
 
Example 8
Source File: FlinkMultiOutputDoFnFunction.java    From flink-dataflow with Apache License 2.0 4 votes vote down vote up
@Override
protected <AggInputT, AggOutputT> Aggregator<AggInputT, AggOutputT> createAggregatorInternal(String name, Combine.CombineFn<AggInputT, ?, AggOutputT> combiner) {
	SerializableFnAggregatorWrapper<AggInputT, AggOutputT> wrapper = new SerializableFnAggregatorWrapper<>(combiner);
	getRuntimeContext().addAccumulator(name, wrapper);
	return null;
}
 
Example 9
Source File: FlinkDoFnFunction.java    From flink-dataflow with Apache License 2.0 4 votes vote down vote up
@Override
protected <AggInputT, AggOutputT> Aggregator<AggInputT, AggOutputT> createAggregatorInternal(String name, Combine.CombineFn<AggInputT, ?, AggOutputT> combiner) {
	SerializableFnAggregatorWrapper<AggInputT, AggOutputT> wrapper = new SerializableFnAggregatorWrapper<>(combiner);
	getRuntimeContext().addAccumulator(name, wrapper);
	return wrapper;
}