Browse Source

HPCC-10746 Fix FileView2 can't display keys that contain blobs

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 10 years ago
parent
commit
fb8a690136

+ 1 - 0
common/fileview2/fvdatasource.hpp

@@ -31,6 +31,7 @@ enum
     FVFFdataset     = 5,
     FVFFset         = 6,
     FVFFvirtual     = 7,
+    FVFFblob        = 8
 };
 
 interface IFvDataSource;

+ 15 - 2
common/fileview2/fvresultset.cpp

@@ -146,8 +146,9 @@ IFvDataSource * createFileDataSource(IDistributedFile * df, const char * logical
         const char * kind = properties.queryProp("@kind");
         if (kind && (stricmp(kind, "key") == 0))
         {
-            if (isSimplifiedRecord(diskRecord, true))
-                ds.setown(new IndexDataSource(logicalName, diskRecord, username, password));
+            OwnedHqlExpr indexRecord = annotateIndexBlobs(diskRecord);
+            if (isSimplifiedRecord(indexRecord, true))
+                ds.setown(new IndexDataSource(logicalName, indexRecord, username, password));
             else
                 throwError1(FVERR_ViewComplexKey, logicalName);
         }
@@ -656,6 +657,14 @@ void CResultSetMetaData::getXmlSchema(ISchemaBuilder & builder, bool useXPath) c
                 }
                 break;
             }
