Sfoglia il codice sorgente

HPCC-14700 Remove unused code for expanding field lists at generate time

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 8 anni fa
parent
commit
aa138c7fee

+ 4 - 4
ecl/hqlcpp/hqlcpp.ipp

@@ -1042,11 +1042,11 @@ public:
            { return bindTableCursor(ctx, dataset, bound, no_none, NULL); }
 
 
-    IHqlExpression * getRtlFieldKey(IHqlExpression * expr, IHqlExpression * ownerRecord, bool expandNested);
-    unsigned buildRtlField(StringBuffer & instanceName, IHqlExpression * field, IHqlExpression * rowRecord, bool expandNested);
+    IHqlExpression * getRtlFieldKey(IHqlExpression * expr, IHqlExpression * ownerRecord);
+    unsigned buildRtlField(StringBuffer & instanceName, IHqlExpression * field, IHqlExpression * rowRecord);
     unsigned buildRtlType(StringBuffer & instanceName, ITypeInfo * type, unsigned typeFlags);
-    unsigned buildRtlRecordFields(StringBuffer & instanceName, IHqlExpression * record, IHqlExpression * rowRecord, bool expandNested);
-    unsigned expandRtlRecordFields(StringBuffer & fieldListText, IHqlExpression * record, IHqlExpression * rowRecord, bool expandNested);
+    unsigned buildRtlRecordFields(StringBuffer & instanceName, IHqlExpression * record, IHqlExpression * rowRecord);
+    unsigned expandRtlRecordFields(StringBuffer & fieldListText, IHqlExpression * record, IHqlExpression * rowRecord);
     unsigned buildRtlIfBlockField(StringBuffer & instanceName, IHqlExpression * ifblock, IHqlExpression * rowRecord);
 
     void buildMetaInfo(MetaInstance & instance);

+ 20 - 69
ecl/hqlcpp/hqlhtcpp.cpp

@@ -3508,7 +3508,7 @@ bool HqlCppTranslator::buildMetaPrefetcherClass(BuildCtx & ctx, IHqlExpression *
     return ok;
 }
 
