Bring back nextSibling
This commit is contained in:
@@ -512,10 +512,23 @@ struct Iterator {
|
|||||||
int cmp;
|
int cmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Node *nextSibling(Node *node) {
|
||||||
|
for (;;) {
|
||||||
|
if (node->parent == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto next = getChildGeq(node->parent, node->parentsIndex + 1);
|
||||||
|
if (next < 0) {
|
||||||
|
node = node->parent;
|
||||||
|
} else {
|
||||||
|
return getChildExists(node->parent, next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct FirstGeqStepwise {
|
struct FirstGeqStepwise {
|
||||||
Node *n;
|
Node *n;
|
||||||
std::span<const uint8_t> remaining;
|
std::span<const uint8_t> remaining;
|
||||||
Node *nextSib = nullptr;
|
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
enum Phase {
|
enum Phase {
|
||||||
@@ -541,10 +554,6 @@ struct FirstGeqStepwise {
|
|||||||
return downLeftSpine();
|
return downLeftSpine();
|
||||||
} else {
|
} else {
|
||||||
int c = getChildGeq(n, remaining[0]);
|
int c = getChildGeq(n, remaining[0]);
|
||||||
int c2 = getChildGeq(n, int(remaining[0]) + 1);
|
|
||||||
if (c2 >= 0) {
|
|
||||||
nextSib = getChildExists(n, c2);
|
|
||||||
}
|
|
||||||
if (c == remaining[0]) {
|
if (c == remaining[0]) {
|
||||||
n = getChildExists(n, c);
|
n = getChildExists(n, c);
|
||||||
remaining = remaining.subspan(1, remaining.size() - 1);
|
remaining = remaining.subspan(1, remaining.size() - 1);
|
||||||
@@ -553,7 +562,7 @@ struct FirstGeqStepwise {
|
|||||||
n = getChildExists(n, c);
|
n = getChildExists(n, c);
|
||||||
return downLeftSpine();
|
return downLeftSpine();
|
||||||
} else {
|
} else {
|
||||||
n = nextSib;
|
n = nextSibling(n);
|
||||||
return downLeftSpine();
|
return downLeftSpine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -571,7 +580,7 @@ struct FirstGeqStepwise {
|
|||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
return downLeftSpine();
|
return downLeftSpine();
|
||||||
} else {
|
} else {
|
||||||
n = nextSib;
|
n = nextSibling(n);
|
||||||
return downLeftSpine();
|
return downLeftSpine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,7 +637,6 @@ Iterator firstGeq(Node *n, const std::span<const uint8_t> key) {
|
|||||||
bool checkPointRead(Node *n, const std::span<const uint8_t> key,
|
bool checkPointRead(Node *n, const std::span<const uint8_t> key,
|
||||||
int64_t readVersion) {
|
int64_t readVersion) {
|
||||||
auto remaining = key;
|
auto remaining = key;
|
||||||
Node *nextSib = nullptr;
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (n->partialKeyLen > 0) {
|
if (n->partialKeyLen > 0) {
|
||||||
int commonLen = std::min<int>(n->partialKeyLen, remaining.size());
|
int commonLen = std::min<int>(n->partialKeyLen, remaining.size());
|
||||||
@@ -640,7 +648,7 @@ bool checkPointRead(Node *n, const std::span<const uint8_t> key,
|
|||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
} else {
|
} else {
|
||||||
n = nextSib;
|
n = nextSibling(n);
|
||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -666,10 +674,6 @@ bool checkPointRead(Node *n, const std::span<const uint8_t> key,
|
|||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
} else {
|
} else {
|
||||||
int c = getChildGeq(n, remaining[0]);
|
int c = getChildGeq(n, remaining[0]);
|
||||||
int c2 = getChildGeq(n, int(remaining[0]) + 1);
|
|
||||||
if (c2 >= 0) {
|
|
||||||
nextSib = getChildExists(n, c2);
|
|
||||||
}
|
|
||||||
if (c == remaining[0]) {
|
if (c == remaining[0]) {
|
||||||
n = getChildExists(n, c);
|
n = getChildExists(n, c);
|
||||||
remaining = remaining.subspan(1, remaining.size() - 1);
|
remaining = remaining.subspan(1, remaining.size() - 1);
|
||||||
@@ -678,7 +682,7 @@ bool checkPointRead(Node *n, const std::span<const uint8_t> key,
|
|||||||
n = getChildExists(n, c);
|
n = getChildExists(n, c);
|
||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
} else {
|
} else {
|
||||||
n = nextSib;
|
n = nextSibling(n);
|
||||||
goto downLeftSpine;
|
goto downLeftSpine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user