Skip to content

Commit

Permalink
HPCC-32856 CKeyCursor should link parent nodes as well as current node
Browse files Browse the repository at this point in the history
Changes following review

Signed-off-by: Richard Chapman <[email protected]>
  • Loading branch information
richardkchapman committed Nov 20, 2024
1 parent 90d15b0 commit ec87f79
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions system/jhtree/jhtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,7 @@ bool CKeyCursor::_next(IContextLogger *ctx)
if (node != NULL)
{
nodeKey = 0;
// Update the nodekey indexes of any parent nodes that are still relevant, and clear any that are not
unsigned depth = key.getBranchDepth();
while (depth)
{
Expand All @@ -1779,7 +1780,7 @@ bool CKeyCursor::_next(IContextLogger *ctx)
unsigned parentNodeKey = parentNodeKeys[depth];
if (parentNodeKey < numParentKeys-1)
{
parentNodeKeys[depth] = parentNodeKey;
parentNodeKeys[depth] = parentNodeKey+1;
break;
}
parents[depth].clear();
Expand Down Expand Up @@ -1871,15 +1872,13 @@ bool CKeyCursor::_gtEqual(IContextLogger *ctx)
int rc = node->compareValueAt(recordBuffer, ++nodeKey);
if (rc <= 0)
{
// printf("Still in leaf node at level %u pos %u\n", depth, nodeKey);
return true;
}
if (nodeKey < numKeys-1)
{
rc = node->compareValueAt(recordBuffer, numKeys-1);
if (rc <= 0)
{
// printf("Still in leaf node at level %u\n", depth);
lwm = nodeKey+1;
}
}
Expand All @@ -1892,18 +1891,18 @@ bool CKeyCursor::_gtEqual(IContextLogger *ctx)
depth--;
if (depth < maxParentNodes)
{
node.set(parents[depth]);
if (node)
const CJHSearchNode *startnode = parents[depth];
if (startnode)
{
unsigned numParentKeys = node->getNumKeys();
unsigned numParentKeys = startnode->getNumKeys();
unsigned parentNodeKey = parentNodeKeys[depth];
if (parentNodeKey < numParentKeys-1)
{
int rc = node->compareValueAt(recordBuffer, numParentKeys-1);
int rc = startnode->compareValueAt(recordBuffer, numParentKeys-1);
if (rc <= 0)
{
lwm = parentNodeKey+1;
// printf("Still in parent node at level %u %u\n", depth, numParentKeys);
node.set(startnode);
break;
}
}
Expand Down Expand Up @@ -1994,18 +1993,18 @@ bool CKeyCursor::_ltEqual(IContextLogger *ctx)
depth--;
if (depth < maxParentNodes)
{
node.set(parents[depth]);
if (node)
const CJHSearchNode *startnode = parents[depth];
if (startnode)
{
unsigned numParentKeys = node->getNumKeys();
unsigned numParentKeys = startnode->getNumKeys();
unsigned parentNodeKey = parentNodeKeys[depth];
if (parentNodeKey < numParentKeys-1)
{
int rc = node->compareValueAt(recordBuffer, numParentKeys-1);
int rc = startnode->compareValueAt(recordBuffer, numParentKeys-1);
if (rc < 0)
{
lwm = parentNodeKey+1;
printf("Still in parent node at level %u %u\n", depth, numParentKeys);
node.set(startnode);
break;
}
}
Expand Down

0 comments on commit ec87f79

Please sign in to comment.