Naive range reads implementation and test

This commit is contained in:
2024-02-05 13:59:10 -08:00
parent e3e0e7ba44
commit 57ec97f2ee
2 changed files with 83 additions and 22 deletions

View File

@@ -815,8 +815,6 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
result[i] = TooOld;
continue;
}
// TODO support non-point reads
assert(r.end.len == 0);
auto [l, c] =
lastLeq(root, std::span<const uint8_t>(r.begin.p, r.begin.len));
#if DEBUG_VERBOSE && !defined(NDEBUG)
@@ -830,6 +828,28 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
r.readVersion
? Conflict
: Commit;
if (result[i] == Commit && r.end.len > 0) {
auto [e, c] =
lastLeq(root, std::span<const uint8_t>(r.end.p, r.end.len));
#if DEBUG_VERBOSE && !defined(NDEBUG)
Arena arena;
fprintf(stderr, "LastLeq for `%s' got `%s'\n", printable(r.end).c_str(),
printable(getSearchPath(arena, e)).c_str());
#endif
if (l == e) {
continue;
}
if (c != 0) {
e = nextLogical(e);
}
for (auto iter = nextLogical(l); iter != e; iter = nextLogical(iter)) {
if (iter->entry.pointVersion > r.readVersion ||
iter->entry.rangeVersion > r.readVersion) {
result[i] = Conflict;
break;
}
}
}
}
}
void addWrites(const WriteRange *writes, int count) {