Class Top.TopCombineFn<T,ComparatorT extends java.util.Comparator<T> & java.io.Serializable>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.Combine.CombineFn<InputT,AccumT,OutputT>
-
- org.apache.beam.sdk.transforms.Combine.AccumulatingCombineFn<T,org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT>,java.util.List<T>>
-
- org.apache.beam.sdk.transforms.Top.TopCombineFn<T,ComparatorT>
-
- Type Parameters:
T
- type of element being compared
- All Implemented Interfaces:
java.io.Serializable
,CombineFnBase.GlobalCombineFn<T,org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT>,java.util.List<T>>
,HasDisplayData
,NameUtils.NameOverride
- Enclosing class:
- Top
public static class Top.TopCombineFn<T,ComparatorT extends java.util.Comparator<T> & java.io.Serializable> extends Combine.AccumulatingCombineFn<T,org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT>,java.util.List<T>> implements NameUtils.NameOverride
CombineFn
forTop
transforms that combines a bunch ofT
s into a singlecount
-longList<T>
, usingcompareFn
to choose the largestT
s.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.beam.sdk.transforms.Combine.AccumulatingCombineFn
Combine.AccumulatingCombineFn.Accumulator<InputT,AccumT,OutputT>
-
-
Constructor Summary
Constructors Constructor Description TopCombineFn(int count, ComparatorT compareFn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT>
createAccumulator()
Returns a new, mutable accumulator value, representing the accumulation of zero input values.java.lang.reflect.TypeVariable<?>
getAccumTVariable()
Returns theTypeVariable
ofAccumT
.Coder<org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT>>
getAccumulatorCoder(CoderRegistry registry, Coder<T> inputCoder)
Returns theCoder
to use for accumulatorAccumT
values, or null if it is not able to be inferred.Coder<OutputT>
getDefaultOutputCoder(CoderRegistry registry, Coder<InputT> inputCoder)
Returns theCoder
to use by default for outputOutputT
values, or null if it is not able to be inferred.java.lang.String
getIncompatibleGlobalWindowErrorMessage()
Returns the error message for not supported default values in Combine.globally().java.lang.reflect.TypeVariable<?>
getInputTVariable()
Returns theTypeVariable
ofInputT
.java.lang.String
getNameOverride()
Return the name to use for this instance.java.lang.reflect.TypeVariable<?>
getOutputTVariable()
Returns theTypeVariable
ofOutputT
.void
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.-
Methods inherited from class org.apache.beam.sdk.transforms.Combine.AccumulatingCombineFn
addInput, extractOutput, mergeAccumulators
-
Methods inherited from class org.apache.beam.sdk.transforms.Combine.CombineFn
apply, compact, defaultValue, getInputType, getOutputType
-
-
-
-
Constructor Detail
-
TopCombineFn
public TopCombineFn(int count, ComparatorT compareFn)
-
-
Method Detail
-
getNameOverride
public java.lang.String getNameOverride()
Description copied from interface:NameUtils.NameOverride
Return the name to use for this instance.- Specified by:
getNameOverride
in interfaceNameUtils.NameOverride
-
createAccumulator
public org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT> createAccumulator()
Description copied from class:Combine.CombineFn
Returns a new, mutable accumulator value, representing the accumulation of zero input values.- Specified by:
createAccumulator
in classCombine.CombineFn<T,org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT extends java.util.Comparator<T> & java.io.Serializable>,java.util.List<T>>
-
getAccumulatorCoder
public Coder<org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT>> getAccumulatorCoder(CoderRegistry registry, Coder<T> inputCoder)
Description copied from interface:CombineFnBase.GlobalCombineFn
Returns theCoder
to use for accumulatorAccumT
values, or null if it is not able to be inferred.By default, uses the knowledge of the
Coder
being used forInputT
values and the enclosingPipeline
'sCoderRegistry
to try to infer the Coder forAccumT
values.This is the Coder used to send data through a communication-intensive shuffle step, so a compact and efficient representation may have significant performance benefits.
- Specified by:
getAccumulatorCoder
in interfaceCombineFnBase.GlobalCombineFn<T,org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT extends java.util.Comparator<T> & java.io.Serializable>,java.util.List<T>>
-
populateDisplayData
public void populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect display data viaDisplayData.from(HasDisplayData)
. Implementations may callsuper.populateDisplayData(builder)
in order to register display data in the current namespace, but should otherwise usesubcomponent.populateDisplayData(builder)
to use the namespace of the subcomponent.By default, does not register any display data. Implementors may override this method to provide their own display data.
- Specified by:
populateDisplayData
in interfaceHasDisplayData
- Parameters:
builder
- The builder to populate with display data.- See Also:
HasDisplayData
-
getIncompatibleGlobalWindowErrorMessage
public java.lang.String getIncompatibleGlobalWindowErrorMessage()
Description copied from interface:CombineFnBase.GlobalCombineFn
Returns the error message for not supported default values in Combine.globally().- Specified by:
getIncompatibleGlobalWindowErrorMessage
in interfaceCombineFnBase.GlobalCombineFn<T,org.apache.beam.sdk.transforms.Top.BoundedHeap<T,ComparatorT extends java.util.Comparator<T> & java.io.Serializable>,java.util.List<T>>
-
getDefaultOutputCoder
public Coder<OutputT> getDefaultOutputCoder(CoderRegistry registry, Coder<InputT> inputCoder) throws CannotProvideCoderException
Description copied from interface:CombineFnBase.GlobalCombineFn
Returns theCoder
to use by default for outputOutputT
values, or null if it is not able to be inferred.By default, uses the knowledge of the
Coder
being used for inputInputT
values and the enclosingPipeline
'sCoderRegistry
to try to infer the Coder forOutputT
values.- Specified by:
getDefaultOutputCoder
in interfaceCombineFnBase.GlobalCombineFn<InputT,AccumT,OutputT>
- Throws:
CannotProvideCoderException
-
getInputTVariable
public java.lang.reflect.TypeVariable<?> getInputTVariable()
Returns theTypeVariable
ofInputT
.
-
getAccumTVariable
public java.lang.reflect.TypeVariable<?> getAccumTVariable()
Returns theTypeVariable
ofAccumT
.
-
getOutputTVariable
public java.lang.reflect.TypeVariable<?> getOutputTVariable()
Returns theTypeVariable
ofOutputT
.
-
-