Browse Source

Merge pull request #14146 from ghalliday/issue24702

HPCC-24702 Avoid excessive duplication of symbols for delayed references

Reviewed-By: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 4 years ago
parent
commit
99cfad869f
3 changed files with 43 additions and 1 deletions
  1. 1 1
      ecl/hql/hqlexpr.cpp
  2. 39 0
      ecl/hql/hqlutil.cpp
  3. 3 0
      ecl/hql/hqlutil.hpp

+ 1 - 1
ecl/hql/hqlexpr.cpp

@@ -9345,7 +9345,7 @@ IHqlExpression * createDelayedReference(node_operator op, IHqlExpression * modul
             ret.setown(createDelayedScope(ret.getClear()));
     }
 
-    return attr->cloneAllAnnotations(ret);
+    return attr->cloneAnnotation(ret);
 }
 
 //---------------------------------------------------------------------------------------------------------------------

+ 39 - 0
ecl/hql/hqlutil.cpp

@@ -712,6 +712,45 @@ IHqlExpression * queryStripCasts(IHqlExpression * expr)
     return expr;
 }
 
+unsigned queryNumAnnotations(IHqlExpression * expr)
+{
+    unsigned num = 0;
+    for (;;)
+    {
+        IHqlExpression * body = expr->queryBody(true);
+        if (expr == body)
+            return num;
+        expr = body;
+        num++;
+    }
+}
+
+void dumpSymbols(IHqlExpression * expr)
+{
+    for (;;)
+    {
+        IHqlExpression * body = expr->queryBody(true);
+        if (expr == body)
+            return;
+        if (body->getAnnotationKind() == annotate_symbol)
+            printf("%s\n", str(body->queryName()));
+        expr = body;
+    }
+}
+
+bool hasSymbol(IHqlExpression * expr, IAtom * search)
+{
+    for (;;)
+    {
+        IHqlExpression * body = expr->queryBody(true);
+        if (expr == body)
+            return false;
+        if (body->queryName() == search)
+            return true;
+        expr = body;
+    }
+}
+
 
 //---------------------------------------------------------------------------------------------
 

+ 3 - 0
ecl/hql/hqlutil.hpp

@@ -791,6 +791,9 @@ extern HQL_API bool userPreventsSort(IHqlExpression * noSortAttr, node_operator
 extern HQL_API IHqlExpression * queryTransformAssign(IHqlExpression * transform, IHqlExpression * searchField);
 extern HQL_API IHqlExpression * queryTransformAssignValue(IHqlExpression * transform, IHqlExpression * searchField);
 extern HQL_API IHqlExpression * convertSetToExpression(bool isAll, size32_t len, const void * ptr, ITypeInfo * setType);
+extern HQL_API unsigned queryNumAnnotations(IHqlExpression * expr);
+extern HQL_API void dumpSymbols(IHqlExpression * expr);
+extern HQL_API bool hasSymbol(IHqlExpression * expr, IAtom * search);
 
 struct FieldTypeInfoStruct;
 interface IRtlFieldTypeDeserializer;