Java Code Examples for org.apache.flink.api.common.accumulators.AccumulatorHelper#compareAccumulatorTypes()
The following examples show how to use
org.apache.flink.api.common.accumulators.AccumulatorHelper#compareAccumulatorTypes() .
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: AbstractRuntimeUDFContext.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <V, A extends Serializable> Accumulator<V, A> getAccumulator(String name, Class<? extends Accumulator<V, A>> accumulatorClass) { Accumulator<?, ?> accumulator = accumulators.get(name); if (accumulator != null) { AccumulatorHelper.compareAccumulatorTypes(name, accumulator.getClass(), accumulatorClass); } else { // Create new accumulator try { accumulator = accumulatorClass.newInstance(); } catch (Exception e) { throw new RuntimeException("Cannot create accumulator " + accumulatorClass.getName()); } accumulators.put(name, accumulator); } return (Accumulator<V, A>) accumulator; }
Example 2
Source File: AbstractRuntimeUDFContext.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <V, A extends Serializable> Accumulator<V, A> getAccumulator(String name, Class<? extends Accumulator<V, A>> accumulatorClass) { Accumulator<?, ?> accumulator = accumulators.get(name); if (accumulator != null) { AccumulatorHelper.compareAccumulatorTypes(name, accumulator.getClass(), accumulatorClass); } else { // Create new accumulator try { accumulator = accumulatorClass.newInstance(); } catch (Exception e) { throw new RuntimeException("Cannot create accumulator " + accumulatorClass.getName()); } accumulators.put(name, accumulator); } return (Accumulator<V, A>) accumulator; }
Example 3
Source File: AbstractRuntimeUDFContext.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <V, A extends Serializable> Accumulator<V, A> getAccumulator(String name, Class<? extends Accumulator<V, A>> accumulatorClass) { Accumulator<?, ?> accumulator = accumulators.get(name); if (accumulator != null) { AccumulatorHelper.compareAccumulatorTypes(name, accumulator.getClass(), accumulatorClass); } else { // Create new accumulator try { accumulator = accumulatorClass.newInstance(); } catch (Exception e) { throw new RuntimeException("Cannot create accumulator " + accumulatorClass.getName()); } accumulators.put(name, accumulator); } return (Accumulator<V, A>) accumulator; }
Example 4
Source File: FlinkGroupAlsoByWindowWrapper.java From flink-dataflow with Apache License 2.0 | 5 votes |
@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 5
Source File: FlinkAbstractParDoWrapper.java From flink-dataflow with Apache License 2.0 | 5 votes |
@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; }