123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- /*##############################################################################
- 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"
- #include "rtlnewkey.hpp"
- //These classes support the dynamic creation of type and field information
- //-------------------------------------------------------------------------------------------------------------------
- /*
- * Used to represent the info that is needed to dynamically create an RtlTypeInfo object
- */
- struct ECLRTL_API FieldTypeInfoStruct
- {
- public:
- unsigned fieldType = 0;
- unsigned length = 0;
- const char *locale = nullptr;
- const char *className = nullptr;
- const RtlTypeInfo *childType = nullptr;
- const RtlFieldInfo * * fieldsArray = nullptr;
- const IFieldFilter * filter = nullptr;
- const RtlTypeInfo *createRtlTypeInfo(IThorIndexCallback *_callback) const;
- };
- interface ITypeInfo;
- /**
- * IRtlFieldTypeDeserializer is used to manage the creation of RtlTypeInfo structures dynamically.
- * All created structures are owned by the deserializer and will be destroyed when the deserializer is destroyed.
- */
- interface IRtlFieldTypeDeserializer : public IInterface
- {
- /*
- * Create RtlTypeInfo structures from a serialized json representation
- *
- * @param json The json representation
- * @return Deserialized RtlTypeInfo structure
- */
- virtual const RtlTypeInfo *deserialize(const char *json) = 0;
- /*
- * Create RtlTypeInfo structures from a serialized json representation
- *
- * @param jsonTree The json representation
- * @return Deserialized RtlTypeInfo structure
- */
- virtual const RtlTypeInfo *deserialize(IPropertyTree &jsonTree) = 0;
- /*
- * Create RtlTypeInfo structures from a serialized binary representation
- *
- * @param buf The binary representation
- * @return Deserialized RtlTypeInfo structure
- */
- virtual const RtlTypeInfo *deserialize(MemoryBuffer &buf) = 0;
- /*
- * Create a single RtlTypeInfo structure from a FieldTypeInfoStruct
- *
- * @param info The information used to create the type
- * @param key A unique pointer used to dedup typeinfo structures
- * @return RtlTypeInfo structure
- */
- virtual const RtlTypeInfo *addType(FieldTypeInfoStruct &info, const IInterface *typeOrIfblock) = 0;
- /*
- * Check if a type has already been created for a given key
- *
- * @param key A unique pointer used to dedup typeinfo structures
- * @return RtlTypeInfo structure, or nullptr if not yet created
- */
- virtual const RtlTypeInfo *lookupType(const IInterface *key) const = 0;
- /*
- * Create RtlFieldInfo structure as part of a RtlTypeInfo tree
- *
- * @param fieldName Field name
- * @param xpath XPath
- * @param type Field type
- * @param flags Field flags
- * @param init Field initializer, or nullptr
- * @return RtlFieldInfo structure. All strings will be owned by the deserializer object
- */
- virtual const RtlFieldInfo *addFieldInfo(const char *fieldName, const char *xpath, const RtlTypeInfo *type, unsigned flags, const char *init) = 0;
- };
- enum class RecordTranslationMode { None = 0, All = 1, Payload = 2, AlwaysDisk = 3, AlwaysECL = 4 }; // Latter 2 are for testing purposes only
- extern ECLRTL_API RecordTranslationMode getTranslationMode(const char *modeStr);
- extern ECLRTL_API const char *getTranslationModeText(RecordTranslationMode val);
- interface IDynamicTransform : public IInterface
- {
- virtual void describe() const = 0;
- virtual size32_t translate(ARowBuilder &builder, const byte *sourceRec) const = 0;
- virtual size32_t translate(ARowBuilder &builder, const RtlRow &sourceRow) const = 0;
- virtual bool canTranslate() const = 0;
- virtual bool needsTranslate() const = 0;
- virtual bool keyedTranslated() const = 0;
- };
- interface IKeyTranslator : public IInterface
- {
- virtual void describe() const = 0;
- virtual bool translate(RowFilter &filters) const = 0; // MORE - this should be deprecated
- virtual bool translate(RowFilter &result, IConstArrayOf<IFieldFilter> &_filters) const = 0;
- virtual bool needsTranslate() const = 0;
- };
- extern ECLRTL_API const IDynamicTransform *createRecordTranslator(const RtlRecord &_destRecInfo, const RtlRecord &_srcRecInfo);
- extern ECLRTL_API const IKeyTranslator *createKeyTranslator(const RtlRecord &_destRecInfo, const RtlRecord &_srcRecInfo);
- extern ECLRTL_API IRtlFieldTypeDeserializer *createRtlFieldTypeDeserializer(IThorIndexCallback *callback);
- extern ECLRTL_API StringBuffer &dumpTypeInfo(StringBuffer &ret, const RtlTypeInfo *t);
- extern ECLRTL_API bool dumpTypeInfo(MemoryBuffer &ret, const RtlTypeInfo *t);
- /**
- * Serialize metadata of supplied record to JSON, and return it to ECL caller as a string. Used for testing serializer.
- *
- */
- extern ECLRTL_API void dumpRecordType(size32_t & __lenResult, char * & __result, IOutputMetaData & metaVal);
- /**
- * Serialize metadata of supplied record to DATA.
- *
- */
- extern ECLRTL_API void serializeRecordType(size32_t & __lenResult, void * & __result, IOutputMetaData & metaVal);
- /**
- * Extract a field from a record via dynamic column number
- *
- */
- extern ECLRTL_API void getFieldVal(size32_t & __lenResult, char * & __result, int column, IOutputMetaData & metaVal, const byte *row);
- /**
- * Extract a column number from a record via dynamic fieldname
- *
- */
- extern ECLRTL_API int getFieldNum(const char *fieldName, IOutputMetaData & metaVal);
- extern ECLRTL_API IRowStream * transformRecord(IEngineRowAllocator * resultAllocator,IOutputMetaData & metaInput,IRowStream * input);
- #endif
|