Skip to content

Commit

Permalink
Merge pull request #18255 from wangkx/h31163
Browse files Browse the repository at this point in the history
HPCC-31163 Improve WU result TotalRowCount calls

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Jan 26, 2024
2 parents b9a3ce4 + eb3eb80 commit 108632e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
11 changes: 3 additions & 8 deletions common/workunit/workunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/workunit/workunit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion esp/services/ws_workunits/ws_workunitsHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "rmtsmtp.hpp"
#include "LogicFileWrapper.hpp"
#include "TpWrapper.hpp"
#include "WUXMLInfo.hpp"

#ifndef _NO_LDAP
#include "ldapsecurity.ipp"
Expand Down Expand Up @@ -1883,7 +1884,7 @@ void WsWuInfo::getResult(IConstWUResult &r, IArrayOf<IEspECLResult>& results, un
}
else
{
r.getResultTotalRowCountString(value);
getResultTotalRowCountString(r, value);
if((r.getResultSequence()>=0) && (!filename.length() || (df && df->queryAttributes().hasProp("ECL"))))
link.append(r.getResultSequence());
}
Expand Down
11 changes: 10 additions & 1 deletion esp/smc/SMCLib/WUXMLInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions esp/smc/SMCLib/WUXMLInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__

0 comments on commit 108632e

Please sign in to comment.