Browse Source

HPCC-15990 Remove a base class to speed up row creation

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 9 năm trước cách đây
mục cha
commit
64fd68aa2e

+ 1 - 1
common/thorhelper/thorcommon.cpp

@@ -1212,7 +1212,7 @@ public:
             eos = true;
             return NULL;
         }
-        RtlDynamicRowBuilder rowBuilder(allocator);
+        RtlDynamicRowBuilder rowBuilder(*allocator);
         size_t size = deserializer->deserialize(rowBuilder,source);
         if (grouped && !eos) {
             byte b;

+ 8 - 8
common/thorhelper/thorcommon.ipp

@@ -168,39 +168,39 @@ protected:
 
 //------------------------------------------------------------------------------------------------
 
-//This class is only ever used to apply a delta to a self pointer, it is never finalized
+//This class is only ever used to apply a delta to a self pointer, it is never finalized, and the builder must stay alive.
 class THORHELPER_API CPrefixedRowBuilder : implements RtlRowBuilderBase
 {
 public:
-    inline CPrefixedRowBuilder(size32_t _offset, ARowBuilder & _builder) : offset(_offset), builder(&_builder)
+    inline CPrefixedRowBuilder(size32_t _offset, ARowBuilder & _builder) : offset(_offset), builder(_builder)
     { 
-        self = builder->getSelf()+offset;
+        self = builder.getSelf()+offset;
     }
 
     virtual byte * ensureCapacity(size32_t required, const char * fieldName)
     {
-        self = builder->ensureCapacity(offset+required, fieldName) + offset;
+        self = builder.ensureCapacity(offset+required, fieldName) + offset;
         return getSelf();
     }
 
     virtual byte * createSelf()
     {
-        self = builder->getSelf()+offset;
+        self = builder.getSelf()+offset;
         return self;
     }
 
     virtual IEngineRowAllocator *queryAllocator() const
     {
-        return builder->queryAllocator();
+        return builder.queryAllocator();
     }
 protected:
     size32_t offset;
-    Linked<ARowBuilder> builder;
+    ARowBuilder & builder;
 };
 
 //------------------------------------------------------------------------------------------------
 
-class AggregateRowBuilder : public RtlDynamicRowBuilder
+class AggregateRowBuilder : public RtlDynamicRowBuilder, public CInterface
 {
 public:
     AggregateRowBuilder(IEngineRowAllocator *_rowAllocator, unsigned _elementHash)

+ 1 - 1
roxie/ccd/ccdserver.cpp

@@ -5818,7 +5818,7 @@ class CRoxieServerStrandedInlineTableActivity : public CRoxieServerStrandedActiv
             //Return rows while the current section is active
             while (curRow < maxRows)
             {
-                RtlDynamicRowBuilder rowBuilder(rowAllocator);
+                RtlDynamicRowBuilder rowBuilder(*rowAllocator);
                 unsigned outSize = helper.getRow(rowBuilder, curRow++);
                 if (outSize)
                 {

+ 2 - 2
rtl/eclrtl/rtlds.cpp

@@ -503,7 +503,7 @@ void appendRowsToRowset(size32_t & targetCount, byte * * & targetRowset, IEngine
 
 const void * rtlCloneRow(IEngineRowAllocator * rowAllocator, size32_t len, const void * row)
 {
-    RtlDynamicRowBuilder builder(rowAllocator);
+    RtlDynamicRowBuilder builder(*rowAllocator);
 
     byte * self = builder.ensureCapacity(len, NULL);
     memcpy(self, row, len);
@@ -1244,7 +1244,7 @@ extern ECLRTL_API byte * rtlDeserializeRow(IEngineRowAllocator * rowAllocator, I
     Owned<ISerialStream> stream = createMemorySerialStream(src, unknownSourceLength);
     CThorStreamDeserializerSource source(stream);
 
-    RtlDynamicRowBuilder rowBuilder(rowAllocator);
+    RtlDynamicRowBuilder rowBuilder(*rowAllocator);
     size32_t rowSize = deserializer->deserialize(rowBuilder, source);
     return static_cast<byte *>(const_cast<void *>(rowBuilder.finalizeRowClear(rowSize)));
 }

+ 5 - 3
rtl/eclrtl/rtlds_imp.hpp

@@ -209,11 +209,9 @@ protected:
 
 void ECLRTL_API rtlReportFieldOverflow(unsigned size, unsigned max, const RtlFieldInfo * field);
 
-class ECLRTL_API RtlRowBuilderBase : implements ARowBuilder, public RtlCInterface
+class ECLRTL_API RtlRowBuilderBase : implements ARowBuilder
 {
 public:
-    RTLIMPLEMENT_IINTERFACE
-
     virtual void reportMissingRow() const;
 };
 
@@ -230,6 +228,10 @@ public:
             maxLength = 0;
         }
     }
+    inline RtlDynamicRowBuilder(IEngineRowAllocator & _rowAllocator) : rowAllocator(&_rowAllocator)
+    {
+        create();
+    }
     virtual IEngineRowAllocator *queryAllocator() const
     {
         return rowAllocator;

+ 1 - 1
rtl/eclrtl/rtlfield.cpp

@@ -1142,7 +1142,7 @@ size32_t RtlDatasetTypeInfo::build(ARowBuilder &builder, size32_t offset, const
         RtlFieldStrInfo dummyField("<nested row>", NULL, child);
         while (source.processNextRow(field))
         {
-            RtlDynamicRowBuilder childBuilder(childAllocator);
+            RtlDynamicRowBuilder childBuilder(*childAllocator);
             size32_t childLen = child->build(childBuilder, 0, &dummyField, source);
             childRows = childAllocator->appendRowOwn(childRows, ++numRows, (void *) childBuilder.finalizeRowClear(childLen));
         }

+ 3 - 3
rtl/include/eclhelper.hpp

@@ -39,8 +39,8 @@ if the supplied pointer was not from the roxiemem heap. Usually an OwnedRoxieStr
 
 //Should be incremented whenever the virtuals in the context or a helper are changed, so
 //that a work unit can't be rerun.  Try as hard as possible to retain compatibility.
-#define ACTIVITY_INTERFACE_VERSION      160
-#define MIN_ACTIVITY_INTERFACE_VERSION  160             //minimum value that is compatible with current interface - without using selectInterface
+#define ACTIVITY_INTERFACE_VERSION      161
+#define MIN_ACTIVITY_INTERFACE_VERSION  161             //minimum value that is compatible with current interface - without using selectInterface
 
 typedef unsigned char byte;
 
@@ -105,7 +105,7 @@ interface INaryCompareEq
 
 interface IEngineRowAllocator;
 
-interface IRowBuilder : public IInterface
+interface IRowBuilder
 {
     virtual byte * ensureCapacity(size32_t required, const char * fieldName) = 0;
 protected: