Class AccumulatorHelper
- java.lang.Object
-
- org.apache.flink.api.common.accumulators.AccumulatorHelper
-
@Internal public class AccumulatorHelper extends Object
Helper functions for the interaction withAccumulator
.
-
-
Constructor Summary
Constructors Constructor Description AccumulatorHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
compareAccumulatorTypes(Object name, Class<? extends Accumulator> first, Class<? extends Accumulator> second)
Compare both classes and throwUnsupportedOperationException
if they differ.static Map<String,Accumulator<?,?>>
copy(Map<String,Accumulator<?,?>> accumulators)
static Map<String,OptionalFailure<Object>>
deserializeAccumulators(Map<String,SerializedValue<OptionalFailure<Object>>> serializedAccumulators, ClassLoader loader)
Takes the serialized accumulator results and tries to deserialize them using the provided class loader.static Map<String,Object>
deserializeAndUnwrapAccumulators(Map<String,SerializedValue<OptionalFailure<Object>>> serializedAccumulators, ClassLoader loader)
Takes the serialized accumulator results and tries to deserialize them using the provided class loader, and then try to unwrap the value unchecked.static String
getResultsFormatted(Map<String,Object> map)
static void
mergeInto(Map<String,OptionalFailure<Accumulator<?,?>>> target, Map<String,Accumulator<?,?>> toMerge)
Merge two collections of accumulators.static Map<String,OptionalFailure<Object>>
toResultMap(Map<String,Accumulator<?,?>> accumulators)
Transform the Map with accumulators into a Map containing only the results.
-
-
-
Method Detail
-
mergeInto
public static void mergeInto(Map<String,OptionalFailure<Accumulator<?,?>>> target, Map<String,Accumulator<?,?>> toMerge)
Merge two collections of accumulators. The second will be merged into the first.- Parameters:
target
- The collection of accumulators that will be updatedtoMerge
- The collection of accumulators that will be merged into the other
-
compareAccumulatorTypes
public static void compareAccumulatorTypes(Object name, Class<? extends Accumulator> first, Class<? extends Accumulator> second) throws UnsupportedOperationException
Compare both classes and throwUnsupportedOperationException
if they differ.- Throws:
UnsupportedOperationException
-
toResultMap
public static Map<String,OptionalFailure<Object>> toResultMap(Map<String,Accumulator<?,?>> accumulators)
Transform the Map with accumulators into a Map containing only the results.
-
copy
public static Map<String,Accumulator<?,?>> copy(Map<String,Accumulator<?,?>> accumulators)
-
deserializeAccumulators
public static Map<String,OptionalFailure<Object>> deserializeAccumulators(Map<String,SerializedValue<OptionalFailure<Object>>> serializedAccumulators, ClassLoader loader) throws IOException, ClassNotFoundException
Takes the serialized accumulator results and tries to deserialize them using the provided class loader.- Parameters:
serializedAccumulators
- The serialized accumulator results.loader
- The class loader to use.- Returns:
- The deserialized accumulator results.
- Throws:
IOException
ClassNotFoundException
-
deserializeAndUnwrapAccumulators
public static Map<String,Object> deserializeAndUnwrapAccumulators(Map<String,SerializedValue<OptionalFailure<Object>>> serializedAccumulators, ClassLoader loader) throws IOException, ClassNotFoundException
Takes the serialized accumulator results and tries to deserialize them using the provided class loader, and then try to unwrap the value unchecked.- Parameters:
serializedAccumulators
- The serialized accumulator results.loader
- The class loader to use.- Returns:
- The deserialized and unwrapped accumulator results.
- Throws:
IOException
ClassNotFoundException
-
-