Browse Source

HPCC-8867 - Fill in @kind file attribute for all files

The @kind meta field was only filled for keys.
Useful also to be able to distinguis between flag,xml & csv

Signed-off-by: Jake Smith <jake.smith@lexisnexis.com>
Jake Smith 11 years ago
parent
commit
e2a9c0d990

+ 6 - 3
dali/dfu/dfurun.cpp

@@ -1057,6 +1057,7 @@ public:
         cAbortNotify abortnotify;
         wu->subscribeAbort(&abortnotify);
         bool iskey=false;
+        StringAttr kind;
         bool multiclusterinsert = false;
         bool multiclustermerge = false;
         bool useserverreplicate = false;
@@ -1129,16 +1130,15 @@ public:
                             }
                         }
                     }
-                    const char * kind;
                     if (foreigncopy) {
                         foreignfdesc.setown(queryDistributedFileDirectory().getFileDescriptor(tmp.str(),foreignuserdesc,foreigndalinode));
                         if (!foreignfdesc) {
                             StringBuffer s;
                             throw MakeStringException(-1,"Source file %s could not be found in Dali %s",tmp.str(),foreigndalinode->endpoint().getUrlStr(s).str());
                         }
-                        kind = foreignfdesc->queryProperties().queryProp("@kind");
+                        kind.set(foreignfdesc->queryProperties().queryProp("@kind"));
                         oldRoxiePrefix.set(foreignfdesc->queryProperties().queryProp("@roxiePrefix"));
-                        iskey = kind&&(strcmp(kind,"key")==0);
+                        iskey = strsame("key", kind);
                         if (destination->getWrap()||iskey)
                             destination->setNumPartsOverride(foreignfdesc->numParts());
                         if (options->getPush()) {// need to set ftslave location
@@ -1159,6 +1159,7 @@ public:
                             throw MakeStringException(-1,"Source file %s could not be found",tmp.str());
                         oldRoxiePrefix.set(srcFile->queryAttributes().queryProp("@roxiePrefix"));
                         iskey = isFileKey(srcFile);
+                        kind.set(srcFile->queryAttributes().queryProp("@kind"));
                         if (destination->getWrap()||(iskey&&(cmd==DFUcmd_copy)))    // keys default wrap for copy
                             destination->setNumPartsOverride(srcFile->numParts());
                         if (options->getSubfileCopy()) 
@@ -1258,6 +1259,8 @@ public:
                                 fdesc->queryProperties().setProp("@roxiePrefix", newroxieprefix.str());
                             if (iskey)
                                 fdesc->queryProperties().setProp("@kind", "key");
+                            else if (kind.length()) // JCSMORE may not really need seperate if (iskey) line above
+                                fdesc->queryProperties().setProp("@kind", kind);
                             if (multiclusterinsert||multiclustermerge) 
                                 multifdesc.setown(fdesc.getClear());
                             else

+ 3 - 0
ecl/hthor/hthor.cpp

@@ -735,6 +735,7 @@ void CHThorDiskWriteActivity::setFormat(IFileDescriptor * desc)
     const char *recordECL = helper.queryRecordECL();
     if (recordECL && *recordECL)
         desc->queryProperties().setProp("ECL", recordECL);
+    desc->queryProperties().setProp("@kind", "flat");
 }
 
 void CHThorDiskWriteActivity::checkSizeLimit()
@@ -867,6 +868,7 @@ void CHThorCsvWriteActivity::setFormat(IFileDescriptor * desc)
     desc->queryProperties().setProp("@csvTerminate", rs.setown(csvInfo->getTerminator(0)));
     desc->queryProperties().setProp("@csvEscape", rs.setown(csvInfo->getEscape(0)));
     desc->queryProperties().setProp("@format","utf8n");
+    desc->queryProperties().setProp("@kind", "csv");
 }
 
 //=====================================================================================================
@@ -929,6 +931,7 @@ void CHThorXmlWriteActivity::setFormat(IFileDescriptor * desc)
 {
     desc->queryProperties().setProp("@format","utf8n");
     desc->queryProperties().setProp("@rowTag",rowTag.str());
+    desc->queryProperties().setProp("@kind", "xml");
 }
 
 //=====================================================================================================

+ 3 - 0
roxie/ccd/ccdserver.cpp

@@ -10852,6 +10852,7 @@ public:
         const char *recordECL = helper.queryRecordECL();
         if (recordECL && *recordECL)
             fileProps.setProp("ECL", recordECL);
