You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2013/03/13 23:19:19 UTC

[2/2] git commit: Fix range and within case

Updated Branches:
  refs/heads/master cb3132a39 -> b48d0f09a


Fix range and within case


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/b48d0f09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/b48d0f09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/b48d0f09

Branch: refs/heads/master
Commit: b48d0f09a0f53054b02e9cf000fe619a6f14d728
Parents: b41f51f
Author: Timothy Chen <tn...@gmail.com>
Authored: Tue Mar 5 00:16:38 2013 -0800
Committer: Timothy Chen <tn...@gmail.com>
Committed: Tue Mar 5 00:16:38 2013 -0800

----------------------------------------------------------------------
 .../apache/drill/exec/ref/rops/WindowFrameROP.java |   10 ++--
 .../drill/exec/ref/rops/WindowFrameROPTest.java    |   41 ++++++++++++++-
 2 files changed, 45 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b48d0f09/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/WindowFrameROP.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/WindowFrameROP.java b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/WindowFrameROP.java
index a8417d1..4ed1642 100644
--- a/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/WindowFrameROP.java
+++ b/sandbox/prototype/exec/ref/src/main/java/org/apache/drill/exec/ref/rops/WindowFrameROP.java
@@ -253,13 +253,13 @@ public class WindowFrameROP extends SingleInputROPBase<WindowFrame> {
                     curWindow.removeHoldersBeforeIndex(curWindow.getWindowId());
                 }
                 curWindow = new Window(start, end, curWindow);
-                if (curWindow.isCrossedWithinBoundary(recordPointer)) {
-                    holderBuffer.add(new WindowObjectHolder(recordPointer, 0, index, schemaChanged));
-                    return;
-                }
             }
 
-            curWindow.addRecord(recordPointer, index, schemaChanged);
+            if (curWindow.isCrossedWithinBoundary(recordPointer)) {
+                holderBuffer.add(new WindowObjectHolder(recordPointer, 0, index, schemaChanged));
+            } else {
+                curWindow.addRecord(recordPointer, index, schemaChanged);
+            }
         }
 
         public boolean hasMoreWindows(int curIndex) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b48d0f09/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/WindowFrameROPTest.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/WindowFrameROPTest.java b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/WindowFrameROPTest.java
index d041174..b0aeb99 100644
--- a/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/WindowFrameROPTest.java
+++ b/sandbox/prototype/exec/ref/src/test/java/org/apache/drill/exec/ref/rops/WindowFrameROPTest.java
@@ -129,7 +129,7 @@ public class WindowFrameROPTest {
     }
 
     @Test
-    public void windowShouldNotCrossWithinAndRange() throws IOException {
+    public void windowShouldNotCrossWithins() throws IOException {
         String withinInput = "" +
                 "{id: 0, v: 0}" +
                 "{id: 1, v: 0}" +
@@ -156,6 +156,45 @@ public class WindowFrameROPTest {
         verifyWindowOrder(windows, out);
     }
 
+    @Test
+    public void windowShouldNotCrossWithinAndRange() throws IOException {
+        String withinInput = "" +
+                "{id: 0, v: 0}" +
+                "{id: 1, v: 0}" +
+                "{id: 2, v: 0}" +
+                "{id: 3, v: 0}" +
+                "{id: 4, v: 1}" +
+                "{id: 5, v: 1}" +
+                "{id: 6, v: 2}";
+        WindowFrameROP rop = new WindowFrameROP(new WindowFrame(new FieldReference("test.v"), null, -1L, 3L));
+        RecordIterator incoming = TestUtils.jsonToRecordIterator("test", withinInput);
+        rop.setInput(incoming);
+        RecordIterator out = rop.getOutput();
+
+        List<WindowObj> windows = Lists.newArrayList(
+                new WindowObj(0, 0, 0),
+                new WindowObj(0, 1, 1),
+                new WindowObj(0, 2, -1),
+                new WindowObj(0, 3, 2),
+                new WindowObj(1, 0, 0),
+                new WindowObj(1, 1, 1),
+                new WindowObj(1, 2, -1),
+                new WindowObj(1, 3, 2),
+                new WindowObj(2, 1, 0),
+                new WindowObj(2, 2, 1),
+                new WindowObj(2, 3, -1),
+                new WindowObj(3, 2, 0),
+                new WindowObj(3, 3, 1),
+                new WindowObj(4, 4, 0),
+                new WindowObj(4, 5, 1),
+                new WindowObj(5, 4, 0),
+                new WindowObj(5, 5, 1),
+                new WindowObj(6, 6, 0)
+        );
+
+        verifyWindowOrder(windows, out);
+    }
+
     private void verifyWindowOrder(List<WindowObj> expectedIds, RecordIterator out) {
         verifyWindowOrder(expectedIds, out, new SchemaPath("ref.segment"), new SchemaPath("ref.position"));
     }