浏览代码

HPCC-10457 Streamed dataset support for Python

Fix memory leak, and cleaner fix for missing tuple issue

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 11 年之前
父节点
当前提交
ec05934f27
共有 2 个文件被更改,包括 13 次插入16 次删除
  1. 11 14
      plugins/pyembed/pyembed.cpp
  2. 2 2
      rtl/eclrtl/rtlfield.cpp

+ 11 - 14
plugins/pyembed/pyembed.cpp

@@ -665,22 +665,19 @@ public:
         // Expect to see a tuple here, or possibly (if the ECL record has a single field), an arbitrary scalar object
         // If it's a tuple, we push it onto our stack as the active object
         iterStack.append(iter.getClear());
-        if (PyTuple_Check(elem))
+        if (!PyTuple_Check(elem))
         {
-            iter.setown(PyObject_GetIter(elem));
-            nextField();
-        }
-        else if (countFields(field->type->queryFields())==1)
-        {
-            // Python doesn't seem to support the concept of a tuple containing a single element.
-            // If we are expecting a single field in our row, then the 'tuple' layer will be missing
-            // NOTE - we don't call nextField here, and iter is set to null by the getClear() above.
-            // elem will be valid for one field only
-        }
-        else
-        {
-            typeError("tuple", field);
+            if (countFields(field->type->queryFields())==1)
+            {
+                // Python doesn't seem to support the concept of a tuple containing a single element.
+                // If we are expecting a single field in our row, then the 'tuple' layer will be missing
+                elem.setown(PyTuple_Pack(1, elem.get()));
+            }
+            else
+                typeError("tuple", field);
         }
+        iter.setown(PyObject_GetIter(elem));
+        nextField();
     }
     virtual bool processNextRow(const RtlFieldInfo * field)
     {

+ 2 - 2
rtl/eclrtl/rtlfield.cpp

@@ -1097,7 +1097,7 @@ size32_t RtlDatasetTypeInfo::build(ARowBuilder &builder, size32_t offset, const
         size32_t sizeInBytes = sizeof(size32_t) + sizeof(void *);
         builder.ensureCapacity(offset+sizeInBytes, field->name->str());
         size32_t numRows = 0;
-        IEngineRowAllocator *childAllocator = builder.queryAllocator()->createChildRowAllocator(child);
+        Owned<IEngineRowAllocator> childAllocator = builder.queryAllocator()->createChildRowAllocator(child);
         byte **childRows = NULL;
         RtlFieldStrInfo dummyField("<nested row>", NULL, child);
         while (source.processNextRow(field))
@@ -1223,7 +1223,7 @@ size32_t RtlDictionaryTypeInfo::build(ARowBuilder &builder, size32_t offset, con
         // a 32-bit record count, and a pointer to an hash table with record pointers
         size32_t sizeInBytes = sizeof(size32_t) + sizeof(void *);
         builder.ensureCapacity(offset+sizeInBytes, field->name->str());
-        IEngineRowAllocator *childAllocator = builder.queryAllocator()->createChildRowAllocator(child);
+        Owned<IEngineRowAllocator> childAllocator = builder.queryAllocator()->createChildRowAllocator(child);
         RtlLinkedDictionaryBuilder dictBuilder(childAllocator, hashInfo);
         RtlFieldStrInfo dummyField("<nested row>", NULL, child);
         while (source.processNextRow(field))