MCPcopy Create free account
hub / github.com/antirez/ds4 / raxIteratorEnterChild

Function raxIteratorEnterChild

rax.c:1578–1597  ·  view source on GitHub ↗

Descend from 'parent' into child 'childidx', updating the iterator key. * If the child is inline we stop on the virtual leaf without changing the * tree. Otherwise we enter the real child node as usual. */

Source from the content-addressed store, hash-verified

1576 * If the child is inline we stop on the virtual leaf without changing the
1577 * tree. Otherwise we enter the real child node as usual. */
1578static inline int raxIteratorEnterChild(raxIterator *it, raxNode *parent,
1579 raxNode **childfield, int childidx)
1580{
1581 if (parent->iscompr) {
1582 if (!raxIteratorAddChars(it,parent->data,parent->size)) return 0;
1583 } else {
1584 if (!raxIteratorAddChars(it,parent->data+childidx,1)) return 0;
1585 }
1586
1587 if (raxIsInlineLeaf(parent,childidx))
1588 return raxIteratorSetInlineLeaf(it,parent,childfield,childidx);
1589
1590 if (!raxStackPush(&it->stack,parent)) return 0;
1591 memcpy(&it->node,childfield,sizeof(it->node));
1592 it->node_child = childidx;
1593 if (it->node_cb && it->node_cb(&it->node))
1594 memcpy(childfield,&it->node,sizeof(it->node));
1595 it->data = it->node->iskey ? raxGetData(it->node) : NULL;
1596 return 1;
1597}
1598
1599/* Return the pointer-to-pointer in the tree that references the element
1600 * currently selected by the iterator. For regular key nodes this is the

Callers 3

raxIteratorNextStepFunction · 0.85
raxSeekGreatestFunction · 0.85
raxIteratorPrevStepFunction · 0.85

Calls 5

raxIteratorAddCharsFunction · 0.85
raxIsInlineLeafFunction · 0.85
raxIteratorSetInlineLeafFunction · 0.85
raxStackPushFunction · 0.85
raxGetDataFunction · 0.85

Tested by

no test coverage detected