Remove searchPathLen
This commit is contained in:
@@ -2937,8 +2937,6 @@ struct CheckJob {
|
||||
std::span<const uint8_t> remaining; // range read only
|
||||
Node *child; // range read only
|
||||
int lcp; // range read only
|
||||
int prefixLen; // range read only
|
||||
int searchPathLen; // range read only
|
||||
Node *commonPrefixNode; // range read only
|
||||
InternalVersionT readVersion;
|
||||
ConflictSet::Result *result;
|
||||
@@ -3263,16 +3261,21 @@ static Continuation commonPrefixIterTable[] = {
|
||||
common_prefix_iter<Node16>, common_prefix_iter<Node48>,
|
||||
common_prefix_iter<Node256>};
|
||||
|
||||
template <class NodeT>
|
||||
template <class NodeT, bool kFirst>
|
||||
PRESERVE_NONE void left_side_iter(CheckJob *, CheckContext *);
|
||||
|
||||
PRESERVE_NONE void left_side_down_left_spine(CheckJob *, CheckContext *);
|
||||
|
||||
PRESERVE_NONE void done_left_side_iter(CheckJob *, CheckContext *);
|
||||
|
||||
static Continuation leftSideIterTable[] = {
|
||||
left_side_iter<Node0>, left_side_iter<Node3>, left_side_iter<Node16>,
|
||||
left_side_iter<Node48>, left_side_iter<Node256>};
|
||||
static Continuation leftSideIterTable[2][5] = {
|
||||
{left_side_iter<Node0, false>, left_side_iter<Node3, false>,
|
||||
left_side_iter<Node16, false>, left_side_iter<Node48, false>,
|
||||
left_side_iter<Node256, false>},
|
||||
{left_side_iter<Node0, true>, left_side_iter<Node3, true>,
|
||||
left_side_iter<Node16, true>, left_side_iter<Node48, true>,
|
||||
left_side_iter<Node256, true>},
|
||||
};
|
||||
|
||||
PRESERVE_NONE void begin(CheckJob *job, CheckContext *context) {
|
||||
job->lcp = longestCommonPrefix(job->begin.data(), job->end.data(),
|
||||
@@ -3381,8 +3384,6 @@ PRESERVE_NONE void done_common_prefix_iter(CheckJob *job,
|
||||
}
|
||||
|
||||
job->remaining = job->begin;
|
||||
job->searchPathLen = 0;
|
||||
job->prefixLen = job->lcp + 1;
|
||||
|
||||
auto c = getChild(job->n, job->remaining[0]);
|
||||
Node *child = c;
|
||||
@@ -3406,32 +3407,32 @@ PRESERVE_NONE void done_common_prefix_iter(CheckJob *job,
|
||||
}
|
||||
|
||||
job->n = child;
|
||||
job->continuation = leftSideIterTable[c.getType()];
|
||||
job->continuation = leftSideIterTable[true][c.getType()];
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
|
||||
// Return true if the max version among all keys that start with key[:prefixLen]
|
||||
// that are >= key is <= readVersion
|
||||
template <class NodeT>
|
||||
template <class NodeT, bool kFirst>
|
||||
PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
assert(NodeT::kType == job->n->getType());
|
||||
NodeT *n = static_cast<NodeT *>(job->n);
|
||||
|
||||
job->remaining = job->remaining.subspan(1, job->remaining.size() - 1);
|
||||
++job->searchPathLen;
|
||||
|
||||
if (n->partialKeyLen > 0) {
|
||||
int commonLen = std::min<int>(n->partialKeyLen, job->remaining.size());
|
||||
int i =
|
||||
longestCommonPrefix(n->partialKey(), job->remaining.data(), commonLen);
|
||||
job->searchPathLen += i;
|
||||
if (i < commonLen) {
|
||||
auto c = n->partialKey()[i] <=> job->remaining[i];
|
||||
if (c > 0) {
|
||||
if (job->searchPathLen < job->prefixLen) {
|
||||
job->continuation = left_side_down_left_spine;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
if constexpr (kFirst) {
|
||||
if (i < job->lcp) {
|
||||
job->continuation = left_side_down_left_spine;
|
||||
MUSTTAIL return job->continuation(job, context);
|
||||
}
|
||||
}
|
||||
if (n->entryPresent && n->entry.rangeVersion > job->readVersion) {
|
||||
job->setResult(false);
|
||||
@@ -3458,7 +3459,6 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
job->remaining =
|
||||
job->remaining.subspan(commonLen, job->remaining.size() - commonLen);
|
||||
} else if (n->partialKeyLen > int(job->remaining.size())) {
|
||||
assert(job->searchPathLen >= job->prefixLen);
|
||||
if (n->entryPresent && n->entry.rangeVersion > job->readVersion) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
@@ -3475,7 +3475,6 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
++context->tls->range_read_iterations_accum;
|
||||
|
||||
if (job->remaining.size() == 0) {
|
||||
assert(job->searchPathLen >= job->prefixLen);
|
||||
if (maxVersion(n) > job->readVersion) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
@@ -3485,12 +3484,10 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
}
|
||||
}
|
||||
|
||||
if (job->searchPathLen >= job->prefixLen) {
|
||||
if (!checkMaxBetweenExclusive(n, job->remaining[0], 256, job->readVersion,
|
||||
context->tls)) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
if (!checkMaxBetweenExclusive(n, job->remaining[0], 256, job->readVersion,
|
||||
context->tls)) {
|
||||
job->setResult(false);
|
||||
MUSTTAIL return complete(job, context);
|
||||
}
|
||||
|
||||
auto c = getChild(n, job->remaining[0]);
|
||||
@@ -3498,12 +3495,6 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
if (child == nullptr) {
|
||||
auto c = getChildGeq(n, job->remaining[0]);
|
||||
if (c != nullptr) {
|
||||
if (job->searchPathLen < job->prefixLen) {
|
||||
job->n = c;
|
||||
job->continuation = left_side_down_left_spine;
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
job->n = c;
|
||||
if (maxVersion(job->n) > job->readVersion) {
|
||||
job->setResult(false);
|
||||
@@ -3524,7 +3515,7 @@ PRESERVE_NONE void left_side_iter(CheckJob *job, CheckContext *context) {
|
||||
}
|
||||
|
||||
job->n = child;
|
||||
job->continuation = leftSideIterTable[c.getType()];
|
||||
job->continuation = leftSideIterTable[false][c.getType()];
|
||||
__builtin_prefetch(job->n);
|
||||
MUSTTAIL return keepGoing(job, context);
|
||||
}
|
||||
|
Reference in New Issue
Block a user