Google Cloud Dataflow SDK for Java, version 1.9.1
Class CombineFns.ComposedKeyedCombineFn<DataT,K>
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.transforms.Combine.KeyedCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
-
- com.google.cloud.dataflow.sdk.transforms.CombineFns.ComposedKeyedCombineFn<DataT,K>
-
- All Implemented Interfaces:
- CombineFnBase.PerKeyCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>, HasDisplayData, Serializable
- Enclosing class:
- CombineFns
public static class CombineFns.ComposedKeyedCombineFn<DataT,K> extends Combine.KeyedCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
A composedCombine.KeyedCombineFn
that applies multipleKeyedCombineFns
.For each
Combine.KeyedCombineFn
it extracts inputs fromDataT
with theextractInputFn
and combines them, and then it outputs each combined value with aTupleTag
to aCombineFns.CoCombineResult
.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Object[]
addInput(K key, Object[] accumulator, DataT value)
Adds the given input value to the given accumulator, returning the new accumulator value.Object[]
compact(K key, Object[] accumulator)
Returns an accumulator that represents the same logical value as the input accumulator, but may have a more compact representation.Object[]
createAccumulator(K key)
Returns a new, mutable accumulator value representing the accumulation of zero input values.CombineFns.CoCombineResult
extractOutput(K key, Object[] accumulator)
Returns the output value that is the result of combining all the input values represented by the given accumulator.TypeVariable<?>
getAccumTVariable()
Returns theTypeVariable
ofAccumT
.Coder<Object[]>
getAccumulatorCoder(CoderRegistry registry, Coder<K> keyCoder, Coder<DataT> dataCoder)
Returns theCoder
to use for accumulatorAccumT
values, or null if it is not able to be inferred.Coder<OutputT>
getDefaultOutputCoder(CoderRegistry registry, Coder<K> keyCoder, Coder<InputT> inputCoder)
Returns theCoder
to use by default for outputOutputT
values, or null if it is not able to be inferred.TypeVariable<?>
getInputTVariable()
Returns theTypeVariable
ofInputT
.TypeVariable<?>
getKTypeVariable()
Returns theTypeVariable
ofK
.TypeVariable<?>
getOutputTVariable()
Returns theTypeVariable
ofOutputT
.Object[]
mergeAccumulators(K key, Iterable<Object[]> accumulators)
Returns an accumulator representing the accumulation of all the input values accumulated in the merging accumulators.void
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.<InputT,OutputT>
CombineFns.ComposedKeyedCombineFn<DataT,K>with(SimpleFunction<DataT,InputT> extractInputFn, Combine.CombineFn<InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFn
with an additionalCombine.CombineFn
.<InputT,OutputT>
CombineFns.ComposedKeyedCombineFn<DataT,K>with(SimpleFunction<DataT,InputT> extractInputFn, Combine.KeyedCombineFn<K,InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFn
with an additionalCombine.KeyedCombineFn
.<InputT,OutputT>
CombineFns.ComposedKeyedCombineFnWithContext<DataT,K>with(SimpleFunction<DataT,InputT> extractInputFn, CombineWithContext.CombineFnWithContext<InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFnWithContext
with an additionalCombineWithContext.CombineFnWithContext
.<InputT,OutputT>
CombineFns.ComposedKeyedCombineFnWithContext<DataT,K>with(SimpleFunction<DataT,InputT> extractInputFn, CombineWithContext.KeyedCombineFnWithContext<K,InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFnWithContext
with an additionalCombineWithContext.KeyedCombineFnWithContext
.-
Methods inherited from class com.google.cloud.dataflow.sdk.transforms.Combine.KeyedCombineFn
apply, forKey
-
-
-
-
Method Detail
-
with
public <InputT,OutputT> CombineFns.ComposedKeyedCombineFn<DataT,K> with(SimpleFunction<DataT,InputT> extractInputFn, Combine.KeyedCombineFn<K,InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFn
with an additionalCombine.KeyedCombineFn
.
-
with
public <InputT,OutputT> CombineFns.ComposedKeyedCombineFnWithContext<DataT,K> with(SimpleFunction<DataT,InputT> extractInputFn, CombineWithContext.KeyedCombineFnWithContext<K,InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFnWithContext
with an additionalCombineWithContext.KeyedCombineFnWithContext
.
-
with
public <InputT,OutputT> CombineFns.ComposedKeyedCombineFn<DataT,K> with(SimpleFunction<DataT,InputT> extractInputFn, Combine.CombineFn<InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFn
with an additionalCombine.CombineFn
.
-
with
public <InputT,OutputT> CombineFns.ComposedKeyedCombineFnWithContext<DataT,K> with(SimpleFunction<DataT,InputT> extractInputFn, CombineWithContext.CombineFnWithContext<InputT,?,OutputT> keyedCombineFn, TupleTag<OutputT> outputTag)
Returns aCombineFns.ComposedKeyedCombineFnWithContext
with an additionalCombineWithContext.CombineFnWithContext
.
-
createAccumulator
public Object[] createAccumulator(K key)
Description copied from class:Combine.KeyedCombineFn
Returns a new, mutable accumulator value representing the accumulation of zero input values.- Specified by:
createAccumulator
in classCombine.KeyedCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
- Parameters:
key
- the key that all the accumulated values using the accumulator are associated with
-
addInput
public Object[] addInput(K key, Object[] accumulator, DataT value)
Description copied from class:Combine.KeyedCombineFn
Adds the given input value to the given accumulator, returning the new accumulator value.For efficiency, the input accumulator may be modified and returned.
- Specified by:
addInput
in classCombine.KeyedCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
- Parameters:
key
- the key that all the accumulated values using the accumulator are associated with
-
mergeAccumulators
public Object[] mergeAccumulators(K key, Iterable<Object[]> accumulators)
Description copied from class:Combine.KeyedCombineFn
Returns an accumulator representing the accumulation of all the input values accumulated in the merging accumulators.May modify any of the argument accumulators. May return a fresh accumulator, or may return one of the (modified) argument accumulators.
- Specified by:
mergeAccumulators
in classCombine.KeyedCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
- Parameters:
key
- the key that all the accumulators are associated with
-
extractOutput
public CombineFns.CoCombineResult extractOutput(K key, Object[] accumulator)
Description copied from class:Combine.KeyedCombineFn
Returns the output value that is the result of combining all the input values represented by the given accumulator.- Specified by:
extractOutput
in classCombine.KeyedCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
- Parameters:
key
- the key that all the accumulated values using the accumulator are associated with
-
compact
public Object[] compact(K key, Object[] accumulator)
Description copied from class:Combine.KeyedCombineFn
Returns an accumulator that represents the same logical value as the input accumulator, but may have a more compact representation.For most CombineFns this would be a no-op, but should be overridden by CombineFns that (for example) buffer up elements and combine them in batches.
For efficiency, the input accumulator may be modified and returned.
By default returns the original accumulator.
- Overrides:
compact
in classCombine.KeyedCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
-
getAccumulatorCoder
public Coder<Object[]> getAccumulatorCoder(CoderRegistry registry, Coder<K> keyCoder, Coder<DataT> dataCoder) throws CannotProvideCoderException
Description copied from interface:CombineFnBase.PerKeyCombineFn
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 forK
keys and inputInputT
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.PerKeyCombineFn<K,DataT,Object[],CombineFns.CoCombineResult>
- Throws:
CannotProvideCoderException
-
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
-
getDefaultOutputCoder
public Coder<OutputT> getDefaultOutputCoder(CoderRegistry registry, Coder<K> keyCoder, Coder<InputT> inputCoder) throws CannotProvideCoderException
Description copied from interface:CombineFnBase.PerKeyCombineFn
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 forK
keys and inputInputT
values and the enclosingPipeline
'sCoderRegistry
to try to infer the Coder forOutputT
values.- Specified by:
getDefaultOutputCoder
in interfaceCombineFnBase.PerKeyCombineFn<K,InputT,AccumT,OutputT>
- Throws:
CannotProvideCoderException
-
getKTypeVariable
public TypeVariable<?> getKTypeVariable()
Returns theTypeVariable
ofK
.
-
getInputTVariable
public TypeVariable<?> getInputTVariable()
Returns theTypeVariable
ofInputT
.
-
getAccumTVariable
public TypeVariable<?> getAccumTVariable()
Returns theTypeVariable
ofAccumT
.
-
getOutputTVariable
public TypeVariable<?> getOutputTVariable()
Returns theTypeVariable
ofOutputT
.
-
-