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

The first program in ObjectReuseITCase has the wrong expected result, and it succeeds

    XMLWordPrintableJSON

Details

    Description

      The first program in ObjectReuseITCase has the following input:
      a,1
      a,2
      a,3
      a,4
      a,50
      There is a groupBy on field 0, and then a reduce, so the result should be 1+2+3+4+50 = 60. But the hardcoded expected result is 100, and running the Flink program also produces this.

      The problem is caused my mismatched assumptions between ReduceCombineDriver.sortAndCombine and the ReduceFunction in the test about object reuse rules of ReduceFunctions:

      ReduceCombineDriver.sortAndCombine has the following comment:
      "The user function is expected to return the first input as the result."
      While the ReduceFunction in the test is modifying and returning the second input. (And the second program in the test also has the same problem.)

      I can't find the assumption that is stated in the comment in any documentation. For example, the javadoc of ReduceFunction should make the user aware of this. Or, alternatively, the code of the driver should be modified to not make this assumption. I'm not sure which solution is better.

      Attachments

        Activity

          People

            greghogan Greg Hogan
            ggevay Gábor Gévay
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: