-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC-31028 Use cost_type internally for consistency #18154
Conversation
https://track.hpccsystems.com/browse/HPCC-31028 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - looks good, 1 issue with getFileAccessCost
@@ -353,7 +353,7 @@ static void DeepAssign(IEspContext &context, IConstDFUWorkUnit *src, IEspDFUWork | |||
if(secs > 0) | |||
dest.setSecsLeft(secs); | |||
dest.setPercentDone(prog->getPercentDone()); | |||
dest.setFileAccessCost(prog->getFileAccessCost()); | |||
dest.setFileAccessCost(cost_type2money(prog->getFileAccessCost())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IConstDFUprogress::getFileAccessCost is still returning a double.
dali/base/dadfs.cpp
Outdated
@@ -13454,14 +13454,14 @@ IPropertyTreeIterator *deserializeFileAttrIterator(MemoryBuffer& mb, unsigned nu | |||
else | |||
sizeDiskSize = file->getPropInt64(getDFUQResultFieldName(DFUQRForigsize), 0); | |||
double sizeGB = sizeDiskSize / ((double)1024 * 1024 * 1024); | |||
cost_type atRestCost = money2cost_type(calcFileAtRestCost(nodeGroup, sizeGB, fileAgeDays)); | |||
file->setPropInt64(getDFUQResultFieldName(DFUQRFatRestCost), atRestCost); | |||
cost_type atRestCostType = calcFileAtRestCost(nodeGroup, sizeGB, fileAgeDays); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial: don't think this variable name needs/is helped by having suffix "Type", and similar below.
{ | ||
CriticalBlock block(parent->crit); | ||
queryRoot()->setPropReal("@fileAccessCost", fileAccessCost); | ||
queryRoot()->setPropInt64("@fileAccessCost", fileAccessCost); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relaed to comment in ws_fsService.cpp.
The corresponding get function in this class is (unchanged):
double getFileAccessCost() const
{
CriticalBlock block(parent->crit);
return queryRoot()->getPropInt64("@fileAccessCost");
}
that looks like a pre-existing bug. It was set as a real, but retrieved as an int (then cast to a double on return).
Costs have been represented as double in some places in the code and cost_type in other places. The use of both double and cost_type internally for costs has made the code more difficult to understand and maintain. It has lead to some bugs. This commit makes all internal representation of cost in the code as cost_type. The cost_type is only converted to double when returning costs externally via ESP services. Signed-off-by: Shamser Ahmed <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - 1 minor comment, but looks good, please fix and squash.
dali/base/dadfs.cpp
Outdated
@@ -191,18 +191,18 @@ static IPropertyTree *getCostPropTree(const char *cluster) | |||
} | |||
} | |||
|
|||
extern da_decl double calcFileAtRestCost(const char * cluster, double sizeGB, double fileAgeDays) | |||
extern da_decl cost_type calcFileAtRestCost(const char * cluster, double sizeGB, double fileAgeDays) | |||
{ | |||
Owned<const IPropertyTree> costPT = getCostPropTree(cluster); | |||
|
|||
if (costPT==nullptr) | |||
return 0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be changed from returning a floating point number to an integer - i.e. return 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also on line 210 in calcFileAccessCost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - looks good
Type of change:
Checklist:
Smoketest:
Testing: