Skip to content

Commit

Permalink
Merge pull request #4084 from pnorbert/fix-query-minblocksinfo
Browse files Browse the repository at this point in the history
BlockIndex.Evaluate() made branch based on BP5 vs BP4. To support Cam…
  • Loading branch information
pnorbert committed Mar 12, 2024
2 parents 8801447 + 240598e commit 6a427f2
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions source/adios2/toolkit/query/BlockIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,27 @@ class BlockIndex
throw std::runtime_error("Unable to evaluate query! Invalid Variable detected");
}

if (m_IdxReader.m_EngineType.find("5") != std::string::npos) // a bp5 reader
RunBP5Stat(query, resultBlockIDs);
else
RunBP4Stat(query, resultBlockIDs);
}

void RunBP5Stat(const QueryVar &query, std::vector<BlockHit> &hitBlocks)
{
size_t currStep = m_IdxReader.CurrentStep();
adios2::Dims currShape = m_VarPtr->Shape();
if (!query.IsSelectionValid(currShape))
return;

auto MinBlocksInfo = m_IdxReader.MinBlocksInfo(*m_VarPtr, currStep);
if (!MinBlocksInfo)
{ // no info, can't do anything
return;

if (MinBlocksInfo != nullptr)
{
RunStatMinBlocksInfo(query, MinBlocksInfo, resultBlockIDs);
delete MinBlocksInfo;
}
else
{
RunStatBlocksInfo(query, currStep, resultBlockIDs);
}
}

void RunStatMinBlocksInfo(const QueryVar &query, const adios2::MinVarInfo *MinBlocksInfo,
std::vector<BlockHit> &hitBlocks)
{
for (auto &blockInfo : MinBlocksInfo->BlocksInfo)
{
T bmin = *(T *)&blockInfo.MinMax.MinUnion;
Expand Down Expand Up @@ -78,16 +81,11 @@ class BlockIndex
hitBlocks.push_back(BlockHit(blockInfo.BlockID));
}
}
delete MinBlocksInfo;
}

void RunBP4Stat(const QueryVar &query, std::vector<BlockHit> &hitBlocks)
void RunStatBlocksInfo(const QueryVar &query, const size_t currStep,
std::vector<BlockHit> &hitBlocks)
{
size_t currStep = m_IdxReader.CurrentStep();
adios2::Dims currShape = m_VarPtr->Shape();
if (!query.IsSelectionValid(currShape))
return;

std::vector<typename adios2::core::Variable<T>::BPInfo> varBlocksInfo =
m_IdxReader.BlocksInfo(*m_VarPtr, currStep);

Expand Down

0 comments on commit 6a427f2

Please sign in to comment.