浏览代码

HPCC-8556 Refactor const char * query functions from helpers

Change queryAlgorithm and queryCluster to complete the set.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 年之前
父节点
当前提交
5080da3fc7

+ 2 - 2
ecl/hqlcpp/hqlhtcpp.cpp

@@ -9563,7 +9563,7 @@ void HqlCppTranslator::buildClusterHelper(BuildCtx & ctx, IHqlExpression * expr)
         return;
 
     BuildCtx funcctx(ctx);
-    funcctx.addQuotedCompound("virtual const char * queryCluster(unsigned idx)");
+    funcctx.addQuotedCompound("virtual const char * getCluster(unsigned idx)");
 
     BuildCtx switchctx(funcctx);
     OwnedHqlExpr var = createVariable("idx", LINK(unsignedType));
@@ -16009,7 +16009,7 @@ ABoundActivity * HqlCppTranslator::doBuildActivitySort(BuildCtx & ctx, IHqlExpre
         flags.append("|TAFconstant");
 
     if (method)
-        doBuildVarStringFunction(instance->startctx, "queryAlgorithm", method);
+        doBuildVarStringFunction(instance->startctx, "getAlgorithm", method);
 
     if (!streq(flags.str(), "|TAFconstant"))
         instance->classctx.addQuotedF("virtual unsigned getAlgorithmFlags() { return %s; }", flags.str()+1);

+ 3 - 3
ecl/hthor/hthor.cpp

@@ -309,7 +309,7 @@ ClusterWriteHandler *createClusterWriteHandler(IAgentContext &agent, IHThorIndex
     unsigned clusterIdx = 0;
     while(true)
     {
-        char const * cluster = iwHelper ? iwHelper->queryCluster(clusterIdx++) : dwHelper->queryCluster(clusterIdx++);
+        OwnedRoxieString cluster(iwHelper ? iwHelper->getCluster(clusterIdx++) : dwHelper->getCluster(clusterIdx++));
         if(!cluster)
             break;
         if(!clusterHandler)
@@ -3698,7 +3698,7 @@ void CHThorGroupSortActivity::createSorter()
     }
     unsigned flags = algo->getAlgorithmFlags();
     sorterIsConst = ((flags & TAFconstant) != 0);
-    char const * algoname = algo->queryAlgorithm();
+    OwnedRoxieString algoname(algo->getAlgorithm());
     if(!algoname)
     {
         if((flags & TAFunstable) != 0)
@@ -3722,7 +3722,7 @@ void CHThorGroupSortActivity::createSorter()
     else
     {
         StringBuffer sb;
-        sb.appendf("Ignoring unsupported sort order algorithm '%s', using default", algoname);
+        sb.appendf("Ignoring unsupported sort order algorithm '%s', using default", algoname.get());
         agent.addWuException(sb.str(),0,ExceptionSeverityWarning,"hthor");
         if((flags & TAFunstable) != 0)
             sorter.setown(new CQuickSorter(helper.queryCompare(), queryRowManager(), InitialSortElements, CommitStep));

+ 10 - 10
roxie/ccd/ccdserver.cpp

@@ -7950,13 +7950,13 @@ public:
             {
                 sorter.clear();
                 IHThorAlgorithm *sortMethod = static_cast<IHThorAlgorithm *>(helper.selectInterface(TAIalgorithm_1));
-                const char *useAlgorithm = sortMethod->queryAlgorithm();
+                OwnedRoxieString useAlgorithm(sortMethod->getAlgorithm());
                 if (useAlgorithm)
                 {
                     if (stricmp(useAlgorithm, "quicksort")==0)
                     {
                         if (sortFlags & TAFstable)
-                            throw MakeStringException(ROXIE_UNKNOWN_ALGORITHM, "Invalid stable sort algorithm %s requested", useAlgorithm);
+                            throw MakeStringException(ROXIE_UNKNOWN_ALGORITHM, "Invalid stable sort algorithm %s requested", useAlgorithm.get());
                         sorter.setown(new CQuickSortAlgorithm(compare));
                     }
                     else if (stricmp(useAlgorithm, "heapsort")==0)
@@ -7965,7 +7965,7 @@ public:
                         sorter.setown(new CInsertionSortAlgorithm(compare, &ctx->queryRowManager(), activityId));
                     else
                     {
-                        WARNLOG(ROXIE_UNKNOWN_ALGORITHM, "Ignoring unsupported sort order algorithm '%s', using default", useAlgorithm);
+                        WARNLOG(ROXIE_UNKNOWN_ALGORITHM, "Ignoring unsupported sort order algorithm '%s', using default", useAlgorithm.get());
                         if (sortFlags & TAFunstable)
                             sorter.setown(new CQuickSortAlgorithm(compare));
                         else
@@ -8012,19 +8012,19 @@ public:
                 sortAlgorithm = unknownSort;
             else
             {
-                const char *useAlgorithm = sortMethod->queryAlgorithm();
+                OwnedRoxieString useAlgorithm(sortMethod->getAlgorithm());
                 if (useAlgorithm)
                 {
                     if (stricmp(useAlgorithm, "quicksort")==0)
                     {
                         if (sortFlags & TAFstable)
-                            throw MakeStringException(ROXIE_UNKNOWN_ALGORITHM, "Invalid stable sort algorithm %s requested", useAlgorithm);
+                            throw MakeStringException(ROXIE_UNKNOWN_ALGORITHM, "Invalid stable sort algorithm %s requested", useAlgorithm.get());
                         sortAlgorithm = quickSort;
                     }
                     else if (stricmp(useAlgorithm, "spillingquicksort")==0)
                     {
                         if (sortFlags & TAFstable)
-                            throw MakeStringException(ROXIE_UNKNOWN_ALGORITHM, "Invalid stable sort algorithm %s requested", useAlgorithm);
+                            throw MakeStringException(ROXIE_UNKNOWN_ALGORITHM, "Invalid stable sort algorithm %s requested", useAlgorithm.get());
                         sortAlgorithm = spillingQuickSort;
                     }
                     else if (stricmp(useAlgorithm, "heapsort")==0)
@@ -8033,7 +8033,7 @@ public:
                         sortAlgorithm = insertionSort;
                     else
                     {
-                        WARNLOG(ROXIE_UNKNOWN_ALGORITHM, "Ignoring unsupported sort order algorithm '%s', using default", useAlgorithm);
+                        WARNLOG(ROXIE_UNKNOWN_ALGORITHM, "Ignoring unsupported sort order algorithm '%s', using default", useAlgorithm.get());
                         if (sortFlags & TAFunstable)
                             sortAlgorithm = quickSort;
                         else
@@ -10680,7 +10680,7 @@ protected:
         unsigned clusterIdx = 0;
         while(true)
         {
-            char const * cluster = helper.queryCluster(clusterIdx);
+            OwnedRoxieString cluster(helper.getCluster(clusterIdx));
             if(!cluster)
                 break;
             clusters.append(cluster);
@@ -11111,7 +11111,7 @@ class CRoxieServerIndexWriteActivity : public CRoxieServerInternalSinkActivity,
         unsigned clusterIdx = 0;
         while(true)
         {
-            char const * cluster = helper.queryCluster(clusterIdx);
+            OwnedRoxieString cluster(helper.getCluster(clusterIdx));
             if(!cluster)
                 break;
             clusters.append(cluster);
@@ -25894,7 +25894,7 @@ public:
         return &testMeta; 
     }
     virtual unsigned getAlgorithmFlags() { return TAFunstable; }
-    virtual const char * queryAlgorithm() { return sortAlgorithm; }
+    virtual const char * getAlgorithm() { return sortAlgorithm; }
 };
 extern "C" IHThorArg * sortActivityTestFactory() { return new SortActivityTest; }
 

+ 3 - 3
rtl/include/eclhelper.hpp

@@ -1142,7 +1142,7 @@ struct IHThorIndexWriteArg : public IHThorArg
     virtual unsigned getExpiryDays() = 0;
     virtual void getUpdateCRCs(unsigned & eclCRC, unsigned __int64 & totalCRC) = 0;
     virtual unsigned getFormatCrc() = 0;
-    virtual const char * queryCluster(unsigned idx) = 0;        // result only valid until next call.
+    virtual const char * getCluster(unsigned idx) = 0;
     virtual bool getIndexLayout(size32_t & _retLen, void * & _retData) = 0;
     virtual bool getIndexMeta(size32_t & lenName, char * & name, size32_t & lenValue, char * & value, unsigned idx) = 0;
     virtual unsigned getWidth() = 0;                // only guaranteed present if TIWhaswidth defined
@@ -1187,7 +1187,7 @@ struct IHThorDiskWriteArg : public IHThorArg
     virtual void getUpdateCRCs(unsigned & eclCRC, unsigned __int64 & totalCRC) = 0;
     virtual void getEncryptKey(size32_t & keyLen, void * & key) = 0;
     virtual unsigned getFormatCrc() = 0;
-    virtual const char * queryCluster(unsigned idx) = 0;        // result only valid until next call.
+    virtual const char * getCluster(unsigned idx) = 0;        // result only valid until next call.
 };
 
 struct IHThorFilterArg : public IHThorArg
@@ -1536,7 +1536,7 @@ struct IHThorSortArg : public IHThorArg
 struct IHThorAlgorithm : public IInterface
 {
     virtual unsigned getAlgorithmFlags() = 0;
-    virtual const char * queryAlgorithm() = 0;
+    virtual const char * getAlgorithm() = 0;
 };
 
 typedef IHThorSortArg IHThorSortedArg;

+ 7 - 7
rtl/include/eclhelper_base.hpp

@@ -345,7 +345,7 @@ public:
     virtual unsigned getExpiryDays()                        { return 0; }
     virtual void getUpdateCRCs(unsigned & eclCRC, unsigned __int64 & totalCRC)  { }
     virtual unsigned getFormatCrc() = 0;
-    virtual const char * queryCluster(unsigned idx) { return NULL; }
+    virtual const char * getCluster(unsigned idx) { return NULL; }
     virtual bool getIndexLayout(size32_t & _retLen, void * & _retData) { return false; }
     virtual bool getIndexMeta(size32_t & lenName, char * & name, size32_t & lenValue, char * & value, unsigned idx) { return false; }
     virtual unsigned getWidth() { return 0; }
@@ -454,7 +454,7 @@ class CThorDiskWriteArg : public CThorArg, implements IHThorDiskWriteArg
     virtual unsigned getExpiryDays()                        { return 0; }
     virtual void getUpdateCRCs(unsigned & eclCRC, unsigned __int64 & totalCRC)  { }
     virtual void getEncryptKey(size32_t & keyLen, void * & key) { keyLen = 0; key = 0; }
-    virtual const char * queryCluster(unsigned idx)         { return NULL; }
+    virtual const char * getCluster(unsigned idx)         { return NULL; }
 };
 
 class CThorPipeReadArg : public CThorArg, implements IHThorPipeReadArg
@@ -1017,7 +1017,7 @@ class CThorSpillArg : public CThorArg, implements IHThorSpillArg
     virtual unsigned getExpiryDays()                        { return 0; }
     virtual void getUpdateCRCs(unsigned & eclCRC, unsigned __int64 & totalCRC)  { }
     virtual void getEncryptKey(size32_t & keyLen, void * & key) { keyLen = 0; key = 0; }
-    virtual const char * queryCluster(unsigned idx)         { return NULL; }
+    virtual const char * getCluster(unsigned idx)         { return NULL; }
 };
 
 
@@ -1542,7 +1542,7 @@ class CThorSortArg : public CThorArg, implements IHThorSortArg, implements IHTho
     virtual const char * getSortedFilename()            { return NULL; }
     virtual ICompare * queryCompareLeftRight()          { return NULL; }
     virtual unsigned getAlgorithmFlags()                { return TAFconstant; }
-    virtual const char * queryAlgorithm()               { return NULL; }
+    virtual const char * getAlgorithm()               { return NULL; }
     virtual ICompare * queryCompareSerializedRow()      { return NULL; }
 };
 
@@ -2278,7 +2278,7 @@ class CThorCsvWriteArg : public CThorArg, implements IHThorCsvWriteArg
     virtual unsigned getExpiryDays()                        { return 0; }
     virtual void getUpdateCRCs(unsigned & eclCRC, unsigned __int64 & totalCRC)  { }
     virtual void getEncryptKey(size32_t & keyLen, void * & key) { keyLen = 0; key = 0; }
-    virtual const char * queryCluster(unsigned idx)         { return NULL; }
+    virtual const char * getCluster(unsigned idx)         { return NULL; }
 };
 
 
@@ -2373,7 +2373,7 @@ class CThorXmlWriteArg : public CThorArg, implements IHThorXmlWriteArg
 
     virtual const char * getXmlIteratorPath()        { return NULL; }             // supplies the prefix and suffix for a row
     virtual const char * getHeader()                 { return NULL; }
-    virtual const char * queryFooter()                 { return NULL; }
+    virtual const char * getFooter()                 { return NULL; }
     virtual unsigned getXmlFlags()                     { return 0; }
 
     virtual int getSequence()                               { return -3; }
@@ -2382,7 +2382,7 @@ class CThorXmlWriteArg : public CThorArg, implements IHThorXmlWriteArg
     virtual unsigned getExpiryDays()                        { return 0; }
     virtual void getUpdateCRCs(unsigned & eclCRC, unsigned __int64 & totalCRC)  { }
     virtual void getEncryptKey(size32_t & keyLen, void * & key) { keyLen = 0; key = 0; }
-    virtual const char * queryCluster(unsigned idx)         { return NULL; }
+    virtual const char * getCluster(unsigned idx)         { return NULL; }
 };
 
 

+ 8 - 2
thorlcr/activities/indexwrite/thindexwrite.cpp

@@ -68,8 +68,14 @@ public:
         singlePartKey = 0 != (helper->getFlags() & TIWsmall) || dlfn.isExternal();
         clusters.kill();
         unsigned idx=0;
-        while (helper->queryCluster(idx))
-            clusters.append(helper->queryCluster(idx++));
+        while (true)
+        {
+            OwnedRoxieString cluster(helper->getCluster(idx));
+            if(!cluster)
+                break;
+            clusters.append(cluster);
+            idx++;
+        }
         IArrayOf<IGroup> groups;
         if (singlePartKey)
         {

+ 4 - 4
thorlcr/activities/msort/thmsort.cpp

@@ -41,11 +41,11 @@ public:
     {
         IHThorSortArg *helper = (IHThorSortArg *)queryHelper();
         IHThorAlgorithm *algo = static_cast<IHThorAlgorithm *>(helper->selectInterface(TAIalgorithm_1));
-        char const *algoname = algo->queryAlgorithm();
+        OwnedRoxieString algoname = algo->getAlgorithm();
         unsigned flags = algo->getAlgorithmFlags();
         if (algoname && (0 != stricmp(algoname, "quicksort")))
         {
-            Owned<IException> e = MakeActivityException(this, 0, "Ignoring, unsupported sort order algorithm '%s'", algoname);
+            Owned<IException> e = MakeActivityException(this, 0, "Ignoring, unsupported sort order algorithm '%s'", algoname.get());
             reportExceptionToWorkunit(container.queryJob().queryWorkUnit(), e);
         }
     }
@@ -77,11 +77,11 @@ protected:
     {
         IHThorSortArg *helper = (IHThorSortArg *)queryHelper();
         IHThorAlgorithm *algo = static_cast<IHThorAlgorithm *>(helper->selectInterface(TAIalgorithm_1));
-        char const *algoname = algo->queryAlgorithm();
+        OwnedRoxieString algoname(algo->getAlgorithm());
         unsigned flags = algo->getAlgorithmFlags();
         if (algoname && (0 != stricmp(algoname, "quicksort")))
         {
-            Owned<IException> e = MakeActivityException(this, 0, "Ignoring, unsupported sort order algorithm '%s'", algoname);
+            Owned<IException> e = MakeActivityException(this, 0, "Ignoring, unsupported sort order algorithm '%s'", algoname.get());
             reportExceptionToWorkunit(container.queryJob().queryWorkUnit(), e);
         }
     }

+ 8 - 2
thorlcr/activities/thdiskbase.cpp

@@ -247,8 +247,14 @@ void CWriteMasterBase::init()
         bool overwriteok = 0!=(TDWoverwrite & diskHelperBase->getFlags());
         
         unsigned idx=0;
-        while (diskHelperBase->queryCluster(idx))
-            clusters.append(diskHelperBase->queryCluster(idx++));
+        while (true)
+        {
+            OwnedRoxieString cluster(diskHelperBase->getCluster(idx));
+            if(!cluster)
+                break;
+            clusters.append(cluster);
+            idx++;
+        }
         IArrayOf<IGroup> groups;
         fillClusterArray(container.queryJob(), fname, clusters, groups);
         fileDesc.setown(queryThorFileManager().create(container.queryJob(), fname, clusters, groups, overwriteok, diskHelperBase->getFlags()));