Github user babokim commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/474#discussion_r27389087
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/ExternalSortExec.java
 ---
    @@ -168,7 +168,7 @@ private Path sortAndStoreChunk(int chunkId, List<Tuple> 
tupleBlock)
         int rowNum = tupleBlock.size();
     
         long sortStart = System.currentTimeMillis();
    -    Collections.sort(tupleBlock, getComparator());
    +    Iterable<Tuple> sorted = getSorter(tupleBlock).sort();
    --- End diff --
    
    appender should use this "sorted" instead of tupleBlock in the following 
for statement.
    ```
    for (Tuple t : sorted) {  // tupleBlock -> sorted
          appender.addTuple(t);
    }
    ```
    I was wonder how the code passed TestExternalSortExec. I found two reasons.
    First, the above logic is not covered in current test condition. "numTuple" 
in TestExternalSortExec code should be changed to "3000000" to cover more use 
case.
    Second, ProjectionExec is parent node in the test program.
    ProjectionExec reuses the tuple object when next() is called. So 
TestExternalSortExec code should be changed as the following:
    ```
    while ((tuple = exec.next()) != null) {
      ...
      //preVal = curVal;
      preVal = new VTuple(curVal);
      cnt++;
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to