Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-11510

Add the MultiFieldSumAggregator to support KeyedStream.sum(int[] positionToSums )

    XMLWordPrintableJSON

Details

    Description

      The goal is to implement a KeyedStream API to sum with multi field.

      The example code with like:

      StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
      DataStream<Tuple3<Long, Long, Integer>> src = env.fromCollection(Arrays.asList(
      new Tuple3<>(1L, 2L, 2),
      new Tuple3<>(1L, 3L, 3),
      new Tuple3<>(1L, 4L, 4),
      new Tuple3<>(2L, 2L, 2),
      new Tuple3<>(2L, 3L, 3),
      new Tuple3<>(2L, 4L, 4)
      ));
      
      src.keyBy(0)
      .sum(new int[] {1, 2}) // right now only sum(1) or sum("f0") is supported
      .print();
      env.execute();
      
       
      

      and the output is expected to be:

      1> (1,2,2)
      1> (2,2,2)
      1> (1,5,5)
      1> (2,5,5)
      1> (1,9,9)
      1> (2,9,9)
      

      Attachments

        Activity

          People

            wangpeibin wangpeibin
            wangpeibin wangpeibin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m