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

    https://github.com/apache/drill/pull/222#discussion_r43586273
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/DefaultFrameTemplate.java
 ---
    @@ -287,6 +318,36 @@ private int countPeers(final int start) {
       }
     
       /**
    +   * Counts how many rows are peer with the first row of the current 
frame. This is called when we don't require all
    +   * batches of current partition to be processed at once.<br>
    +   * Assumes the end of the frame has indeed been found, because of this 
it doesn't use partition.remaining to check
    +   * the end of current partition but rather isSamePartition()
    +   * @param start first row of current frame
    +   * @return number of peer rows
    +   */
    +  private int countPeersPartialPartition(final int start) {
    +    // current frame always starts from first batch
    +    final VectorAccessible first = getCurrent();
    +    int length = 0;
    +
    +    // count all rows that are in the same frame of starting row
    +    // keep increasing length until we find first non peer row we reach 
the very
    +    // last batch
    +    for (WindowDataBatch batch : batches) {
    +      final int recordCount = batch.getRecordCount();
    +
    +      // for every remaining row in the partition, count it if it's a peer 
row
    +      for (int row = (batch == first) ? start : 0; row < recordCount; 
row++, length++) {
    +        if (!isSamePartition(start, first, row, batch) || !isPeer(start, 
first, row, batch)) {
    --- End diff --
    
    I think isPeer() could also check whether two rows are in the same 
partition...because the notion of peer is only valid within a partition.  This 
will simplify the generated code a bit. 


---
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