소스 검색

HPCC-15025 Remove duplicate rows from the parent extract

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 9 년 전
부모
커밋
57682bf6ec
1개의 변경된 파일21개의 추가작업 그리고 10개의 파일을 삭제
  1. 21 10
      ecl/hqlcpp/hqlinline.cpp

+ 21 - 10
ecl/hqlcpp/hqlinline.cpp

@@ -1312,6 +1312,8 @@ void ParentExtract::gatherActiveRows(BuildCtx & ctx)
     if (localisation == GraphCoLocal || localisation == GraphCoNonLocal)
     {
         OwnedHqlExpr colocal = createQuoted("colocal", makeVoidType());
+        HqlExprCopyArray matchBound;
+        HqlExprCopyArray matchAlias;
         ForEachItemInRev(i, activeRows)
         {
             BoundRow & cur = activeRows.item(i);
@@ -1337,16 +1339,25 @@ void ParentExtract::gatherActiveRows(BuildCtx & ctx)
             }
             else if (serialization)
             {
-                //A cursor active in the current scope => add it to the extract, and create an alias in the
-                //child contexts.
-                //Need to add these fields to the extract record, and do the assignments at the point of call
-                Owned<ITypeInfo> fieldType = makeRowReferenceType(cur.queryDataset());
-                if (hasOutOfLineModifier(bound->queryType()))
-                    fieldType.setown(makeAttributeModifier(LINK(fieldType), getLinkCountedAttr()));
-                OwnedHqlExpr expandedAlias = serialization->createField(NULL, fieldType);
-                OwnedHqlExpr castSource = createValue(no_implicitcast, LINK(fieldType), LINK(bound));
-                OwnedHqlExpr translated = createTranslated(castSource);
-                translator.buildAssign(ctx, expandedAlias, translated);
+                unsigned match = matchBound.find(*bound);
+                OwnedHqlExpr expandedAlias;
+                if (match == NotFound)
+                {
+                    //A cursor active in the current scope => add it to the extract, and create an alias in the
+                    //child contexts.
+                    //Need to add these fields to the extract record, and do the assignments at the point of call
+                    Owned<ITypeInfo> fieldType = makeRowReferenceType(cur.queryDataset());
+                    if (hasOutOfLineModifier(bound->queryType()))
+                        fieldType.setown(makeAttributeModifier(LINK(fieldType), getLinkCountedAttr()));
+                    expandedAlias.setown(serialization->createField(NULL, fieldType));
+                    OwnedHqlExpr castSource = createValue(no_implicitcast, LINK(fieldType), LINK(bound));
+                    OwnedHqlExpr translated = createTranslated(castSource);
+                    translator.buildAssign(ctx, expandedAlias, translated);
+                    matchBound.append(*bound);
+                    matchAlias.append(*expandedAlias);
+                }
+                else
+                    expandedAlias.set(&matchAlias.item(match));
 
                 newRow = new BoundAliasRow(cur, NULL, expandedAlias);
                 newRow->setInherited(true);