-IHqlExpression * HqlCppTranslator::getRtlFieldKey(IHqlExpression * expr, IHqlExpression * rowRecord, bool expandNested)
+IHqlExpression * HqlCppTranslator::getRtlFieldKey(IHqlExpression * expr, IHqlExpression * rowRecord)
 {
     /*
     Most field information is context independent - which make life much easier, there are a few exceptions though:
@@ -3549,10 +3549,6 @@ IHqlExpression * HqlCppTranslator::getRtlFieldKey(IHqlExpression * expr, IHqlExp
             //actually too strict - some alien data types are not context dependent.
             contextDependent = true;
             break;
-        case type_row:
-            contextDependent = true;
-            extra.setown(createConstant(expandNested));
-            break;
         }
         break;
     case no_ifblock:
@@ -3570,9 +3566,9 @@ bool checkXpathIsNonScalar(const char *xpath)
     return (strpbrk(xpath, "/?*[]<>")!=NULL); //anything other than a single tag/attr name cannot name a scalar field
 }
 
-unsigned HqlCppTranslator::buildRtlField(StringBuffer & instanceName, IHqlExpression * field, IHqlExpression * rowRecord, bool expandNested)
+unsigned HqlCppTranslator::buildRtlField(StringBuffer & instanceName, IHqlExpression * field, IHqlExpression * rowRecord)
 {
-    OwnedHqlExpr fieldKey = getRtlFieldKey(field, rowRecord, expandNested);
+    OwnedHqlExpr fieldKey = getRtlFieldKey(field, rowRecord);
 
     BuildCtx declarectx(*code, declareAtom);
     HqlExprAssociation * match = declarectx.queryMatchExpr(fieldKey);
@@ -3673,41 +3669,17 @@ unsigned HqlCppTranslator::buildRtlField(StringBuffer & instanceName, IHqlExpres
         }
 
         StringBuffer definition;
-        if (field->isDatarow() && expandNested)
-        {
-            BuildCtx fieldctx(declarectx);
-
-            OwnedHqlExpr marker = createAttribute(rowAtom);
-            if (!declarectx.queryMatchExpr(marker))
-            {
-                fieldctx.setNextPriority(TypeInfoPrio);
-                fieldctx.addQuotedLiteral("const RtlBeginRowTypeInfo tybRow;");
-                fieldctx.setNextPriority(TypeInfoPrio);
-                fieldctx.addQuotedLiteral("const RtlEndRowTypeInfo tyeRow;");
-                declarectx.associateExpr(marker, marker);
-            }
-
-            definition.clear().append("const RtlFieldStrInfo ").append(name).append("b(\"").append(lowerName).append("\",").append(xpathCppText).append(",&tybRow);");
-            fieldctx.setNextPriority(TypeInfoPrio);
-            fieldctx.addQuoted(definition);
-            definition.clear().append("const RtlFieldStrInfo ").append(name).append("e(\"").append(lowerName).append("\",").append(xpathCppText).append(",&tyeRow);");
-            fieldctx.setNextPriority(TypeInfoPrio);
-            fieldctx.addQuoted(definition);
-        }
-        else
-        {
-            StringBuffer typeName;
-            typeFlags = buildRtlType(typeName, fieldType, typeFlags); //benefit to adding other flags to generated code as well?
+        StringBuffer typeName;
+        typeFlags = buildRtlType(typeName, fieldType, typeFlags); //benefit to adding other flags to generated code as well?
 
-            definition.append("const RtlFieldStrInfo ").append(name).append("(\"").append(lowerName).append("\",").append(xpathCppText).append(",&").append(typeName);
-            if (defaultInitializer.length())
-                definition.append(',').append(defaultInitializer);
-            definition.append(");");
+        definition.append("const RtlFieldStrInfo ").append(name).append("(\"").append(lowerName).append("\",").append(xpathCppText).append(",&").append(typeName);
+        if (defaultInitializer.length())
+            definition.append(',').append(defaultInitializer);
+        definition.append(");");
 
-            BuildCtx fieldctx(declarectx);
-            fieldctx.setNextPriority(TypeInfoPrio);
-            fieldctx.addQuoted(definition);
-        }
+        BuildCtx fieldctx(declarectx);
+        fieldctx.setNextPriority(TypeInfoPrio);
+        fieldctx.addQuoted(definition);
 
         name.insert(0, "&");
     }
@@ -3729,7 +3701,7 @@ unsigned HqlCppTranslator::buildRtlIfBlockField(StringBuffer & instanceName, IHq
     {
         unsigned length = 0;
         StringBuffer childTypeName;
-        unsigned childType = buildRtlRecordFields(childTypeName, ifblock->queryChild(1), rowRecord, false);
+        unsigned childType = buildRtlRecordFields(childTypeName, ifblock->queryChild(1), rowRecord);
         fieldType |= (childType & (RFTMcontainsunknown|RFTMinvalidxml|RFTMhasxmlattr));
 
         StringBuffer className;
@@ -3773,7 +3745,7 @@ unsigned HqlCppTranslator::buildRtlIfBlockField(StringBuffer & instanceName, IHq
 }
 
 
-unsigned HqlCppTranslator::expandRtlRecordFields(StringBuffer & fieldListText, IHqlExpression * record, IHqlExpression * rowRecord, bool expandNested)
+unsigned HqlCppTranslator::expandRtlRecordFields(StringBuffer & fieldListText, IHqlExpression * record, IHqlExpression * rowRecord)
 {
     unsigned fieldType = 0;
     ForEachChild(i, record)
@@ -3783,33 +3755,12 @@ unsigned HqlCppTranslator::expandRtlRecordFields(StringBuffer & fieldListText, I
         switch (cur->getOperator())
         {
         case no_field:
-            if (cur->isDatarow() && expandNested)
-            {
-                StringBuffer baseName;
-                childType = buildRtlField(baseName, cur, rowRecord, expandNested);
-                fieldListText.append(baseName).append("b,");
-                childType = expandRtlRecordFields(fieldListText, cur->queryRecord(), cur->queryRecord(), true);
-                fieldListText.append(baseName).append("e,");
-            }
-            else
-            {
-                childType = buildRtlField(fieldListText, cur, rowRecord, expandNested);
-                fieldListText.append(",");
-            }
-            break;
         case no_ifblock:
-            if (expandNested)
-            {
-                childType = expandRtlRecordFields(fieldListText, cur->queryChild(1), cur->queryRecord(), true);
-            }
-            else
-            {
-                childType = buildRtlField(fieldListText, cur, rowRecord, expandNested);
-                fieldListText.append(",");
-            }
+            childType = buildRtlField(fieldListText, cur, rowRecord);
+            fieldListText.append(",");
             break;
         case no_record:
-            childType = expandRtlRecordFields(fieldListText, cur, rowRecord, expandNested);
+            childType = expandRtlRecordFields(fieldListText, cur, rowRecord);
             break;
         }
         fieldType |= (childType & (RFTMcontainsunknown|RFTMinvalidxml|RFTMhasxmlattr));
@@ -3818,10 +3769,10 @@ unsigned HqlCppTranslator::expandRtlRecordFields(StringBuffer & fieldListText, I
 }
 
 
-unsigned HqlCppTranslator::buildRtlRecordFields(StringBuffer & instanceName, IHqlExpression * record, IHqlExpression * rowRecord, bool expandNested)
+unsigned HqlCppTranslator::buildRtlRecordFields(StringBuffer & instanceName, IHqlExpression * record, IHqlExpression * rowRecord)
 {
     StringBuffer fieldListText;
-    unsigned fieldFlags = expandRtlRecordFields(fieldListText, record, rowRecord, expandNested);
+    unsigned fieldFlags = expandRtlRecordFields(fieldListText, record, rowRecord);
 
     StringBuffer name;
     name.append("tl").append(++nextTypeId);
@@ -3966,7 +3917,7 @@ unsigned HqlCppTranslator::buildRtlType(StringBuffer & instanceName, ITypeInfo *
             className.append("RtlRecordTypeInfo");
             arguments.append(",");
             StringBuffer fieldsInstance;
-            childType = buildRtlRecordFields(fieldsInstance, record, record, false);
+            childType = buildRtlRecordFields(fieldsInstance, record, record);
             arguments.append(fieldsInstance);
 
             //The following code could be used to generate an extra list of fields with nested records expanded out,

+ 0 - 79
rtl/eclrtl/rtlfield.cpp

@@ -1333,85 +1333,6 @@ __int64 RtlCompoundTypeInfo::getInt(const void * ptr) const
 
 //-------------------------------------------------------------------------------------------------------------------
 
-size32_t RtlBeginRowTypeInfo::size(const byte * self, const byte * selfrow) const
-{
-    return 0;
-}
-
-size32_t RtlBeginRowTypeInfo::process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const
-{
-    if (target.processBeginRow(field))
-    {
-        //Cannot process in quite the same way
-    }
-    return 0;
-}
-
-size32_t RtlBeginRowTypeInfo::toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const
-{
-    const char * xpath = queryXPath(field);
-    if (*xpath)
-        target.outputBeginNested(xpath, false);
-    return 0;
-}
-
-size32_t RtlBeginRowTypeInfo::build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const
-{
-    source.processBeginRow(field);
-    return offset;
-}
-
-void RtlBeginRowTypeInfo::getUtf8(size32_t & resultLen, char * & result, const void * ptr) const
-{
-    resultLen = 0;
-    result = nullptr;
-}
-
-__int64 RtlBeginRowTypeInfo::getInt(const void * ptr) const
-{
-    return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-
-size32_t RtlEndRowTypeInfo::size(const byte * self, const byte * selfrow) const
-{
-    return 0;
-}
-
-size32_t RtlEndRowTypeInfo::process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const
-{
-    target.processEndRow(field);
-    return 0;
-}
-
-size32_t RtlEndRowTypeInfo::toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const
-{
-    const char * xpath = queryXPath(field);
-    if (*xpath)
-        target.outputEndNested(xpath);
-    return 0;
-}
-
-size32_t RtlEndRowTypeInfo::build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const
-{
-    source.processEndRow(field);
-    return offset;
-}
-
-void RtlEndRowTypeInfo::getUtf8(size32_t & resultLen, char * & result, const void * ptr) const
-{
-    resultLen = 0;
-    result = nullptr;
-}
-
-__int64 RtlEndRowTypeInfo::getInt(const void * ptr) const
-{
-    return 0;
-}
-
-//-------------------------------------------------------------------------------------------------------------------
-
 size32_t RtlSetTypeInfo::getMinSize() const
 {
     return sizeof(bool) + sizeof(size32_t);

+ 0 - 26
rtl/eclrtl/rtlfield.hpp

@@ -260,32 +260,6 @@ struct ECLRTL_API RtlRecordTypeInfo : public RtlTypeInfoBase
     virtual const RtlFieldInfo * const * queryFields() const { return fields; }
 };
 
-struct ECLRTL_API RtlBeginRowTypeInfo : public RtlTypeInfoBase
-{
-    inline RtlBeginRowTypeInfo() : RtlTypeInfoBase(0,0) {}
-
-    virtual size32_t size(const byte * self, const byte * selfrow) const;
-    virtual size32_t build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const;
-    virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
-    virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
-
-    virtual void getUtf8(size32_t & resultLen, char * & result, const void * ptr) const;
-    virtual __int64 getInt(const void * ptr) const;
-};
-
-struct ECLRTL_API RtlEndRowTypeInfo : public RtlTypeInfoBase
-{
-    inline RtlEndRowTypeInfo() : RtlTypeInfoBase(0, 0) {}
-
-    virtual size32_t size(const byte * self, const byte * selfrow) const;
-    virtual size32_t build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const;
-    virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
-    virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
-
-    virtual void getUtf8(size32_t & resultLen, char * & result, const void * ptr) const;
-    virtual __int64 getInt(const void * ptr) const;
-};
-
 struct ECLRTL_API RtlCompoundTypeInfo : public RtlTypeInfoBase
 {
     inline RtlCompoundTypeInfo(unsigned _fieldType, unsigned _length, const RtlTypeInfo * _child) : RtlTypeInfoBase(_fieldType, _length), child(_child) {}

+ 3 - 0
testing/regress/ecl/project2.ecl

@@ -15,6 +15,9 @@
     limitations under the License.
 ############################################################################## */
 
+//Ensure that we test the case where the last field in a record is a variable length row.
+#option ('varFieldAccessorThreshold', 1);
+
 childRec := RECORD
     UNSIGNED id;
     STRING name;