+        case FVFFblob: //for now FileViewer will output the string "[blob]"
+            {
+                Owned<ITypeInfo> stringType = makeStringType(UNKNOWN_LENGTH, NULL, NULL);
+                if (useXPath)
+                    fvSplitXPath(meta->queryXPath(idx), xname, name);
+                builder.addField(name, *stringType, idx < keyedCount);
+            }
+            break;
         default:
             {
                 ITypeInfo & type = *column.type;
@@ -1528,6 +1537,9 @@ void CResultSetCursor::writeXmlText(IXmlWriter &writer, int columnIndex, const c
     unsigned flags = column.flag;
     switch (flags)
     {
+    case FVFFblob:
+        writer.outputCString("[blob]", name);
+        return;
     case FVFFbeginif:
     case FVFFendif:
         return;
@@ -1759,6 +1771,7 @@ void CResultSetCursor::writeXmlRow(IXmlWriter &writer)
         case FVFFvirtual:
         case FVFFdataset:
         case FVFFset:
+        case FVFFblob:
             if (ignoreNesting == 0)
                 writeXmlText(writer, col);
             break;

+ 7 - 4
common/fileview2/fvsource.cpp

@@ -249,7 +249,7 @@ void DataSourceMetaData::addFileposition()
     addVirtualField("__fileposition__", NULL, makeIntType(8, false));
 }
 
-void DataSourceMetaData::addSimpleField(const char * name, const char * xpath, ITypeInfo * type)
+void DataSourceMetaData::addSimpleField(const char * name, const char * xpath, ITypeInfo * type, unsigned flag)
 {
     ITypeInfo * promoted = type->queryPromotedType();
     unsigned size = promoted->getSize();
@@ -291,7 +291,7 @@ void DataSourceMetaData::addSimpleField(const char * name, const char * xpath, I
         minRecordSize += size;
     if (thisBits == 0)
         bitsRemaining = 0;
-    fields.append(*new DataSourceMetaItem(FVFFnone, name, xpath, type));
+    fields.append(*new DataSourceMetaItem(flag, name, xpath, type));
 }
 
 
@@ -369,9 +369,12 @@ void DataSourceMetaData::gatherFields(IHqlExpression * expr, bool isConditional,
             IHqlExpression * xpathAttr = expr->queryAttribute(xpathAtom);
             if (xpathAttr && xpathAttr->queryChild(0)->queryValue())
                 xpath = xpathAttr->queryChild(0)->queryValue()->getStringValue(xpathtext);
-
+            unsigned flag = FVFFnone;
             if (isKey() && expr->hasAttribute(blobAtom))
+            {
                 type.setown(makeIntType(8, false));
+                flag = FVFFblob;
+            }
             type_t tc = type->getTypeCode();
             if (tc == type_row)
             {
@@ -407,7 +410,7 @@ void DataSourceMetaData::gatherFields(IHqlExpression * expr, bool isConditional,
                 }
                 if (pMixedContent && xpath && !*xpath)
                     *pMixedContent = true;
-                addSimpleField(outname, xpath, type);
+                addSimpleField(outname, xpath, type, flag);
             }
             break;
         }

+ 1 - 1
common/fileview2/fvsource.ipp

@@ -141,7 +141,7 @@ public:
     virtual size32_t getMinRecordSize() const;
 
 protected:
-    void addSimpleField(const char * name, const char * xpath, ITypeInfo * type);
+    void addSimpleField(const char * name, const char * xpath, ITypeInfo * type, unsigned flag=FVFFnone);
     void gatherFields(IHqlExpression * expr, bool isConditional, bool *pMixedContent);
     void gatherChildFields(IHqlExpression * expr, bool isConditional, bool *pMixedContent);
     void gatherAttributes();

+ 22 - 1
ecl/hql/hqlexpr.cpp

@@ -14180,7 +14180,7 @@ static void simplifyFileViewRecordTypes(HqlExprArray & fields, IHqlExpression *
             bool forceSimplify = false;
             if (isKey)
             {
-                if (cur->hasAttribute(blobAtom))
+                if (cur->hasAttribute(blobAtom) && !cur->hasAttribute(_isBlobInIndex_Atom))
                     forceSimplify = true;
             }
             else
@@ -16072,6 +16072,27 @@ extern bool HQL_API extractVersion(unsigned & major, unsigned & minor, unsigned
     return true;
 }
 
+static HqlTransformerInfo cHqlBlobTransformerInfo("CHqlBlobTransformer");
+class CHqlBlobTransformer : public QuickHqlTransformer
+{
+public:
+    CHqlBlobTransformer() : QuickHqlTransformer(cHqlBlobTransformerInfo, NULL) {}
+
+    virtual IHqlExpression * createTransformed(IHqlExpression * expr)
+    {
+        OwnedHqlExpr transformed = QuickHqlTransformer::createTransformed(expr);
+        if ((expr->getOperator() == no_field) && expr->hasAttribute(blobAtom))
+            return appendOwnedOperand(transformed, createAttribute(_isBlobInIndex_Atom));
+        return transformed.getClear();
+    }
+};
+
+IHqlExpression * annotateIndexBlobs(IHqlExpression * expr)
+{
+    CHqlBlobTransformer transformer;
+    return transformer.transform(expr);
+}
+
 /*
 List of changes:
 

+ 3 - 0
ecl/hql/hqlexpr.hpp

@@ -1862,4 +1862,7 @@ void exportSymbols(IPropertyTree* data, IHqlScope * scope, HqlLookupContext & ct
 //The following is only here to provide information about the source file being compiled when reporting leaks
 extern HQL_API void setActiveSource(const char * filename);
 
+extern HQL_API IHqlExpression * annotateIndexBlobs(IHqlExpression * expr);
+
+
 #endif

+ 0 - 22
ecl/hqlcpp/hqlhtcpp.cpp

@@ -10088,28 +10088,6 @@ protected:
 };
 
 
-static HqlTransformerInfo cHqlBlobTransformerInfo("CHqlBlobTransformer");
-class CHqlBlobTransformer : public QuickHqlTransformer
-{
-public:
-    CHqlBlobTransformer() : QuickHqlTransformer(cHqlBlobTransformerInfo, NULL) {}
-
-    virtual IHqlExpression * createTransformed(IHqlExpression * expr)
-    {
-        OwnedHqlExpr transformed = QuickHqlTransformer::createTransformed(expr);
-        if ((expr->getOperator() == no_field) && expr->hasAttribute(blobAtom))
-            return appendOwnedOperand(transformed, createAttribute(_isBlobInIndex_Atom));
-        return transformed.getClear();
-    }
-};
-
-IHqlExpression * annotateIndexBlobs(IHqlExpression * expr)
-{
-    CHqlBlobTransformer transformer;
-    return transformer.transform(expr);
-}
-
-
 IDefRecordElement * HqlCppTranslator::createMetaRecord(IHqlExpression * record)
 {
     TranslatorMaxSizeCallback callback(*this);