浏览代码

HPCC-10456 Codegen support for streamed datasets from embedded languages

All non C++ dataset embedded functions must return streamed datasets

An explicitly link counted dataset type should ensure the field is
linkcounted

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 年之前
父节点
当前提交
c59ba76695
共有 2 个文件被更改,包括 15 次插入2 次删除
  1. 11 0
      ecl/hql/hqlgram2.cpp
  2. 4 2
      testing/ecl/streame.ecl

+ 11 - 0
ecl/hql/hqlgram2.cpp

@@ -862,6 +862,13 @@ IHqlExpression * HqlGram::processEmbedBody(const attribute & errpos, IHqlExpress
     if (!type)
         type.setown(makeVoidType());
 
+    //All non C++ dataset embedded functions must return streamed datasets
+    if (language && isDatasetType(type))
+    {
+        type.setown(setStreamedAttr(type, true));
+        type.setown(setLinkCountedAttr(type, true));
+    }
+
     IHqlExpression * record = queryOriginalRecord(type);
     OwnedHqlExpr result;
     if (record)
@@ -2414,6 +2421,10 @@ void HqlGram::addDatasetField(const attribute &errpos, IIdAtom * name, ITypeInfo
             attrs = createComma(LINK(childAttrs->queryChild(0)), attrs);
     }
 
+    //An explicitly link counted dataset type should ensure the field is linkcounted
+    if (isLinkedRowset(fieldType) && !queryAttributeInList(_linkCounted_Atom, attrs))
+        attrs = createComma(attrs, getLinkCountedAttr());
+
     Owned<ITypeInfo> dsType = LINK(fieldType);
     if (value)
     {

+ 4 - 2
testing/ecl/streame.ecl

@@ -23,7 +23,7 @@ END;
 namesRecord := RECORD
     STRING name1;
     STRING10 name2;
-    DATASET(childrec) childnames;
+    LINKCOUNTED DATASET(childrec) childnames;
     DICTIONARY(childrec) childdict;
     unsigned1 val1;
     integer1   val2;
@@ -44,10 +44,12 @@ _linkcounted_ dataset(namesRecord) linkedNames(string prefix) := EMBED(Python)
   return ["Gavin","John","Bart"]
 ENDEMBED;
 
-STREAMED dataset(namesRecord) streamedNames(data d, utf8 u) := EMBED(Python)
+dataset(namesRecord) streamedNames(data d, utf8 u) := EMBED(Python)
   return [  \
      ("Gavin", "Halliday", [("a", 1)], 250, -1,  U'là',  U'là',  U'là', 1234566, d, False, {"1","2"}), \
      ("John", "Smith", [], 250, -1,  U'là',  U'là',  u, 1234566, d, True, [])]
 ENDEMBED;
 
+//output(linkedNames('AA'));
+//output(blockedNames('AA'));
 output(streamedNames(d'AA', u'là'));