From eb3eb80e04f1c6fc1b1efda035b529b06be79a6b Mon Sep 17 00:00:00 2001 From: wangkx Date: Wed, 24 Jan 2024 09:18:39 -0500 Subject: [PATCH] HPCC-31163 Improve WU result TotalRowCount calls 1. Move the getResultTotalRowCountString() to esp lib. 2. Add hasTotalRowCount to CLocalWUResult. Signed-off-by: wangkx --- common/workunit/workunit.cpp | 11 +++-------- common/workunit/workunit.hpp | 2 +- esp/services/ws_workunits/ws_workunitsHelpers.cpp | 3 ++- esp/smc/SMCLib/WUXMLInfo.cpp | 11 ++++++++++- esp/smc/SMCLib/WUXMLInfo.hpp | 2 ++ 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/common/workunit/workunit.cpp b/common/workunit/workunit.cpp index 82cfaeca8a4..7faa1dffcf5 100644 --- a/common/workunit/workunit.cpp +++ b/common/workunit/workunit.cpp @@ -4748,7 +4748,7 @@ class CLocalWUResult : implements IWUResult, public CInterface virtual IStringVal& getResultXml(IStringVal &str, bool hidePasswords) const; virtual unsigned getResultFetchSize() const; virtual __int64 getResultTotalRowCount() const; - virtual StringBuffer& getResultTotalRowCountString(StringBuffer &str) const; + virtual bool hasTotalRowCount() const; virtual __int64 getResultRowCount() const; virtual void getResultDataset(IStringVal & ecl, IStringVal & defs) const; virtual IStringVal& getResultLogicalName(IStringVal &ecl) const; @@ -11217,14 +11217,9 @@ __int64 CLocalWUResult::getResultTotalRowCount() const return p->getPropInt64("totalRowCount", -1); } -StringBuffer &CLocalWUResult::getResultTotalRowCountString(StringBuffer &str) const +bool CLocalWUResult::hasTotalRowCount() const { - __int64 count = getResultTotalRowCount(); - if (count == -1) - str.append("[??? rows]"); - else - str.append('[').append(count).append(" rows]"); - return str; + return p->hasProp("totalRowCount"); } __int64 CLocalWUResult::getResultRowCount() const diff --git a/common/workunit/workunit.hpp b/common/workunit/workunit.hpp index 98590644e38..3e08f2d16eb 100644 --- a/common/workunit/workunit.hpp +++ b/common/workunit/workunit.hpp @@ -275,7 +275,7 @@ interface IConstWUResult : extends IInterface virtual IStringVal & getResultXml(IStringVal & str, bool hidePasswords) const = 0; virtual unsigned getResultFetchSize() const = 0; virtual __int64 getResultTotalRowCount() const = 0; - virtual StringBuffer & getResultTotalRowCountString(StringBuffer & str) const = 0; + virtual bool hasTotalRowCount() const = 0; virtual __int64 getResultRowCount() const = 0; virtual void getResultDataset(IStringVal & ecl, IStringVal & defs) const = 0; virtual IStringVal & getResultLogicalName(IStringVal & ecl) const = 0; diff --git a/esp/services/ws_workunits/ws_workunitsHelpers.cpp b/esp/services/ws_workunits/ws_workunitsHelpers.cpp index 00ecb28b988..a1c87b7b956 100644 --- a/esp/services/ws_workunits/ws_workunitsHelpers.cpp +++ b/esp/services/ws_workunits/ws_workunitsHelpers.cpp @@ -33,6 +33,7 @@ #include "rmtsmtp.hpp" #include "LogicFileWrapper.hpp" #include "TpWrapper.hpp" +#include "WUXMLInfo.hpp" #ifndef _NO_LDAP #include "ldapsecurity.ipp" @@ -1883,7 +1884,7 @@ void WsWuInfo::getResult(IConstWUResult &r, IArrayOf& results, un } else { - r.getResultTotalRowCountString(value); + getResultTotalRowCountString(r, value); if((r.getResultSequence()>=0) && (!filename.length() || (df && df->queryAttributes().hasProp("ECL")))) link.append(r.getResultSequence()); } diff --git a/esp/smc/SMCLib/WUXMLInfo.cpp b/esp/smc/SMCLib/WUXMLInfo.cpp index 4db31eaffe2..ce9ceec7d60 100644 --- a/esp/smc/SMCLib/WUXMLInfo.cpp +++ b/esp/smc/SMCLib/WUXMLInfo.cpp @@ -262,7 +262,7 @@ bool CWUXMLInfo::buildXmlResultList(IConstWorkUnit &wu,IPropertyTree& XMLStructu else { value.append(" "); - r.getResultTotalRowCountString(value); + getResultTotalRowCountString(r, value); link.append(r.getResultSequence()); } IPropertyTree* result = resultsTree->addPropTree("WUResult", createPTree(ipt_caseInsensitive)); @@ -368,3 +368,12 @@ void CWUXMLInfo::formatDuration(StringBuffer &ret, unsigned ms) else ret.appendf("%d.%03d", secs, ms); } + +extern WUXMLINFO_API StringBuffer &getResultTotalRowCountString(IConstWUResult &r, StringBuffer &str) +{ + if (r.hasTotalRowCount()) + str.append('[').append(r.getResultTotalRowCount()).append(" rows]"); + else + str.append("[??? rows]"); + return str; +} diff --git a/esp/smc/SMCLib/WUXMLInfo.hpp b/esp/smc/SMCLib/WUXMLInfo.hpp index acdd8b56fb1..5add18854a6 100644 --- a/esp/smc/SMCLib/WUXMLInfo.hpp +++ b/esp/smc/SMCLib/WUXMLInfo.hpp @@ -53,4 +53,6 @@ class WUXMLINFO_API CWUXMLInfo : public CInterface void buildXmlActiveWuidStatus(const char* ClusterName, IEspECLWorkunit& wuStructure); }; +extern WUXMLINFO_API StringBuffer& getResultTotalRowCountString(IConstWUResult& r, StringBuffer& str); + #endif // __CWUXMLInfo_HPP__