Kaynağa Gözat

Merge pull request #9449 from ghalliday/issue16805

HPCC-16805 Start refactoring field and type formats

Reviewed-By: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 yıl önce
ebeveyn
işleme
21f5092a91

+ 1 - 1
common/thorhelper/roxiedebug.cpp

@@ -380,7 +380,7 @@ public:
                 if (canMatchAny(childType))
                     sawMatch = true;
             }
-            if (stricmp(str(fields[0]->name), searchFieldName)==0)
+            if (stricmp(fields[0]->name, searchFieldName)==0)
                 sawMatch = true;
             fields++;
         }

+ 1 - 1
common/thorhelper/thorfile.cpp

@@ -22,7 +22,7 @@
 #include "eclhelper.hpp"
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlds_imp.hpp"
 
 namespace thorfile {

+ 3 - 1
ecl/hql/CMakeLists.txt

@@ -35,6 +35,7 @@ set (   SRCS
         hqlerror.cpp
         hqlesp.cpp
         hqlexpr.cpp
+        hqlfield.cpp
         hqlfold.cpp
         hqlgram2.cpp
         hqlmanifest.cpp
@@ -69,6 +70,7 @@ set (   SRCS
         hqldesc.hpp
         hqlesp.hpp
         hqlexpr.hpp
+        hqlfield.hpp
         hqlfold.hpp
         hqlgram.hpp
         hqlmeta.hpp
@@ -99,7 +101,7 @@ include_directories (
          ./../../system/hrpc 
          ./../../common/thorhelper 
          ./../../rtl/eclrtl 
-         ./../../rtl/include 
+         ./../../rtl/include
          ./../eclagent 
          ./../../system/include 
          ./../../common/workunit

+ 25 - 0
ecl/hql/hqlfield.cpp

@@ -0,0 +1,25 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+#include "jliball.hpp"
+#include "hql.hpp"
+#include "eclrtl.hpp"
+
+#include "platform.h"
+#include "jlib.hpp"
+#include "hqlexpr.hpp"
+#include "hqlfield.hpp"
+

+ 23 - 0
ecl/hql/hqlfield.hpp

@@ -0,0 +1,23 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2016 HPCC Systems®.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+#ifndef __HQLFIELD_HPP_
+#define __HQLFIELD_HPP_
+
+#include "hqlexpr.hpp"
+#include "rtldynfield.hpp"
+
+#endif

+ 1 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -60,7 +60,7 @@
 //The following are include to ensure they call compile...
 #include "eclhelper.hpp"
 #include "eclrtl_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlds_imp.hpp"
 #include "eclhelper_base.hpp"
 

+ 2 - 2
plugins/Rembed/Rembed.cpp

@@ -61,7 +61,7 @@
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "nbcd.hpp"
 
 static const char * compatibleVersions[] =
@@ -277,7 +277,7 @@ public:
 protected:
     void addField(const RtlFieldInfo * field)
     {
-        namevec.push_back(field->name->queryStr());
+        namevec.push_back(field->name);
     }
 };
 

+ 5 - 5
plugins/cassandra/cassandraembed.cpp

@@ -25,7 +25,7 @@
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlembed.hpp"
 #include "roxiemem.hpp"
 #include "nbcd.hpp"
@@ -591,7 +591,7 @@ static void typeError(const char *expected, const CassValue *value, const RtlFie
 {
     VStringBuffer msg("cassandra: type mismatch - %s expected", expected);
     if (field)
-        msg.appendf(" for field %s", str(field->name));
+        msg.appendf(" for field %s", field->name);
     if (value)
         msg.appendf(", received %s", getTypeName(cass_value_type(value)));
     rtlFail(0, msg.str());
@@ -982,7 +982,7 @@ protected:
         else
             ret = cass_row_get_column(stmtInfo->queryRow(), colIdx++);
         if (!ret)
-            failx("Too many fields in ECL output row, reading field %s", str(field->name));
+            failx("Too many fields in ECL output row, reading field %s", field->name);
         return ret;
     }
     const CassandraStatementInfo *stmtInfo;
@@ -1169,14 +1169,14 @@ protected:
     inline unsigned checkNextParam(const RtlFieldInfo * field)
     {
         if (logctx.queryTraceLevel() > 4)
-            logctx.CTXLOG("Binding %s to %d", str(field->name), thisParam);
+            logctx.CTXLOG("Binding %s to %d", field->name, thisParam);
         return thisParam++;
     }
     inline void checkBind(CassError rc, const RtlFieldInfo * field)
     {
         if (rc != CASS_OK)
         {
-            failx("While binding parameter %s: %s", str(field->name), cass_error_desc(rc));
+            failx("While binding parameter %s: %s", field->name, cass_error_desc(rc));
         }
     }
     const RtlTypeInfo *typeInfo;

+ 1 - 1
plugins/cassandra/cassandrawu.cpp

@@ -25,7 +25,7 @@
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlembed.hpp"
 #include "roxiemem.hpp"
 #include "nbcd.hpp"

+ 10 - 10
plugins/couchbase/couchbaseembed.cpp

@@ -166,7 +166,7 @@ namespace couchbaseembed
 
     void bindStringParam(unsigned len, const char *value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
     {
-        VStringBuffer cbPlaceholder("$%s", field->name->queryStr());
+        VStringBuffer cbPlaceholder("$%s", field->name);
         if (pQcmd)
         {
             size32_t utf8chars;
@@ -182,7 +182,7 @@ namespace couchbaseembed
 
     void bindBoolParam(bool value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
     {
-        VStringBuffer cbPlaceholder("$%s", field->name->queryStr());
+        VStringBuffer cbPlaceholder("$%s", field->name);
         if (pQcmd)
         {
             StringBuffer serialized;
@@ -199,7 +199,7 @@ namespace couchbaseembed
 
     void bindDataParam(unsigned len, const void *value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
     {
-        VStringBuffer cbPlaceholder("$%s", field->name->queryStr());
+        VStringBuffer cbPlaceholder("$%s", field->name);
         if (pQcmd)
         {
             size32_t bytes;
@@ -216,7 +216,7 @@ namespace couchbaseembed
 
     void bindIntParam(__int64 value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
     {
-        VStringBuffer cbPlaceholder("$%s", field->name->queryStr());
+        VStringBuffer cbPlaceholder("$%s", field->name);
         if (pQcmd)
         {
             StringBuffer serialized;
@@ -233,7 +233,7 @@ namespace couchbaseembed
 
     void bindUIntParam(unsigned __int64 value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
     {
-        VStringBuffer cbPlaceholder("$%s", field->name->queryStr());
+        VStringBuffer cbPlaceholder("$%s", field->name);
         if (pQcmd)
         {
             StringBuffer serialized;
@@ -250,7 +250,7 @@ namespace couchbaseembed
 
     void bindRealParam(double value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
     {
-        VStringBuffer cbPlaceholder("$%s", field->name->queryStr());
+        VStringBuffer cbPlaceholder("$%s", field->name);
         if (pQcmd)
         {
             StringBuffer serialized;
@@ -266,7 +266,7 @@ namespace couchbaseembed
 
     void bindUnicodeParam(unsigned chars, const UChar *value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
     {
-        VStringBuffer cbPlaceholder("$%s", field->name->queryStr());
+        VStringBuffer cbPlaceholder("$%s", field->name);
         if (pQcmd)
         {
             size32_t utf8chars;
@@ -357,7 +357,7 @@ namespace couchbaseembed
     unsigned CouchbaseRecordBinder::checkNextParam(const RtlFieldInfo * field)
     {
        if (logctx.queryTraceLevel() > 4)
-           logctx.CTXLOG("Binding %s to %d", str(field->name), thisParam);
+           logctx.CTXLOG("Binding %s to %d", field->name, thisParam);
        return thisParam++;
     }
 
@@ -909,7 +909,7 @@ namespace couchbaseembed
         */
 
         if (getNumFields(field->type->queryChildType()) > 0)
-            m_oNestedField.set(m_oResultRow->queryBranch(field->name->queryStr()));
+            m_oNestedField.set(m_oResultRow->queryBranch(field->name));
     }
 
     void CouchbaseRowBuilder::processBeginRow(const RtlFieldInfo * field)
@@ -941,7 +941,7 @@ namespace couchbaseembed
         if (!m_oResultRow)
             failx("Missing result row data");
 
-        const char * fieldname = field->name->queryStr();
+        const char * fieldname = field->name;
         if (!fieldname || !*fieldname)
             failx("Missing result column metadata (name)");
 

+ 2 - 2
plugins/couchbase/couchbaseembed.hpp

@@ -40,7 +40,7 @@
 #include "jptree.hpp"
 #include "tokenserialization.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "roxiemem.hpp"
 
 
@@ -60,7 +60,7 @@ namespace couchbaseembed
 
     static void typeError(const char *expected, const RtlFieldInfo *field)
     {
-        typeError(expected, field ? field->name->queryStr() : nullptr);
+        typeError(expected, field ? field->name : nullptr);
     }
 
     static int getNumFields(const RtlTypeInfo *record)

+ 6 - 6
plugins/javaembed/javaembed.cpp

@@ -24,7 +24,7 @@
 #include "eclhelper.hpp"
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlds_imp.hpp"
 #include "jprop.hpp"
 #include "build-config.h"
@@ -304,10 +304,10 @@ protected:
             if (inSet)
             {
                 VStringBuffer arraySig("[%s", sig);
-                fieldId = JNIenv->GetFieldID(Class, str(field->name), arraySig.str());
+                fieldId = JNIenv->GetFieldID(Class, field->name, arraySig.str());
             }
             else
-                fieldId = JNIenv->GetFieldID(Class, str(field->name), sig);
+                fieldId = JNIenv->GetFieldID(Class, field->name, sig);
         }
         else
         {
@@ -318,14 +318,14 @@ protected:
             checkException();
             jmethodID getDeclaredField = JNIenv->GetMethodID(classClass, "getDeclaredField", "(Ljava/lang/String;)Ljava/lang/reflect/Field;" );
             checkException();
-            jstring fieldName = JNIenv->NewStringUTF(str(field->name));
+            jstring fieldName = JNIenv->NewStringUTF(field->name);
             checkException();
             jobject reflectedField = JNIenv->CallObjectMethod(Class, getDeclaredField, fieldName);
             checkException();
             fieldId = JNIenv->FromReflectedField(reflectedField);
         }
         if (!fieldId && expected)
-            throw MakeStringException(0, "javaembed: Unable to retrieve field %s of type %s", str(field->name), expected);
+            throw MakeStringException(0, "javaembed: Unable to retrieve field %s of type %s", field->name, expected);
         if (expected)
             checkException();
         else
@@ -951,7 +951,7 @@ public:
             if (!JNIenv->CallBooleanMethod(arrayClass, isArrayMethod))
             {
                 JNIenv->ExceptionClear();
-                VStringBuffer message("javaembed: Array expected for field %s", str(field->name));
+                VStringBuffer message("javaembed: Array expected for field %s", field->name);
                 rtlFail(0, message.str());
             }
             // Set up constructor etc for the child rows, so we don't do it per row

+ 4 - 4
plugins/mysql/mysqlembed.cpp

@@ -25,7 +25,7 @@
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlembed.hpp"
 #include "roxiemem.hpp"
 #include "nbcd.hpp"
@@ -706,7 +706,7 @@ static void typeError(const char *expected, const RtlFieldInfo *field)
 {
     VStringBuffer msg("mysql: type mismatch - %s expected", expected);
     if (field)
-        msg.appendf(" for field %s", field->name->queryStr());
+        msg.appendf(" for field %s", field->name);
     rtlFail(0, msg.str());
 }
 
@@ -1070,9 +1070,9 @@ protected:
             colIdx++;
         else
             fail("Too many fields in ECL output row");
-        const MYSQL_BIND &column = resultInfo.queryColumn(colIdx,field->name->queryStr());
+        const MYSQL_BIND &column = resultInfo.queryColumn(colIdx,field->name);
         if (*column.error)
-            failx("Error fetching column %s", field->name->queryStr());
+            failx("Error fetching column %s", field->name);
         return column;
     }
     const MySQLBindingArray &resultInfo;

+ 4 - 4
plugins/pyembed/pyembed.cpp

@@ -26,7 +26,7 @@
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "nbcd.hpp"
 #include "roxiemem.hpp"
 #include "enginecontext.hpp"
@@ -365,7 +365,7 @@ public:
             const RtlFieldInfo *field = *fields;
             if (names.length())
                 names.append(',');
-            names.append(str(field->name));
+            names.append(field->name);
             fields++;
         }
         OwnedPyObject pnames = PyString_FromString(names.str());
@@ -559,7 +559,7 @@ static void typeError(const char *expected, const RtlFieldInfo *field)
 {
     VStringBuffer msg("pyembed: type mismatch - %s expected", expected);
     if (field)
-        msg.appendf(" for field %s", str(field->name));
+        msg.appendf(" for field %s", field->name);
     rtlFail(0, msg.str());
 }
 
@@ -947,7 +947,7 @@ protected:
             elem.setown(pushback.getClear());
         else if (field && named) // If it's named tuple, expect to always resolve fields by name, not position
         {
-            elem.setown(PyObject_GetAttrString(parent, str(field->name)));
+            elem.setown(PyObject_GetAttrString(parent, field->name));
         }
         else if (iter)
             elem.setown(PyIter_Next(iter));

+ 2 - 2
plugins/sqlite3/sqlite3.cpp

@@ -25,7 +25,7 @@
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlembed.hpp"
 #include "nbcd.hpp"
 
@@ -88,7 +88,7 @@ static void typeError(const char *expected, const RtlFieldInfo *field)
 {
     VStringBuffer msg("sqlite3: type mismatch - %s expected", expected);
     if (field)
-        msg.appendf(" for field %s", str(field->name));
+        msg.appendf(" for field %s", field->name);
     rtlFail(0, msg.str());
 }
 

+ 5 - 5
plugins/v8embed/v8embed.cpp

@@ -24,7 +24,7 @@
 #include "eclrtl.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlds_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "nbcd.hpp"
 #include "roxiemem.hpp"
 #include <vector>
@@ -66,7 +66,7 @@ static void typeError(const char *expected, const RtlFieldInfo *field)
 {
     VStringBuffer msg("v8embed: type mismatch - %s expected", expected);
     if (field)
-        msg.appendf(" for field %s", str(field->name));
+        msg.appendf(" for field %s", field->name);
     rtlFail(0, msg.str());
 }
 
@@ -201,10 +201,10 @@ protected:
         v8::Local<v8::Value> v;
         if (named)
         {
-            v8::Local<v8::String> name = v8::String::New(str(field->name));
+            v8::Local<v8::String> name = v8::String::New(field->name);
             if (!row->Has(name))
             {
-                VStringBuffer msg("v8embed: No value for field %s", str(field->name));
+                VStringBuffer msg("v8embed: No value for field %s", field->name);
                 rtlFail(0, msg.str());
             }
             v = row->Get(name);
@@ -363,7 +363,7 @@ protected:
         if (inDataset)
             obj->Set(idx++, value);
         else
-            obj->Set(v8::String::New(str(field->name)), value);
+            obj->Set(v8::String::New(field->name), value);
     }
     v8::Local<v8::Object> obj;
     std::vector< v8::Local<v8::Object> > stack;

+ 1 - 1
roxie/ccd/ccdserver.cpp

@@ -38,7 +38,7 @@
 #include "thorfile.hpp"
 #include "eclhelper.hpp"
 #include "eclrtl_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlds_imp.hpp"
 #include "rtlread_imp.hpp"
 

+ 3 - 2
rtl/eclrtl/CMakeLists.txt

@@ -31,6 +31,7 @@ set (    SRCS
          rtlbcd.cpp 
          rtldistr.cpp 
          rtlds.cpp 
+         rtldynfield.cpp 
          rtlint.cpp 
          rtlkey.cpp 
          rtlqstr.cpp 
@@ -47,7 +48,7 @@ set (    SRCS
          rtldistr.hpp
          rtlds_imp.hpp
          rtlembed.hpp
-         rtlfield_imp.hpp
+         rtlfield.hpp
          rtlkey2.hpp
          rtlkey.hpp
          rtlread_imp.hpp
@@ -98,7 +99,7 @@ if (NOT PLUGIN)
     ${CMAKE_CURRENT_SOURCE_DIR}/rtlbcd.hpp
     ${CMAKE_CURRENT_SOURCE_DIR}/rtldistr.hpp
     ${CMAKE_CURRENT_SOURCE_DIR}/rtlds_imp.hpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/rtlfield_imp.hpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/rtlfield.hpp
     ${CMAKE_CURRENT_SOURCE_DIR}/rtlkey.hpp
   )
     install ( FILES ${iFILES} DESTINATION componentfiles/cl/include COMPONENT Runtime )

+ 1 - 1
rtl/eclrtl/eclinclude4.hpp

@@ -63,7 +63,7 @@ typedef unsigned __int64 hash64_t;
 #include "eclhelper.hpp"
 #include "rtlkey.hpp"
 #include "eclrtl_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlds_imp.hpp"
 #include "eclhelper_base.hpp"
 #include "rtlbcd.hpp"

+ 1 - 1
rtl/eclrtl/rtlds.cpp

@@ -258,7 +258,7 @@ void rtlRowsAttr::dispose()
 void rtlReportFieldOverflow(unsigned size, unsigned max, const RtlFieldInfo * field)
 {
     if (field)
-        rtlReportFieldOverflow(size, max, str(field->name));
+        rtlReportFieldOverflow(size, max, field->name);
     else
         rtlReportRowOverflow(size, max);
 }

+ 25 - 0
rtl/eclrtl/rtldynfield.cpp

@@ -0,0 +1,25 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+#include "platform.h"
+#include <math.h>
+#include <stdio.h>
+#include "jmisc.hpp"
+#include "jlib.hpp"
+#include "eclhelper.hpp"
+#include "eclrtl_imp.hpp"
+#include "rtldynfield.hpp"

+ 41 - 0
rtl/eclrtl/rtldynfield.hpp

@@ -0,0 +1,41 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2016 HPCC Systems®.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+#ifndef rtldynfield_hpp
+#define rtldynfield_hpp
+
+#include "rtlfield.hpp"
+
+//These classes support the dynamic creation of type and field information
+
+struct ECLRTL_API RtlDynFieldInfo : public RtlFieldInfo
+{
+public:
+    RtlDynFieldInfo(const char * _name, const char * _xpath, const RtlTypeInfo * _type)
+    : RtlFieldInfo(nullptr, nullptr, _type, nullptr), nameAttr(_name), xpathAttr(_xpath)
+    {
+        name = nameAttr.get();
+        xpath = xpathAttr.get();
+    }
+
+protected:
+    StringAttr nameAttr;
+    StringAttr xpathAttr;
+};
+
+
+#endif

+ 1 - 1
rtl/eclrtl/rtlembed.hpp

@@ -18,7 +18,7 @@
 #ifndef rtlembed_hpp
 #define rtlembed_hpp
 
-// NOTE - not included from generated code (see rtlfield_imp.hpp)
+// NOTE - not included from generated code (see rtlfield.hpp)
 
 #include "eclrtl.hpp"
 #include "nbcd.hpp"

+ 28 - 28
rtl/eclrtl/rtlfield.cpp

@@ -22,7 +22,7 @@
 #include "jlib.hpp"
 #include "eclhelper.hpp"
 #include "eclrtl_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlds_imp.hpp"
 #include "nbcd.hpp"
 
@@ -36,13 +36,13 @@ static const char * queryXPath(const RtlFieldInfo * field)
             return xpath;
         return sep+1;
     }
-    return str(field->name);
+    return field->name;
 }
 
 static const char * queryScalarXPath(const RtlFieldInfo * field)
 {
     if (field->type->hasNonScalarXpath())
-        return str(field->name);
+        return field->name;
     return queryXPath(field);
 }
 
@@ -131,7 +131,7 @@ const RtlTypeInfo * RtlTypeInfoBase::queryChildType() const
 
 size32_t RtlBoolTypeInfo::build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const
 {
-    builder.ensureCapacity(sizeof(bool)+offset, str(field->name));
+    builder.ensureCapacity(sizeof(bool)+offset, field->name);
     bool val = source.getBooleanResult(field);
     * (bool *) (builder.getSelf() + offset) = val;
     offset += sizeof(bool);
@@ -161,7 +161,7 @@ double RtlRealTypeInfo::value(const byte * self) const
 
 size32_t RtlRealTypeInfo::build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const
 {
-    builder.ensureCapacity(length+offset, str(field->name));
+    builder.ensureCapacity(length+offset, field->name);
     double val = source.getRealResult(field);
     byte *dest = builder.getSelf() + offset;
     if (length == 4)
@@ -188,7 +188,7 @@ size32_t RtlRealTypeInfo::toXML(const byte * self, const byte * selfrow, const R
 
 size32_t RtlIntTypeInfo::build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const
 {
-    builder.ensureCapacity(length+offset, str(field->name));
+    builder.ensureCapacity(length+offset, field->name);
     __int64 val = isUnsigned() ? (__int64) source.getUnsignedResult(field) : source.getSignedResult(field);
     rtlWriteInt(builder.getSelf() + offset, val, length);
     offset += length;
@@ -217,7 +217,7 @@ size32_t RtlIntTypeInfo::toXML(const byte * self, const byte * selfrow, const Rt
 
 size32_t RtlSwapIntTypeInfo::build(ARowBuilder &builder, size32_t offset, const RtlFieldInfo *field, IFieldSource &source) const
 {
-    builder.ensureCapacity(length+offset, str(field->name));
+    builder.ensureCapacity(length+offset, field->name);
     __int64 val = isUnsigned() ? (__int64) source.getUnsignedResult(field) : source.getSignedResult(field);
     // NOTE - we assume that the value returned from the source is NOT already a swapped int - source doesn;t know that we are going to store it swapped
     rtlWriteSwapInt(builder.getSelf() + offset, val, length);
@@ -254,7 +254,7 @@ size32_t RtlPackedIntTypeInfo::build(ARowBuilder &builder, size32_t offset, cons
 {
     unsigned __int64 value = isUnsigned() ? (__int64) source.getUnsignedResult(field) : source.getSignedResult(field);
     size32_t sizeInBytes = rtlGetPackedSize(&value);
-    builder.ensureCapacity(sizeInBytes+offset, str(field->name));
+    builder.ensureCapacity(sizeInBytes+offset, field->name);
     rtlSetPackedUnsigned(builder.getSelf() + offset, value);
     offset += sizeInBytes;
     return offset;
@@ -295,7 +295,7 @@ size32_t RtlStringTypeInfo::build(ARowBuilder &builder, size32_t offset, const R
     source.getStringResult(field, size, value);
     if (!isFixedSize())
     {
-        builder.ensureCapacity(offset+size+sizeof(size32_t), str(field->name));
+        builder.ensureCapacity(offset+size+sizeof(size32_t), field->name);
         byte *dest = builder.getSelf()+offset;
         rtlWriteInt4(dest, size);
         // NOTE - it has been the subject of debate whether we should convert the incoming data to EBCDIC, or expect the IFieldSource to have already returned ebcdic
@@ -309,7 +309,7 @@ size32_t RtlStringTypeInfo::build(ARowBuilder &builder, size32_t offset, const R
     }
     else
     {
-        builder.ensureCapacity(offset+length, str(field->name));
+        builder.ensureCapacity(offset+length, field->name);
         byte *dest = builder.getSelf()+offset;
         if (isEbcdic())
             rtlStrToEStr(length, (char *) dest, size, (char *) value);
@@ -399,7 +399,7 @@ size32_t RtlDataTypeInfo::build(ARowBuilder &builder, size32_t offset, const Rtl
     source.getDataResult(field, size, value);
     if (!isFixedSize())
     {
-        builder.ensureCapacity(offset+size+sizeof(size32_t), str(field->name));
+        builder.ensureCapacity(offset+size+sizeof(size32_t), field->name);
         byte *dest = builder.getSelf()+offset;
         rtlWriteInt4(dest, size);
         memcpy(dest+sizeof(size32_t), value, size);
@@ -407,7 +407,7 @@ size32_t RtlDataTypeInfo::build(ARowBuilder &builder, size32_t offset, const Rtl
     }
     else
     {
-        builder.ensureCapacity(offset+length, str(field->name));
+        builder.ensureCapacity(offset+length, field->name);
         byte *dest = builder.getSelf()+offset;
         rtlDataToData(length, dest, size, value);
         offset += length;
@@ -475,7 +475,7 @@ size32_t RtlVarStringTypeInfo::build(ARowBuilder &builder, size32_t offset, cons
     source.getStringResult(field, size, value);
     if (!isFixedSize())
     {
-        builder.ensureCapacity(offset+size+1, str(field->name));
+        builder.ensureCapacity(offset+size+1, field->name);
         // See notes re EBCDIC conversion in RtlStringTypeInfo code
         byte *dest = builder.getSelf()+offset;
         memcpy(dest, value, size);
@@ -484,7 +484,7 @@ size32_t RtlVarStringTypeInfo::build(ARowBuilder &builder, size32_t offset, cons
     }
     else
     {
-        builder.ensureCapacity(offset+length, str(field->name));
+        builder.ensureCapacity(offset+length, field->name);
         byte *dest = builder.getSelf()+offset;
         rtlStrToVStr(length, dest, size, value);
         offset += length;
@@ -556,7 +556,7 @@ size32_t RtlQStringTypeInfo::build(ARowBuilder &builder, size32_t offset, const
     if (!isFixedSize())
     {
         size32_t sizeInBytes = rtlQStrSize(size) + sizeof(size32_t);
-        builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         byte *dest = builder.getSelf()+offset;
         rtlWriteInt4(dest, size);
         rtlStrToQStr(size, (char *) dest+sizeof(size32_t), size, value);
@@ -565,7 +565,7 @@ size32_t RtlQStringTypeInfo::build(ARowBuilder &builder, size32_t offset, const
     else
     {
         size32_t sizeInBytes = rtlQStrSize(length);
-        builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         byte *dest = builder.getSelf()+offset;
         rtlStrToQStr(length, (char *) dest, size, value);
         offset += sizeInBytes;
@@ -635,7 +635,7 @@ size32_t RtlDecimalTypeInfo::build(ARowBuilder &builder, size32_t offset, const
     Decimal value;
     source.getDecimalResult(field, value);
     size32_t sizeInBytes = calcSize();
-    builder.ensureCapacity(sizeInBytes+offset, str(field->name));
+    builder.ensureCapacity(sizeInBytes+offset, field->name);
     if (isUnsigned())
         value.getUDecimal(sizeInBytes, getDecimalPrecision(), builder.getSelf()+offset);
     else
@@ -712,7 +712,7 @@ size32_t RtlUnicodeTypeInfo::build(ARowBuilder &builder, size32_t offset, const
     if (!isFixedSize())
     {
         size32_t sizeInBytes = sizeInChars * sizeof(UChar);
-        builder.ensureCapacity(offset+sizeInBytes+sizeof(size32_t), str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes+sizeof(size32_t), field->name);
         byte *dest = builder.getSelf()+offset;
         rtlWriteInt4(dest, sizeInChars);  // NOTE - in chars!
         memcpy(dest+sizeof(size32_t), value, sizeInBytes);
@@ -721,7 +721,7 @@ size32_t RtlUnicodeTypeInfo::build(ARowBuilder &builder, size32_t offset, const
     else
     {
         size32_t sizeInBytes = length * sizeof(UChar);
-        builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         byte *dest = builder.getSelf()+offset;
         rtlUnicodeToUnicode(length, (UChar *) dest, sizeInChars, value);
         offset += sizeInBytes;
@@ -790,7 +790,7 @@ size32_t RtlVarUnicodeTypeInfo::build(ARowBuilder &builder, size32_t offset, con
     if (!isFixedSize())
     {
         size32_t sizeInBytes = (sizeInChars+1) * sizeof(UChar);
-        builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         UChar *dest = (UChar *) builder.getSelf()+offset;
         memcpy(dest, value, sizeInBytes - sizeof(UChar));
         dest[sizeInChars] = 0;
@@ -799,7 +799,7 @@ size32_t RtlVarUnicodeTypeInfo::build(ARowBuilder &builder, size32_t offset, con
     else
     {
         size32_t sizeInBytes = length * sizeof(UChar);
-        builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         byte *dest = builder.getSelf()+offset;
         rtlUnicodeToVUnicode(length, (UChar *) dest, sizeInChars, value);
         offset += sizeInBytes;
@@ -851,7 +851,7 @@ size32_t RtlUtf8TypeInfo::build(ARowBuilder &builder, size32_t offset, const Rtl
     source.getUTF8Result(field, sizeInChars, value);
     size32_t sizeInBytes = rtlUtf8Size(sizeInChars, value);
     assertex(!isFixedSize());
-    builder.ensureCapacity(offset+sizeInBytes+sizeof(size32_t), str(field->name));
+    builder.ensureCapacity(offset+sizeInBytes+sizeof(size32_t), field->name);
     byte *dest = builder.getSelf()+offset;
     rtlWriteInt4(dest, sizeInChars);  // NOTE - in chars!
     memcpy(dest+sizeof(size32_t), value, sizeInBytes);
@@ -995,7 +995,7 @@ size32_t RtlSetTypeInfo::build(ARowBuilder &builder, size32_t offset, const RtlF
     bool isAll;
     source.processBeginSet(field, isAll);
     size32_t sizeInBytes = sizeof(bool) + sizeof(size32_t);
-    builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+    builder.ensureCapacity(offset+sizeInBytes, field->name);
     byte *dest = builder.getSelf()+offset;
     if (isAll)
     {
@@ -1135,7 +1135,7 @@ size32_t RtlDatasetTypeInfo::build(ARowBuilder &builder, size32_t offset, const
     {
         // a 32-bit record count, and a pointer to an array of record pointers
         size32_t sizeInBytes = sizeof(size32_t) + sizeof(void *);
-        builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         size32_t numRows = 0;
         Owned<IEngineRowAllocator> childAllocator = builder.queryAllocator()->createChildRowAllocator(child);
         byte **childRows = NULL;
@@ -1155,7 +1155,7 @@ size32_t RtlDatasetTypeInfo::build(ARowBuilder &builder, size32_t offset, const
     {
         // a 32-bit size, then rows inline
         size32_t sizeInBytes = sizeof(size32_t);
-        builder.ensureCapacity(offset+sizeInBytes, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         size32_t newOffset = offset + sizeInBytes;
         RtlFieldStrInfo dummyField("<nested row>", NULL, child);
         while (source.processNextRow(field))
@@ -1270,7 +1270,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, str(field->name));
+        builder.ensureCapacity(offset+sizeInBytes, field->name);
         Owned<IEngineRowAllocator> childAllocator = builder.queryAllocator()->createChildRowAllocator(child);
         RtlLinkedDictionaryBuilder dictBuilder(childAllocator, hashInfo);
         RtlFieldStrInfo dummyField("<nested row>", NULL, child);
@@ -1450,13 +1450,13 @@ size32_t RtlUnimplementedTypeInfo::toXML(const byte * self, const byte * selfrow
 //-------------------------------------------------------------------------------------------------------------------
 
 RtlFieldStrInfo::RtlFieldStrInfo(const char * _name, const char * _xpath, const RtlTypeInfo * _type, const char *_initializer)
-: RtlFieldInfo(rtlCreateFieldNameAtom(_name), _xpath, _type, _initializer)
+: RtlFieldInfo(_name, _xpath, _type, _initializer)
 {
 }
 
 
 RtlFieldStrInfo::RtlFieldStrInfo(const char * _name, const char * _xpath, const RtlTypeInfo * _type)
-: RtlFieldInfo(rtlCreateFieldNameAtom(_name), _xpath, _type, NULL)
+: RtlFieldInfo(_name, _xpath, _type, NULL)
 {
 }
 

+ 11 - 2
rtl/eclrtl/rtlfield_imp.hpp

@@ -15,11 +15,20 @@
     limitations under the License.
 ############################################################################## */
 
-#ifndef rtlfield_imp_hpp
-#define rtlfield_imp_hpp
+#ifndef rtlfield_hpp
+#define rtlfield_hpp
 
+#include "eclhelper.hpp"
 #include "eclrtl.hpp"
 
+/*
+The classes in this file are used to represent the type of various fields, and information about the fields.
+They are primarily designed to be used in generated code, so should have as little overhead as possible when used
+in that context.  For that reason the classes have no destructors.
+
+The file rtldynfield contains classes which manage instances of these classes which are dynamically created.
+*/
+
 // A base implementation of RtlTypeInfo
 struct ECLRTL_API RtlTypeInfoBase : public RtlTypeInfo
 {

+ 4 - 3
rtl/include/eclhelper.hpp

@@ -344,6 +344,7 @@ interface IRtlFieldTypeDeserializer;
 //Interface used to get field information.  Separate from RtlTypeInfo for clarity and to ensure the vmt comes first.
 interface RtlITypeInfo
 {
+    virtual ~RtlITypeInfo() {}
     virtual size32_t size(const byte * self, const byte * selfrow) const = 0;
     virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const = 0;  // returns the size
     virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & out) const = 0;
@@ -381,13 +382,13 @@ public:
                                     // if RFTMunknownsize then maxlength (records) [maxcount(datasets)]
 };
 
-//Core struct used for representing meta for a field.
+//Core struct used for representing meta for a field.  Effectively used as an interface.
 struct RtlFieldInfo
 {
-    inline RtlFieldInfo(IAtom * _name, const char * _xpath, const RtlTypeInfo * _type, const char *_initializer = NULL)
+    inline RtlFieldInfo(const char * _name, const char * _xpath, const RtlTypeInfo * _type, const char *_initializer = NULL)
     : name(_name), xpath(_xpath), type(_type), initializer((const byte *) _initializer) {}
 
-    IAtom * name;
+    const char * name;
     const char * xpath;
     const RtlTypeInfo * type;
     const byte *initializer;

+ 1 - 1
thorlcr/thorutil/thormisc.cpp

@@ -45,7 +45,7 @@
 #include "eclhelper.hpp"
 #include "eclrtl_imp.hpp"
 #include "rtlread_imp.hpp"
-#include "rtlfield_imp.hpp"
+#include "rtlfield.hpp"
 #include "rtlds_imp.hpp"
 
 namespace thormisc {  // Make sure we can't clash with generated versions or version check mechanism fails.