com.google.cloud.dataflow.sdk.transforms

## Class CombineFns.ComposedCombineFnWithContext<DataT>

- java.lang.Object
- - com.google.cloud.dataflow.sdk.transforms.CombineWithContext.CombineFnWithContext<DataT,Object[],CombineFns.CoCombineResult>
  - - com.google.cloud.dataflow.sdk.transforms.CombineFns.ComposedCombineFnWithContext<DataT>

All Implemented Interfaces:
  CombineFnBase.GlobalCombineFn<DataT,Object[],CombineFns.CoCombineResult>, CombineWithContext.RequiresContextInternal, HasDisplayData, Serializable

Enclosing class:
  CombineFns

    public static class CombineFns.ComposedCombineFnWithContext<DataT>
    extends CombineWithContext.CombineFnWithContext<DataT,Object[],CombineFns.CoCombineResult>

A composed `CombineWithContext.CombineFnWithContext` that applies multiple `CombineFnWithContexts`.

For each `CombineWithContext.CombineFnWithContext` it extracts inputs from `DataT` with the `extractInputFn` and combines them, and then it outputs each combined value with a `TupleTag` to a `CombineFns.CoCombineResult`.

See Also:
  Serialized Form

### Method Summary

All Methods Instance Methods Concrete Methods
`Object[]` `addInput(Object[] accumulator, DataT value, CombineWithContext.Context c)` Adds the given input value to the given accumulator, returning the new accumulator value.
`Object[]` `compact(Object[] accumulator, CombineWithContext.Context c)` Returns an accumulator that represents the same logical value as the input accumulator, but may have a more compact representation.
`Object[]` `createAccumulator(CombineWithContext.Context c)` Returns a new, mutable accumulator value, representing the accumulation of zero input values.
`CombineFns.CoCombineResult` `extractOutput(Object[] accumulator, CombineWithContext.Context c)` Returns the output value that is the result of combining all the input values represented by the given accumulator.
`TypeVariable<?>` `getAccumTVariable()` Returns the `TypeVariable` of `AccumT`.
`Coder<Object[]>` `getAccumulatorCoder(CoderRegistry registry, Coder<DataT> dataCoder)` Returns the `Coder` to use for accumulator `AccumT` values, or null if it is not able to be inferred.
`Coder<OutputT>` `getDefaultOutputCoder(CoderRegistry registry, Coder<InputT> inputCoder)` Returns the `Coder` to use by default for output `OutputT` values, or null if it is not able to be inferred.
`String` `getIncompatibleGlobalWindowErrorMessage()` Returns the error message for not supported default values in Combine.globally().
`TypeVariable<?>` `getInputTVariable()` Returns the `TypeVariable` of `InputT`.
`TypeVariable<?>` `getOutputTVariable()` Returns the `TypeVariable` of `OutputT`.
`Object[]` `mergeAccumulators(Iterable<Object[]> accumulators, CombineWithContext.Context c)` 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.ComposedCombineFnWithContext<DataT>` `with(SimpleFunction<DataT,InputT> extractInputFn, CombineFnBase.GlobalCombineFn<InputT,?,OutputT> globalCombineFn, TupleTag<OutputT> outputTag)` Returns a `CombineFns.ComposedCombineFnWithContext` with an additional `CombineFnBase.GlobalCombineFn`.

### Methods inherited from class com.google.cloud.dataflow.sdk.transforms.CombineWithContext.CombineFnWithContext

`asKeyedFn, defaultValue`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### with

    public <InputT,OutputT> CombineFns.ComposedCombineFnWithContext<DataT> with(SimpleFunction<DataT,InputT> extractInputFn,
                                                                                CombineFnBase.GlobalCombineFn<InputT,?,OutputT> globalCombineFn,
                                                                                TupleTag<OutputT> outputTag)

Returns a `CombineFns.ComposedCombineFnWithContext` with an additional `CombineFnBase.GlobalCombineFn`.

#### createAccumulator

    public Object[] createAccumulator(CombineWithContext.Context c)

Description copied from class: `CombineWithContext.CombineFnWithContext`
Returns a new, mutable accumulator value, representing the accumulation of zero input values.

It is equivalent to `Combine.CombineFn.createAccumulator()`, but it has additional access to `CombineWithContext.Context`.

Specified by:
  `createAccumulator` in class `CombineWithContext.CombineFnWithContext<DataT,Object[],CombineFns.CoCombineResult>`

#### addInput

    public Object[] addInput(Object[] accumulator,
                             DataT value,
                             CombineWithContext.Context c)

Description copied from class: `CombineWithContext.CombineFnWithContext`
Adds the given input value to the given accumulator, returning the new accumulator value.

It is equivalent to `Combine.CombineFn.addInput(AccumT, InputT)`, but it has additional access to `CombineWithContext.Context`.

Specified by:
  `addInput` in class `CombineWithContext.CombineFnWithContext<DataT,Object[],CombineFns.CoCombineResult>`

#### mergeAccumulators

    public Object[] mergeAccumulators(Iterable<Object[]> accumulators,
                                      CombineWithContext.Context c)

Description copied from class: `CombineWithContext.CombineFnWithContext`
Returns an accumulator representing the accumulation of all the input values accumulated in the merging accumulators.

It is equivalent to `Combine.CombineFn.mergeAccumulators(java.lang.Iterable<AccumT>)`, but it has additional access to `CombineWithContext.Context`.

Specified by:
  `mergeAccumulators` in class `CombineWithContext.CombineFnWithContext<DataT,Object[],CombineFns.CoCombineResult>`

#### extractOutput

    public CombineFns.CoCombineResult extractOutput(Object[] accumulator,
                                                    CombineWithContext.Context c)

Description copied from class: `CombineWithContext.CombineFnWithContext`
Returns the output value that is the result of combining all the input values represented by the given accumulator.

It is equivalent to `Combine.CombineFn.extractOutput(AccumT)`, but it has additional access to `CombineWithContext.Context`.

Specified by:
  `extractOutput` in class `CombineWithContext.CombineFnWithContext<DataT,Object[],CombineFns.CoCombineResult>`

#### compact

    public Object[] compact(Object[] accumulator,
                            CombineWithContext.Context c)

Description copied from class: `CombineWithContext.CombineFnWithContext`
Returns an accumulator that represents the same logical value as the input accumulator, but may have a more compact representation.

It is equivalent to `Combine.CombineFn.compact(AccumT)`, but it has additional access to `CombineWithContext.Context`.

Overrides:
  `compact` in class `CombineWithContext.CombineFnWithContext<DataT,Object[],CombineFns.CoCombineResult>`

#### getAccumulatorCoder

    public Coder<Object[]> getAccumulatorCoder(CoderRegistry registry,
                                               Coder<DataT> dataCoder)
                                        throws CannotProvideCoderException

Description copied from interface: `CombineFnBase.GlobalCombineFn`
Returns the `Coder` to use for accumulator `AccumT` values, or null if it is not able to be inferred.

By default, uses the knowledge of the `Coder` being used for `InputT` values and the enclosing `Pipeline`'s `CoderRegistry` to try to infer the Coder for `AccumT` 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 interface `CombineFnBase.GlobalCombineFn<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 via `DisplayData.from(HasDisplayData)`. Implementations may call `super.populateDisplayData(builder)` in order to register display data in the current namespace, but should otherwise use `subcomponent.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 interface `HasDisplayData`
Parameters:
  `builder` - The builder to populate with display data.
See Also:
  `HasDisplayData`

#### getDefaultOutputCoder

    public Coder<OutputT> getDefaultOutputCoder(CoderRegistry registry,
                                                Coder<InputT> inputCoder)
                                         throws CannotProvideCoderException

Description copied from interface: `CombineFnBase.GlobalCombineFn`
Returns the `Coder` to use by default for output `OutputT` values, or null if it is not able to be inferred.

By default, uses the knowledge of the `Coder` being used for input `InputT` values and the enclosing `Pipeline`'s `CoderRegistry` to try to infer the Coder for `OutputT` values.

Specified by:
  `getDefaultOutputCoder` in interface `CombineFnBase.GlobalCombineFn<InputT,AccumT,OutputT>`
Throws:
  `CannotProvideCoderException`

#### getIncompatibleGlobalWindowErrorMessage

    public String getIncompatibleGlobalWindowErrorMessage()

Description copied from interface: `CombineFnBase.GlobalCombineFn`
Returns the error message for not supported default values in Combine.globally().

Specified by:
  `getIncompatibleGlobalWindowErrorMessage` in interface `CombineFnBase.GlobalCombineFn<InputT,AccumT,OutputT>`

#### getInputTVariable

    public TypeVariable<?> getInputTVariable()

Returns the `TypeVariable` of `InputT`.

#### getAccumTVariable

    public TypeVariable<?> getAccumTVariable()

Returns the `TypeVariable` of `AccumT`.

#### getOutputTVariable

    public TypeVariable<?> getOutputTVariable()

Returns the `TypeVariable` of `OutputT`.