瀏覽代碼

HPCC-21569 Implicitly create KEYED filters for disk read activities

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 6 年之前
父節點
當前提交
efdcfca30a
共有 1 個文件被更改,包括 47 次插入28 次删除
  1. 47 28
      ecl/hqlcpp/hqlsource.cpp

+ 47 - 28
ecl/hqlcpp/hqlsource.cpp

@@ -2976,46 +2976,65 @@ void DiskReadBuilderBase::extractMonitors(IHqlExpression * ds, SharedHqlExpr & u
     //KEYED filters can only currently be implemented for binary files - not csv, xml or pipe....
     if (queryTableMode(tableExpr) == no_flat)
     {
-        OwnedHqlExpr implicitFilter;
-        ForEachItemIn(i, conds)
+        if (translator.queryOptions().implicitKeyedDiskFilter)
         {
-            IHqlExpression * filter = &conds.item(i);
-            if (isSourceInvariant(ds, filter))                  // more actually isSourceInvariant.
-                extendConditionOwn(globalGuard, no_and, LINK(filter));
-            else
+            HqlExprArray newconds;
+            ForEachItemIn(i, conds)
             {
-                node_operator op = filter->getOperator();
-                switch (op)
+                IHqlExpression * filter = &conds.item(i);
+                if (isSourceInvariant(ds, filter))                  // more actually isSourceInvariant.
+                    extendConditionOwn(globalGuard, no_and, LINK(filter));
+                else
+                    newconds.append(OLINK(*filter));
+            }
+
+            OwnedHqlExpr extraFilter;
+            monitors.extractFilters(newconds, extraFilter);
+            appendFilter(unkeyedFilter, extraFilter);
+        }
+        else
+        {
+            OwnedHqlExpr implicitFilter;
+            ForEachItemIn(i, conds)
+            {
+                IHqlExpression * filter = &conds.item(i);
+                if (isSourceInvariant(ds, filter))                  // more actually isSourceInvariant.
+                    extendConditionOwn(globalGuard, no_and, LINK(filter));
+                else
                 {
-                case no_assertkeyed:
-                case no_assertwild:
+                    node_operator op = filter->getOperator();
+                    switch (op)
                     {
-                        //MORE: This needs to test that the fields are at fixed offsets, fixed length, and collatable.
-                        OwnedHqlExpr extraFilter;
-                        monitors.extractFilters(filter, extraFilter);
+                    case no_assertkeyed:
+                    case no_assertwild:
+                        {
+                            //MORE: This needs to test that the fields are at fixed offsets, fixed length, and collatable.
+                            OwnedHqlExpr extraFilter;
+                            monitors.extractFilters(filter, extraFilter);
 
-                        //NB: Even if it is keyed then (part of) the test condition might be duplicated.
-                        appendFilter(unkeyedFilter, extraFilter);
+                            //NB: Even if it is keyed then (part of) the test condition might be duplicated.
+                            appendFilter(unkeyedFilter, extraFilter);
+                            break;
+                        }
+                    default:
+                        // Add this condition to the catchall filter
+                        appendFilter(implicitFilter, filter);
                         break;
                     }
-                default:
-                    // Add this condition to the catchall filter
-                    appendFilter(implicitFilter, filter);
-                    break;
                 }
             }
-        }
 
-        if (implicitFilter)
-        {
-            if (translator.queryOptions().implicitKeyedDiskFilter && !monitors.isKeyed())
+            if (implicitFilter)
             {
-                OwnedHqlExpr extraFilter;
-                monitors.extractFilters(implicitFilter.get(), extraFilter);
-                appendFilter(unkeyedFilter, extraFilter);
+                if (translator.queryOptions().implicitKeyedDiskFilter && !monitors.isKeyed())
+                {
+                    OwnedHqlExpr extraFilter;
+                    monitors.extractFilters(implicitFilter.get(), extraFilter);
+                    appendFilter(unkeyedFilter, extraFilter);
+                }
+                else
+                    appendFilter(unkeyedFilter, implicitFilter);
             }
-            else
-                appendFilter(unkeyedFilter, implicitFilter);
         }
     }
     else