소스 검색

Merge pull request #2775 from richardkchapman/rollup-2390

gh-2390 ROLLUP should compare previous input row

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 13 년 전
부모
커밋
b1c55f49eb
5개의 변경된 파일32개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 1
      ecl/hthor/hthor.cpp
  2. 1 0
      ecl/hthor/hthor.ipp
  3. 6 1
      roxie/ccd/ccdserver.cpp
  4. 12 0
      testing/ecl/key/rollup1.xml
  5. 8 0
      testing/ecl/rollup1.ecl

+ 5 - 1
ecl/hthor/hthor.cpp

@@ -2223,11 +2223,13 @@ void CHThorRollupActivity::ready()
 {
     CHThorSimpleActivityBase::ready();
     left.setown(input->nextInGroup());
+    prev.set(left);
 }
 
 void CHThorRollupActivity::done()
 {
     left.clear();
+    prev.clear();
     right.clear();
     CHThorSimpleActivityBase::done();
 }
@@ -2237,7 +2239,7 @@ const void *CHThorRollupActivity::nextInGroup()
     loop
     {
         right.setown(input->nextInGroup());
-        if(!left || !right || !helper.matches(left,right))
+        if(!prev || !right || !helper.matches(prev,right))
         {
             const void * ret = left.getClear();
             if(ret)
@@ -2245,6 +2247,7 @@ const void *CHThorRollupActivity::nextInGroup()
                 processed++;
             }
             left.setown(right.getClear());
+            prev.set(left);
             return ret;
         }
         try
@@ -2255,6 +2258,7 @@ const void *CHThorRollupActivity::nextInGroup()
             {
                 left.setown(rowBuilder.finalizeRowClear(outSize));
             }
+            prev.set(right);
         }
         catch(IException * e)
         {

+ 1 - 0
ecl/hthor/hthor.ipp

@@ -436,6 +436,7 @@ class CHThorRollupActivity : public CHThorSimpleActivityBase
 {
     IHThorRollupArg &helper;
     OwnedConstHThorRow left;
+    OwnedConstHThorRow prev;
     OwnedConstHThorRow right;
 public:
     CHThorRollupActivity(IAgentContext &agent, unsigned _activityId, unsigned _subgraphId, IHThorRollupArg &_arg, ThorActivityKind _kind);

+ 6 - 1
roxie/ccd/ccdserver.cpp

@@ -6866,6 +6866,7 @@ class CRoxieServerRollupActivity : public CRoxieServerActivity
 {
     IHThorRollupArg &helper;
     OwnedConstRoxieRow left;
+    OwnedConstRoxieRow prev;
     OwnedConstRoxieRow right;
     bool readFirstRow;
 
@@ -6889,6 +6890,7 @@ public:
     virtual void reset()    
     {
         left.clear();
+        prev.clear();
         right.clear();
         CRoxieServerActivity::reset();
     }
@@ -6901,18 +6903,20 @@ public:
         if (!readFirstRow)
         {
             left.setown(input->nextInGroup());
+            prev.set(left);
             readFirstRow = true;
         }
 
         loop
         {
             right.setown(input->nextInGroup());
-            if(!left || !right || !helper.matches(left,right))
+            if(!prev || !right || !helper.matches(prev,right))
             {
                 const void * ret = left.getClear();
                 if(ret)
                     processed++;
                 left.setown(right.getClear());
+                prev.set(left);
                 return ret;
             }
             try
@@ -6921,6 +6925,7 @@ public:
                 unsigned outSize = helper.transform(rowBuilder, left, right);
                 if (outSize)
                     left.setown(rowBuilder.finalizeRowClear(outSize));
+                prev.set(right);
             }
             catch(IException * E)
             {

+ 12 - 0
testing/ecl/key/rollup1.xml

@@ -0,0 +1,12 @@
+<Dataset name='Result 1'>
+ <Row><r>2</r></Row>
+ <Row><r>2</r></Row>
+ <Row><r>3</r></Row>
+ <Row><r>4</r></Row>
+ <Row><r>8</r></Row>
+ <Row><r>9</r></Row>
+</Dataset>
+<Dataset name='Result 2'>
+ <Row><r>3</r></Row>
+ <Row><r>9</r></Row>
+</Dataset>

+ 8 - 0
testing/ecl/rollup1.ecl

@@ -0,0 +1,8 @@
+d := dataset([{1},{1},{2},{3},{4},{8},{9}], { unsigned r; });
+
+d t(d L, d r) := transform
+SELF.r := IF (L.r=3,SKIP,L.r + 1);
+END;
+
+rollup(d, t(LEFT, RIGHT), LEFT.r = RIGHT.r);
+rollup(d, t(LEFT, RIGHT), LEFT.r >= RIGHT.r-1, LOCAL);