Class ApproximateDistinct.ApproximateDistinctFn<InputT>
- java.lang.Object
-
- org.apache.beam.sdk.transforms.Combine.CombineFn<InputT,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus>
-
- org.apache.beam.sdk.extensions.sketching.ApproximateDistinct.ApproximateDistinctFn<InputT>
-
- Type Parameters:
InputT- the type of the elements in the inputPCollection
- All Implemented Interfaces:
java.io.Serializable,org.apache.beam.sdk.transforms.CombineFnBase.GlobalCombineFn<InputT,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus>,org.apache.beam.sdk.transforms.display.HasDisplayData
- Enclosing class:
- ApproximateDistinct
public static class ApproximateDistinct.ApproximateDistinctFn<InputT> extends org.apache.beam.sdk.transforms.Combine.CombineFn<InputT,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus>Implements theCombine.CombineFnofApproximateDistincttransforms.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.clearspring.analytics.stream.cardinality.HyperLogLogPlusaddInput(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus acc, InputT record)static <InputT> ApproximateDistinct.ApproximateDistinctFn<InputT>create(org.apache.beam.sdk.coders.Coder<InputT> coder)Returns anApproximateDistinct.ApproximateDistinctFncombiner with the given input coder.com.clearspring.analytics.stream.cardinality.HyperLogLogPluscreateAccumulator()com.clearspring.analytics.stream.cardinality.HyperLogLogPlusextractOutput(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus accumulator)Output the whole structure so it can be queried, reused or stored easily.java.lang.reflect.TypeVariable<?>getAccumTVariable()org.apache.beam.sdk.coders.Coder<AccumT>getAccumulatorCoder(org.apache.beam.sdk.coders.CoderRegistry arg0, org.apache.beam.sdk.coders.Coder<@UnknownKeyFor @NonNull @Initialized InputT> arg1)org.apache.beam.sdk.coders.Coder<OutputT>getDefaultOutputCoder(org.apache.beam.sdk.coders.CoderRegistry arg0, org.apache.beam.sdk.coders.Coder<@UnknownKeyFor @NonNull @Initialized InputT> arg1)java.lang.StringgetIncompatibleGlobalWindowErrorMessage()java.lang.reflect.TypeVariable<?>getInputTVariable()java.lang.reflect.TypeVariable<?>getOutputTVariable()com.clearspring.analytics.stream.cardinality.HyperLogLogPlusmergeAccumulators(java.lang.Iterable<com.clearspring.analytics.stream.cardinality.HyperLogLogPlus> accumulators)voidpopulateDisplayData(org.apache.beam.sdk.transforms.display.DisplayData.Builder builder)ApproximateDistinct.ApproximateDistinctFn<InputT>withPrecision(int p)Returns anApproximateDistinct.ApproximateDistinctFncombiner with a new precisionp.ApproximateDistinct.ApproximateDistinctFn<InputT>withSparseRepresentation(int sp)Returns anApproximateDistinct.ApproximateDistinctFncombiner with a new sparse representation's precisionsp.
-
-
-
Method Detail
-
create
public static <InputT> ApproximateDistinct.ApproximateDistinctFn<InputT> create(org.apache.beam.sdk.coders.Coder<InputT> coder)
Returns anApproximateDistinct.ApproximateDistinctFncombiner with the given input coder.- Parameters:
coder- the coder that encodes the elements' type
-
withPrecision
public ApproximateDistinct.ApproximateDistinctFn<InputT> withPrecision(int p)
Returns anApproximateDistinct.ApproximateDistinctFncombiner with a new precisionp.Keep in mind that
pcannot be lower than 4, because the estimation would be too inaccurate.See
ApproximateDistinct.precisionForRelativeError(double)andApproximateDistinct.relativeErrorForPrecision(int)to have more information about the relationship between precision and relative error.- Parameters:
p- the precision value for the normal representation
-
withSparseRepresentation
public ApproximateDistinct.ApproximateDistinctFn<InputT> withSparseRepresentation(int sp)
Returns anApproximateDistinct.ApproximateDistinctFncombiner with a new sparse representation's precisionsp.Values above 32 are not yet supported by the AddThis version of HyperLogLog+.
Fore more information about the sparse representation, read Google's paper available here.
- Parameters:
sp- the precision of HyperLogLog+' sparse representation
-
createAccumulator
public com.clearspring.analytics.stream.cardinality.HyperLogLogPlus createAccumulator()
- Specified by:
createAccumulatorin classorg.apache.beam.sdk.transforms.Combine.CombineFn<InputT,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus>
-
addInput
public com.clearspring.analytics.stream.cardinality.HyperLogLogPlus addInput(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus acc, InputT record)- Specified by:
addInputin classorg.apache.beam.sdk.transforms.Combine.CombineFn<InputT,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus>
-
extractOutput
public com.clearspring.analytics.stream.cardinality.HyperLogLogPlus extractOutput(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus accumulator)
Output the whole structure so it can be queried, reused or stored easily.- Specified by:
extractOutputin classorg.apache.beam.sdk.transforms.Combine.CombineFn<InputT,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus>
-
mergeAccumulators
public com.clearspring.analytics.stream.cardinality.HyperLogLogPlus mergeAccumulators(java.lang.Iterable<com.clearspring.analytics.stream.cardinality.HyperLogLogPlus> accumulators)
- Specified by:
mergeAccumulatorsin classorg.apache.beam.sdk.transforms.Combine.CombineFn<InputT,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus,com.clearspring.analytics.stream.cardinality.HyperLogLogPlus>
-
populateDisplayData
public void populateDisplayData(org.apache.beam.sdk.transforms.display.DisplayData.Builder builder)
- Specified by:
populateDisplayDatain interfaceorg.apache.beam.sdk.transforms.display.HasDisplayData
-
getAccumulatorCoder
public org.apache.beam.sdk.coders.Coder<AccumT> getAccumulatorCoder(org.apache.beam.sdk.coders.CoderRegistry arg0, org.apache.beam.sdk.coders.Coder<@UnknownKeyFor @NonNull @Initialized InputT> arg1) throws org.apache.beam.sdk.coders.CannotProvideCoderException- Specified by:
getAccumulatorCoderin interfaceorg.apache.beam.sdk.transforms.CombineFnBase.GlobalCombineFn<InputT extends java.lang.Object,AccumT extends java.lang.Object,OutputT extends java.lang.Object>- Throws:
org.apache.beam.sdk.coders.CannotProvideCoderException
-
getDefaultOutputCoder
public org.apache.beam.sdk.coders.Coder<OutputT> getDefaultOutputCoder(org.apache.beam.sdk.coders.CoderRegistry arg0, org.apache.beam.sdk.coders.Coder<@UnknownKeyFor @NonNull @Initialized InputT> arg1) throws org.apache.beam.sdk.coders.CannotProvideCoderException- Specified by:
getDefaultOutputCoderin interfaceorg.apache.beam.sdk.transforms.CombineFnBase.GlobalCombineFn<InputT extends java.lang.Object,AccumT extends java.lang.Object,OutputT extends java.lang.Object>- Throws:
org.apache.beam.sdk.coders.CannotProvideCoderException
-
getIncompatibleGlobalWindowErrorMessage
public java.lang.String getIncompatibleGlobalWindowErrorMessage()
- Specified by:
getIncompatibleGlobalWindowErrorMessagein interfaceorg.apache.beam.sdk.transforms.CombineFnBase.GlobalCombineFn<InputT extends java.lang.Object,AccumT extends java.lang.Object,OutputT extends java.lang.Object>
-
getInputTVariable
public java.lang.reflect.TypeVariable<?> getInputTVariable()
-
getAccumTVariable
public java.lang.reflect.TypeVariable<?> getAccumTVariable()
-
getOutputTVariable
public java.lang.reflect.TypeVariable<?> getOutputTVariable()
-
-