+        fileProps.setProp("@kind", "flat"); // default, derivitives may override
     }
 
     virtual IUserDescriptor *queryUserDescriptor() const
@@ -10937,6 +10938,7 @@ public:
         props.setProp("@csvQuote", rs.setown(csvParameters->getQuote(0)));
         props.setProp("@csvTerminate", rs.setown(csvParameters->getTerminator(0)));
         props.setProp("@csvEscape", rs.setown(csvParameters->getEscape(0)));
+        props.setProp("@kind", "csv");
     }
 
     virtual bool isOutputTransformed() const { return true; }
@@ -11008,6 +11010,7 @@ public:
         CRoxieServerDiskWriteActivity::setFileProperties(desc);
         desc->queryProperties().setProp("@format","utf8n");
         desc->queryProperties().setProp("@rowTag",rowTag.get());
+        desc->queryProperties().setProp("@kind", "xml");
     }
 
     virtual bool isOutputTransformed() const { return true; }

+ 1 - 1
thorlcr/activities/diskwrite/thdiskwrite.cpp

@@ -60,8 +60,8 @@ public:
     void done()
     {
         IPropertyTree &props = fileDesc->queryProperties();
-        props.setPropBool("@csv", true);
         props.setProp("@format", "utf8n");
+        props.setProp("@kind", "csv");
         IHThorCsvWriteArg *helper=(IHThorCsvWriteArg *)queryHelper();
         ICsvParameters *csvParameters = helper->queryCsvParameters();
         StringBuffer separator;

+ 1 - 0
thorlcr/activities/keydiff/thkeydiff.cpp

@@ -76,6 +76,7 @@ public:
         OwnedRoxieString outputName(helper->getOutputName());
         fillClusterArray(container.queryJob(), outputName, clusters, groups);
         patchDesc.setown(queryThorFileManager().create(container.queryJob(), outputName, clusters, groups, 0 != (KDPoverwrite & helper->getFlags()), 0, !local, width));
+        patchDesc->queryProperties().setProp("@kind", "keydiff");
     }
     void serializeSlaveData(MemoryBuffer &dst, unsigned slave)
     {

+ 1 - 1
thorlcr/activities/spill/thspill.cpp

@@ -57,7 +57,7 @@ public:
             props.setPropBool("@blockCompressed", true);        
         if (0 != (helper->getFlags() & TDXgrouped))
             fileDesc->queryProperties().setPropBool("@grouped", true);
-
+        props.setProp("@kind", "flat");
         if (container.queryOwner().queryOwner() && (!container.queryOwner().isGlobal())) // I am in a child query
         { // do early, because this will be local act. and will not come back to master until end of owning graph.
             container.queryTempHandler()->registerFile(fname, container.queryOwner().queryGraphId(), helper->getTempUsageCount(), TDXtemporary & helper->getFlags(), getDiskOutputKind(helper->getFlags()), &clusters);

+ 1 - 0
thorlcr/activities/thdiskbase.cpp

@@ -283,6 +283,7 @@ void CWriteMasterBase::init()
             blockCompressed = true;
         if (blockCompressed)
             props.setPropBool("@blockCompressed", true);
+        props.setProp("@kind", "flat");
         if (TAKdiskwrite == container.getKind() && (0 != (diskHelperBase->getFlags() & TDXtemporary)) && container.queryOwner().queryOwner() && (!container.queryOwner().isGlobal())) // I am in a child query
         { // do early, because this will be local act. and will not come back to master until end of owning graph.
             publish();

+ 1 - 0
thorlcr/activities/xmlwrite/thxmlwrite.cpp

@@ -52,6 +52,7 @@ public:
         }
         props.setProp("@rowTag", rowTag.str());
         props.setProp("@format", "utf8n");
+        props.setProp("@kind", "xml");
     }
 };
 

+ 1 - 0
thorlcr/graph/thgraphmaster.cpp

@@ -1470,6 +1470,7 @@ void CJobMaster::saveSpills()
             fillClusterArray(*this, tmpName, clusters, groups);
             Owned<IFileDescriptor> fileDesc = queryThorFileManager().create(*this, tmpName, clusters, groups, true, TDXtemporary|TDWnoreplicate);
             fileDesc->queryProperties().setPropBool("@pausefile", true); // JCSMORE - mark to keep, may be able to distinguish via other means
+            fileDesc->queryProperties().setProp("@kind", "flat");
 
             IPropertyTree &props = fileDesc->queryProperties();
             props.setPropBool("@owned", true);