Skip to content
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-20090 Return partition/bloom information in WsDfu.DFUInfo #11420

Merged
merged 3 commits into from Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion esp/scm/ws_dfu.ecm
Expand Up @@ -42,6 +42,20 @@ ESPStruct SpaceItem
int64 SmallestSizeInt;
};

ESPStruct DFUFilePartition
{
int64 FieldMask;
ESParray<string> FieldNames;
};

ESPStruct DFUFileBloom
{
int64 FieldMask;
ESParray<string> FieldNames;
int64 Limit;
string Probability;
};

ESPStruct DFULogicalFile
{
string Prefix;
Expand Down Expand Up @@ -160,6 +174,8 @@ ESPStruct [nil_remove] DFUFileDetail
[min_ver("1.37"), json_inline(1)] string jsonInfo;
[min_ver("1.37")] binary binInfo;
[min_ver("1.38")] string PackageID;
[min_ver("1.39")] ESPstruct DFUFilePartition Partitions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this isn't an array should it be Partition instead of Partitions?

[min_ver("1.39")] ESPstruct DFUFileBloom Blooms;
};

ESPStruct DFUSpaceItem
Expand Down Expand Up @@ -793,7 +809,7 @@ ESPresponse [exceptions_inline, nil_remove] EraseHistoryResponse
// ===========================================================================
ESPservice [
auth_feature("DEFERRED"),
version("1.38"),
version("1.39"),
noforms,
exceptions_inline("./smc_xslt/exceptions.xslt")] WsDfu
{
Expand Down
73 changes: 73 additions & 0 deletions esp/services/ws_dfu/ws_dfuService.cpp
Expand Up @@ -1977,6 +1977,51 @@ void CWsDfuEx::getFilePartsOnClusters(IEspContext &context, const char* clusterR
}
}

void CWsDfuEx::parseFieldMask(unsigned __int64 fieldMask, unsigned &fieldCount, IntArray &fieldIndexArray)
{
if (fieldMask == 0)
return;

fieldCount++;
if (fieldMask % 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the most efficient way, but probably doesn't make much difference.

fieldIndexArray.append(fieldCount);
parseFieldMask(fieldMask/2, fieldCount, fieldIndexArray);
}

void CWsDfuEx::queryFieldNames(IEspContext &context, const char *fileName, const char *cluster,
unsigned __int64 fieldMask, StringArray &fieldNames)
{
if (!fileName || !*fileName)
throw MakeStringException(ECLWATCH_MISSING_PARAMS, "File name required");

Owned<IResultSetFactory> resultSetFactory = getSecResultSetFactory(context.querySecManager(), context.queryUser(), context.queryUserId(), context.queryPassword());
Owned<INewResultSet> result = resultSetFactory->createNewFileResultSet(fileName, cluster);
if (!result)
throw MakeStringException(ECLWATCH_INVALID_INPUT, "Failed to access FileResultSet for %s.", fileName);

unsigned fieldCount = 0;
IntArray fieldIndexArray;
parseFieldMask(fieldMask, fieldCount, fieldIndexArray);

const IResultSetMetaData& metaData = result->getMetaData();
unsigned totalColumns = (unsigned) metaData.getColumnCount();
if (fieldCount > totalColumns)
throw MakeStringException(ECLWATCH_INVALID_INPUT, "Invalid FieldMask %" I64F "u: total fields %u, ask for %u.",
fieldMask, totalColumns, fieldCount);

ForEachItemIn(i, fieldIndexArray)
{
int fieldIndex = fieldIndexArray.item(i);

SCMStringBuffer columnLabel;
if (metaData.hasSetTranslation(fieldIndex))
metaData.getNaturalColumnLabel(columnLabel, fieldIndex);
if (columnLabel.length() < 1)
metaData.getColumnLabel(columnLabel, fieldIndex);
fieldNames.append(columnLabel.str());
}
}

void CWsDfuEx::doGetFileDetails(IEspContext &context, IUserDescriptor *udesc, const char *name, const char *cluster,
const char *querySet, const char *query, const char *description, bool includeJsonTypeInfo, bool includeBinTypeInfo, IEspDFUFileDetail &FileDetails)
{
Expand Down Expand Up @@ -2107,6 +2152,34 @@ void CWsDfuEx::doGetFileDetails(IEspContext &context, IUserDescriptor *udesc, co
FileDetails.setOwner(df->queryAttributes().queryProp("@owner"));
FileDetails.setJobName(df->queryAttributes().queryProp("@job"));

if (version >= 1.39)
{
if (df->queryAttributes().hasProp("@partitionFieldMask"))
{
StringArray partitionFieldNames;
unsigned __int64 partitionFieldMask = df->queryAttributes().getPropInt64("@partitionFieldMask");
queryFieldNames(context, name, cluster, partitionFieldMask, partitionFieldNames);

IEspDFUFilePartition &partition = FileDetails.updatePartitions();
partition.setFieldMask(partitionFieldMask);
partition.setFieldNames(partitionFieldNames);
}

IPropertyTree *bloom = df->queryAttributes().queryPropTree("Bloom");
if (bloom)
{
StringArray bloomFieldNames;
unsigned __int64 bloomFieldMask = bloom->getPropInt64("@bloomFieldMask");
queryFieldNames(context, name, cluster, bloomFieldMask, bloomFieldNames);

IEspDFUFileBloom &blooms = FileDetails.updateBlooms();
blooms.setFieldMask(bloomFieldMask);
blooms.setFieldNames(bloomFieldNames);
blooms.setLimit(bloom->getPropInt64("@bloomLimit"));
blooms.setProbability(bloom->queryProp("@bloomProbability"));
}
}

//#14280
IDistributedSuperFile *sf = df->querySuperFile();
if(sf)
Expand Down
3 changes: 3 additions & 0 deletions esp/services/ws_dfu/ws_dfuService.hpp
Expand Up @@ -227,6 +227,9 @@ class CWsDfuEx : public CWsDfu
void getFilePartsOnClusters(IEspContext &context, const char* clusterReq, StringArray& clusters, IDistributedFile* df, IEspDFUFileDetail& FileDetails,
offset_t& mn, offset_t& mx, offset_t& sum, offset_t& count);
bool getQueryFile(const char *logicalName, const char *querySet, const char *queryID, IEspDFUFileDetail &fileDetails);
void queryFieldNames(IEspContext &context, const char *fileName, const char *cluster,
unsigned __int64 fieldMask, StringArray &fieldNames);
void parseFieldMask(unsigned __int64 fieldMask, unsigned &fieldCount, IntArray &fieldIndexArray);
bool attachServiceToDali() override
{
SpinBlock b(m_daliDetachedStateLock);
Expand Down