Browse Source

Merge pull request #8151 from ghalliday/issue14826

HPCC-14826 Remove calls to removeAssociation and addGroup()

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 năm trước cách đây
mục cha
commit
525435f0e5
4 tập tin đã thay đổi với 24 bổ sung52 xóa
  1. 5 13
      ecl/hqlcpp/hqlcppds.cpp
  2. 0 1
      ecl/hqlcpp/hqlcset.cpp
  3. 18 37
      ecl/hqlcpp/hqlhtcpp.cpp
  4. 1 1
      ecl/hqlcpp/hqlsource.cpp

+ 5 - 13
ecl/hqlcpp/hqlcppds.cpp

@@ -2132,9 +2132,7 @@ void HqlCppTranslator::doBuildDataset(BuildCtx & ctx, IHqlExpression * expr, CHq
             Owned<BoundRow> rowBuilder = createRowBuilder(ctx, tempRow);
             Owned<IReferenceSelector> createdRef = createReferenceSelector(rowBuilder);
 
-            BuildCtx subctx(ctx);
-            subctx.addGroup();
-            doBuildRowAssignAggregate(subctx, createdRef, expr);
+            doBuildRowAssignAggregate(ctx, createdRef, expr);
             finalizeTempRow(ctx, tempRow, rowBuilder);
 
             convertBoundRowToDataset(ctx, tgt, tempRow, format);
@@ -3332,13 +3330,11 @@ void HqlCppTranslator::buildDatasetAssignJoin(BuildCtx & ctx, IHqlCppDatasetBuil
 
 void HqlCppTranslator::buildDatasetAssignAggregate(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr)
 {
-    BuildCtx subctx(ctx);
-    subctx.addGroup();
-    BoundRow * targetRow = target->buildCreateRow(subctx);
+    BoundRow * targetRow = target->buildCreateRow(ctx);
 
-    Owned<IReferenceSelector> targetRef = buildActiveRow(subctx, targetRow->querySelector());
-    doBuildRowAssignAggregate(subctx, targetRef, expr);
-    target->finishRow(subctx, targetRow);
+    Owned<IReferenceSelector> targetRef = buildActiveRow(ctx, targetRow->querySelector());
+    doBuildRowAssignAggregate(ctx, targetRef, expr);
+    target->finishRow(ctx, targetRow);
 }
 
 void HqlCppTranslator::buildDatasetAssignChoose(BuildCtx & ctx, IHqlCppDatasetBuilder * target, IHqlExpression * expr)
@@ -3577,7 +3573,6 @@ void HqlCppTranslator::buildDatasetAssign(BuildCtx & ctx, IHqlCppDatasetBuilder
     if (isRowAssign)
     {
         bool done = false;
-        subctx.addGroup();
 
         //Some code primarily here to improve the generated code for productions inside parse statements for text parsing.
         //see if we can replace a memcpy of the child record with a link...
@@ -4390,8 +4385,6 @@ void HqlCppTranslator::doBuildRowAssignSerializeRow(BuildCtx & ctx, IReferenceSe
         //MORE: This doesn't associated the returned size with the target if assigned to a child field.
         //very unusual code, so not too concerned.
     }
-
-    subctx.removeAssociation(selfCursor);
 }
         
 void HqlCppTranslator::doBuildRowAssignUserTable(BuildCtx & ctx, IReferenceSelector * target, IHqlExpression * expr)
@@ -4797,7 +4790,6 @@ IHqlExpression * HqlCppTranslator::ensureIteratedRowIsLive(BuildCtx & initctx, B
     }
 
     BuildCtx childctx(iterctx);
-    childctx.addGroup();
 
     Owned<BoundRow> tempRow = declareTempRow(childctx, childctx, rowExpr);
     Owned<BoundRow> rowBuilder = createRowBuilder(childctx, tempRow);

+ 0 - 1
ecl/hqlcpp/hqlcset.cpp

@@ -1684,7 +1684,6 @@ void DatasetBuilderBase::doFinishRow(BuildCtx & ctx, BoundRow * selfCursor, IHql
     s.append(instanceName).append(".finalizeRow(");
     translator.generateExprCpp(s, boundSize.expr).append(");");
     ctx.addQuoted(s);
-    ctx.removeAssociation(selfCursor);
 }
 
 //---------------------------------------------------------------------------

+ 18 - 37
ecl/hqlcpp/hqlhtcpp.cpp

@@ -7107,7 +7107,6 @@ void HqlCppTranslator::finishSelf(BuildCtx & ctx, BoundRow * self, BoundRow * ta
         OwnedHqlExpr sizeofTarget = createSizeof(target->querySelector());
         ctx.associateExpr(sizeofTarget, bound);
     }
-    ctx.removeAssociation(self);
 }
 
 
@@ -12615,48 +12614,30 @@ void HqlCppTranslator::buildProcessTransformFunction(BuildCtx & ctx, IHqlExpress
 
     LinkedHqlExpr skipReturnValue = queryZero();
     associateSkipReturnMarker(funcctx, skipReturnValue, NULL);
-    if (!recordTypesMatch(dataset, right))
-    {
-        //self won't clash, so can generate efficient code.
-        //Perform cse on both transforms
-        OwnedHqlExpr comma = createComma(LINK(transformRow), LINK(transformRight));
-        comma.setown(spotScalarCSE(comma, NULL, queryOptions().spotCseInIfDatasetConditions));
-        if (comma->getOperator() == no_alias_scope)
-            comma.set(comma->queryChild(0));
 
-        HqlExprArray unwound;
-        comma->unwindList(unwound, no_comma);
-        unsigned max = unwound.ordinality();
+    //Perform cse on both transforms
+    OwnedHqlExpr comma = createComma(LINK(transformRow), LINK(transformRight));
+    comma.setown(spotScalarCSE(comma, NULL, queryOptions().spotCseInIfDatasetConditions));
+    if (comma->getOperator() == no_alias_scope)
+        comma.set(comma->queryChild(0));
 
-        BoundRow * selfCursor = bindSelf(funcctx, dataset, "crSelf");
-        BoundRow * selfRowCursor = bindSelf(funcctx, right, "crSelfRight");
+    HqlExprArray unwound;
+    comma->unwindList(unwound, no_comma);
+    unsigned max = unwound.ordinality();
 
-        for (unsigned i=0; i<max-2; i++)
-            buildStmt(funcctx, &unwound.item(i));
+    BoundRow * selfCursor = bindSelf(funcctx, dataset, "crSelf");
+    BoundRow * selfRowCursor = bindSelf(funcctx, right, "crSelfRight");
 
-        IHqlExpression * newTransformRow = queryExpandAliasScope(funcctx, &unwound.item(max-2));
-        IHqlExpression * newTransformRight = queryExpandAliasScope(funcctx, &unwound.item(max-1));
-        assertex(newTransformRow->getOperator() == no_transform && newTransformRight->getOperator() == no_transform);
+    for (unsigned i=0; i<max-2; i++)
+        buildStmt(funcctx, &unwound.item(i));
 
-        doTransform(funcctx, newTransformRow, selfCursor);
-        doTransform(funcctx, newTransformRight, selfRowCursor);
-        buildReturnRecordSize(funcctx, selfCursor);
-    }
-    else
-    {
-        BuildCtx ctx1(funcctx);
+    IHqlExpression * newTransformRow = queryExpandAliasScope(funcctx, &unwound.item(max-2));
+    IHqlExpression * newTransformRight = queryExpandAliasScope(funcctx, &unwound.item(max-1));
+    assertex(newTransformRow->getOperator() == no_transform && newTransformRight->getOperator() == no_transform);
 
-        ctx1.addGroup();
-        BoundRow * selfRowCursor = bindSelf(ctx1, right, "crSelfRight");
-        doTransform(ctx1, transformRight, selfRowCursor);
-
-        BuildCtx ctx2(funcctx);
-        ctx2.addGroup();
-        BoundRow * selfCursor = bindSelf(ctx2, dataset, "crSelf");
-        doTransform(ctx2, transformRow, selfCursor);
-
-        buildReturnRecordSize(ctx2, selfCursor);
-    }
+    doTransform(funcctx, newTransformRow, selfCursor);
+    doTransform(funcctx, newTransformRight, selfRowCursor);
+    buildReturnRecordSize(funcctx, selfCursor);
 }
 
 

+ 1 - 1
ecl/hqlcpp/hqlsource.cpp

@@ -1231,7 +1231,7 @@ void SourceBuilder::buildTargetCursor(Shared<BoundRow> & tempRow, Shared<BoundRo
 void SourceBuilder::associateTargetCursor(BuildCtx & subctx, BuildCtx & ctx, BoundRow * tempRow, BoundRow * rowBuilder, IHqlExpression * expr)
 {
     //First remove the old active dataset
-    //NOT sure this is needed
+    //This is not strictly necessary, but it avoids the redundant row being serialized to any child queries
     BoundRow * oldCursor = translator.resolveSelectorDataset(ctx, expr->queryChild(0));
     ctx.removeAssociation(oldCursor);