You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Kenneth Knowles (JIRA)" <ji...@apache.org> on 2017/01/17 21:05:26 UTC

[jira] [Updated] (BEAM-1276) StateSpecs.combiningValue interface is very awkward to use

     [ https://issues.apache.org/jira/browse/BEAM-1276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kenneth Knowles updated BEAM-1276:
----------------------------------
    Description: 
Using StateSpecs.combiningValue with built in combiners is very verbose.  For example, to keep a running sum of ints:

{code}
@StateId("count")
private final StateSpec<Object, AccumulatorCombiningState<Integer, int[], Integer>> countSpec =
    StateSpecs.combiningValue(
          Sum.ofIntegers().getAccumulatorCoder(pipeline.getCoderRegistry(), VarIntCoder.of()), Sum.ofIntegers());
{code}

This involves getting a reference to the pipeline into the DoFn, guessing/finding the proper type parameters for Sum.ofIntegers(), and manually pulling the accumulator coder out.

For combiners like Sum.ofIntegers() that have a fixed accumulator, the combiningValue call should be able to deduce that.  Additionally, it would be nice to remove the type of the accumulator from the StateSpec object, since the user only needs the input and output types in their code.

  was:
Using StateSpecs.combiningValue with built in combiners is very verbose.  For example, to keep a running sum of ints:

@StateId("count")
private final StateSpec<Object, AccumulatorCombiningState<Integer, int[], Integer>> countSpec =
    StateSpecs.combiningValue(
          Sum.ofIntegers().getAccumulatorCoder(pipeline.getCoderRegistry(), VarIntCoder.of()), Sum.ofIntegers());

This involves getting a reference to the pipeline into the DoFn, guessing/finding the proper type parameters for Sum.ofIntegers(), and manually pulling the accumulator coder out.

For combiners like Sum.ofIntegers() that have a fixed accumulator, the combiningValue call should be able to deduce that.  Additionally, it would be nice to remove the type of the accumulator from the StateSpec object, since the user only needs the input and output types in their code.


> StateSpecs.combiningValue interface is very awkward to use
> ----------------------------------------------------------
>
>                 Key: BEAM-1276
>                 URL: https://issues.apache.org/jira/browse/BEAM-1276
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>            Reporter: Daniel Mills
>            Assignee: Kenneth Knowles
>            Priority: Minor
>
> Using StateSpecs.combiningValue with built in combiners is very verbose.  For example, to keep a running sum of ints:
> {code}
> @StateId("count")
> private final StateSpec<Object, AccumulatorCombiningState<Integer, int[], Integer>> countSpec =
>     StateSpecs.combiningValue(
>           Sum.ofIntegers().getAccumulatorCoder(pipeline.getCoderRegistry(), VarIntCoder.of()), Sum.ofIntegers());
> {code}
> This involves getting a reference to the pipeline into the DoFn, guessing/finding the proper type parameters for Sum.ofIntegers(), and manually pulling the accumulator coder out.
> For combiners like Sum.ofIntegers() that have a fixed accumulator, the combiningValue call should be able to deduce that.  Additionally, it would be nice to remove the type of the accumulator from the StateSpec object, since the user only needs the input and output types in their code.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)