浏览代码

Merge pull request #11221 from richardkchapman/index-meta-bias

HPCC-19771 ESP methods for returning file type info should use new data

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 7 年之前
父节点
当前提交
fbd4c34660
共有 2 个文件被更改,包括 73 次插入20 次删除
  1. 6 0
      common/thorhelper/thorcommon.cpp
  2. 67 20
      esp/services/ws_dfu/ws_dfuService.cpp

+ 6 - 0
common/thorhelper/thorcommon.cpp

@@ -2009,6 +2009,12 @@ extern THORHELPER_API IOutputMetaData *getDaliLayoutInfo(IPropertyTree const &pr
         }
         else if (props.hasProp("ECL"))
         {
+            const char *kind = props.queryProp("@kind");
+            if (kind && streq(kind, "key"))
+            {
+                DBGLOG("Cannot deserialize file metadata: index too old");
+                return nullptr;
+            }
             StringBuffer layoutECL;
             props.getProp("ECL", layoutECL);
             MultiErrorReceiver errs;

+ 67 - 20
esp/services/ws_dfu/ws_dfuService.cpp

@@ -1631,19 +1631,44 @@ bool CWsDfuEx::onDFURecordTypeInfo(IEspContext &context, IEspDFURecordTypeInfoRe
             userdesc.setown(createUserDescriptor());
             userdesc->set(userId, context.queryPassword(), context.querySessionToken(), context.querySignature());
         }
-
-        OwnedHqlExpr record = getEclRecordDefinition(userdesc, fileName);
-        if (req.getIncludeJsonTypeInfo())
+        Owned<IDistributedFile> df = queryDistributedFileDirectory().lookup(fileName, userdesc);
+        if(!df)
+            throw MakeStringException(ECLWATCH_FILE_NOT_EXIST,"Cannot find file %s.",fileName);
+        if (df->queryAttributes().hasProp("_rtlType"))
         {
-            StringBuffer jsonFormat;
-            exportJsonType(jsonFormat,record);
-            resp.setJsonInfo(jsonFormat);
+            MemoryBuffer layoutBin;
+            df->queryAttributes().getPropBin("_rtlType", layoutBin);
+            if (req.getIncludeJsonTypeInfo())
+            {
+                Owned<IRtlFieldTypeDeserializer> deserializer(createRtlFieldTypeDeserializer(nullptr));
+                const RtlTypeInfo *typeInfo = deserializer->deserialize(layoutBin);
+                StringBuffer jsonFormat;
+                dumpTypeInfo(jsonFormat, typeInfo);
+                resp.setJsonInfo(jsonFormat);
+                layoutBin.reset(0);
+            }
+            if (req.getIncludeBinTypeInfo())
+                resp.setBinInfo(layoutBin);
         }
-        if (req.getIncludeBinTypeInfo())
+        else if (df->queryAttributes().hasProp("ECL"))
         {
-            MemoryBuffer binFormat;
-            exportBinaryType(binFormat,record);
-            resp.setBinInfo(binFormat);
+            const char * kind = df->queryAttributes().queryProp("@kind");
+            if (kind && streq(kind, "key"))
+                throw MakeStringException(ECLWATCH_FILE_NOT_EXIST, "Index file %s does not contain type information",fileName);
+
+            OwnedHqlExpr record = getEclRecordDefinition(userdesc, fileName);
+            if (req.getIncludeJsonTypeInfo())
+            {
+                StringBuffer jsonFormat;
+                exportJsonType(jsonFormat,record);
+                resp.setJsonInfo(jsonFormat);
+            }
+            if (req.getIncludeBinTypeInfo())
+            {
+                MemoryBuffer binFormat;
+                exportBinaryType(binFormat,record);
+                resp.setBinInfo(binFormat);
+            }
         }
     }
     catch(IException* e)
@@ -2342,20 +2367,42 @@ void CWsDfuEx::doGetFileDetails(IEspContext &context, IUserDescriptor *udesc, co
             }
         }
     }
-    if (df->queryAttributes().hasProp("ECL") && (includeJsonTypeInfo||includeBinTypeInfo) )
+    if (includeJsonTypeInfo||includeBinTypeInfo)
     {
-        OwnedHqlExpr record = getEclRecordDefinition(df->queryAttributes().queryProp("ECL"));
-        if (includeJsonTypeInfo)
+        if (df->queryAttributes().hasProp("_rtlType"))
         {
-            StringBuffer jsonFormat;
-            exportJsonType(jsonFormat,record);
-            FileDetails.setJsonInfo(jsonFormat);
+            MemoryBuffer layoutBin;
+            df->queryAttributes().getPropBin("_rtlType", layoutBin);
+            if (includeJsonTypeInfo)
+            {
+                Owned<IRtlFieldTypeDeserializer> deserializer(createRtlFieldTypeDeserializer(nullptr));
+                const RtlTypeInfo *typeInfo = deserializer->deserialize(layoutBin);
+                StringBuffer jsonFormat;
+                dumpTypeInfo(jsonFormat, typeInfo);
+                FileDetails.setJsonInfo(jsonFormat);
+                layoutBin.reset(0);
+            }
+            if (includeBinTypeInfo)
+                FileDetails.setBinInfo(layoutBin);
         }
-        if (includeBinTypeInfo)
+        else if (df->queryAttributes().hasProp("ECL"))
         {
-            MemoryBuffer binFormat;
-            exportBinaryType(binFormat,record);
-            FileDetails.setBinInfo(binFormat);
+            const char * kind = df->queryAttributes().queryProp("@kind");
+            if (kind && streq(kind, "key"))
+                throw MakeStringException(ECLWATCH_FILE_NOT_EXIST, "Index file %s does not contain type information", name);
+            OwnedHqlExpr record = getEclRecordDefinition(df->queryAttributes().queryProp("ECL"));
+            if (includeJsonTypeInfo)
+            {
+                StringBuffer jsonFormat;
+                exportJsonType(jsonFormat, record);
+                FileDetails.setJsonInfo(jsonFormat);
+            }
+            if (includeBinTypeInfo)
+            {
+                MemoryBuffer binFormat;
+                exportBinaryType(binFormat, record);
+                FileDetails.setBinInfo(binFormat);
+            }
         }
     }
     PROGLOG("doGetFileDetails: %s done", name);