Browse Source

Merge pull request #2144 from jakesmith/gh-1988

gh-1988 - exit non-grouped existaggregate early

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 13 năm trước cách đây
mục cha
commit
3410b4381e

+ 9 - 5
thorlcr/activities/aggregate/thaggregateslave.cpp

@@ -182,11 +182,15 @@ public:
         {
             hadElement = true;
             sz = helper->processFirst(resultcr, next);
-            loop {
-                next.setown(input->ungroupedNextRow());
-                if (!next)
-                    break;
-                sz = helper->processNext(resultcr, next);
+            if (container.getKind() != TAKexistsaggregate)
+            {
+                while (!abortSoon)
+                {
+                    next.setown(input->ungroupedNextRow());
+                    if (!next)
+                        break;
+                    sz = helper->processNext(resultcr, next);
+                }
             }
         }
         doStopInput();

+ 11 - 8
thorlcr/activities/aggregate/thgroupaggregateslave.cpp

@@ -22,7 +22,7 @@ class GroupAggregateSlaveActivity : public CSlaveActivity, public CThorDataLink
 {
 
 private:
-    bool eof;
+    bool eof, ungroupedExistsAggregate;
     IHThorAggregateArg * helper;
     IThorDataLink *input;
 
@@ -47,9 +47,8 @@ public:
         eof = false;
         input=inputs.item(0);
         startInput(input);
+        ungroupedExistsAggregate = (container.getKind() == TAKexistsaggregate) && !input->isGrouped();
         dataLinkStart("GROUPAGGREGATE", container.queryId());
-        if (!input->isGrouped())
-            ActPrintLog("WARNING: non-grouped data as input to GroupAggregate");
     }
 
     void stop()
@@ -69,12 +68,16 @@ public:
         if (row)
         {
             sz = helper->processFirst(out, row);
-            loop
+            // NB: if ungrouped existsAggregate, no need to look at rest of input
+            if (!ungroupedExistsAggregate)
             {
-                row.setown(input->nextRow());
-                if (!row)
-                    break;
-                sz = helper->processNext(out, row);
+                while (!abortSoon)
+                {
+                    row.setown(input->nextRow());
+                    if (!row)
+                        break;
+                    sz = helper->processNext(out, row);
+                }
             }
             if (!input->isGrouped())
                 eof = true;