Skip to content

Commit

Permalink
HPCC-32873 Fix bool default, common up, separate scale
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Smith <[email protected]>
  • Loading branch information
jakesmith committed Oct 31, 2024
1 parent c4739fc commit 346b050
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions system/jlib/jfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7899,18 +7899,19 @@ static unsigned jFileHookId = 0;


// Declare the array with an anonymous struct
enum PlaneAttrType { boolean, integerK };
enum PlaneAttrType { boolean, integer };
struct PlaneAttributeInfo
{
PlaneAttrType type;
size32_t scale;
bool isExpert;
const char *name;
};
static const std::array<PlaneAttributeInfo, PlaneAttributeCount> planeAttributeInfo = {{
{ PlaneAttrType::integerK, false, "blockedFileIOKB" }, // enum PlaneAttributeType::BlockedSequentialIO {0}
{ PlaneAttrType::integerK, false, "blockedRandomIOKB" }, // enum PlaneAttributeType::blockedRandomIOKB {1}
{ PlaneAttrType::boolean, true, "fileSyncWriteClose" }, // enum PlaneAttributeType::fileSyncWriteClose {2}
{ PlaneAttrType::boolean, true, "concurrentWriteSupport" } // enum PlaneAttributeType::concurrentWriteSupport {3}
{ PlaneAttrType::integer, 1024, false, "blockedFileIOKB" }, // enum PlaneAttributeType::BlockedSequentialIO {0}
{ PlaneAttrType::integer, 1024, false, "blockedRandomIOKB" }, // enum PlaneAttributeType::blockedRandomIOKB {1}
{ PlaneAttrType::boolean, 0, true, "fileSyncWriteClose" }, // enum PlaneAttributeType::fileSyncWriteClose {2}
{ PlaneAttrType::boolean, 0, true, "concurrentWriteSupport" } // enum PlaneAttributeType::concurrentWriteSupport {3}
}};

// {prefix, {key1: value1, key2: value2, ...}}
Expand All @@ -7934,30 +7935,32 @@ MODULE_INIT(INIT_PRIORITY_STANDARD)
auto &values = element.second;
for (unsigned propNum=0; propNum<PlaneAttributeType::PlaneAttributeCount; ++propNum)
{
const PlaneAttributeInfo &attrInfo = planeAttributeInfo[propNum];
std::string prop;
if (planeAttributeInfo[propNum].isExpert)
if (attrInfo.isExpert)
prop += "expert/";
prop += "@" + std::string(planeAttributeInfo[propNum].name);
switch (planeAttributeInfo[propNum].type)
prop += "@" + std::string(attrInfo.name);
switch (attrInfo.type)
{
case PlaneAttrType::integerK:
case PlaneAttrType::integer:
case PlaneAttrType::boolean: // handling is same as integer
{
unsigned __int64 value = plane.getPropInt64(prop.c_str(), unsetPlaneAttrValue);
values[propNum] = (unsetPlaneAttrValue != value) ? value * 1024 : value;
break;
}
case PlaneAttrType::boolean:
{
if (plane.hasProp(prop.c_str()))
values[propNum] = plane.getPropBool(prop.c_str()) ? 1 : 0;
else if (FileSyncWriteClose == propNum) // temporary (check legacy fileSyncMaxRetrySecs too), purely for short term backward compatibility (see HPCC-xxxx)
if (unsetPlaneAttrValue != value)
{
if (attrInfo.scale)
{
dbgassertex(PlaneAttrType::integer == attrInfo.type);
value *= attrInfo.scale;
}
}
else if (FileSyncWriteClose == propNum) // temporary (if FileSyncWriteClose and unset, check legacy fileSyncMaxRetrySecs), purely for short term backward compatibility (see HPCC-32757)
{
unsigned __int64 v = plane.getPropInt64("expert/@fileSyncMaxRetrySecs", unsetPlaneAttrValue);
// NB: fileSyncMaxRetrySecs==0 is treated as set/enabled
values[FileSyncWriteClose] = v != unsetPlaneAttrValue ? 1 : 0;
value = v != unsetPlaneAttrValue ? 1 : 0;
}
else
values[propNum] = false;
values[propNum] = value;
break;
}
default:
Expand Down

0 comments on commit 346b050

Please sign in to comment.