Write 10 keys

This commit is contained in:
2024-01-17 17:38:26 -08:00
parent 6365e01d5b
commit eb579dfc1e

View File

@@ -260,6 +260,18 @@ void lastLeqMulti(Node *root, std::span<Key> keys, Iterator *results) {
fprintf(file, "}\n");
}
[[maybe_unused]] Key toKey(int n) {
constexpr int kMaxLength = 4;
static unsigned char itoaBuf[kMaxLength];
int i = kMaxLength;
memset(itoaBuf, '0', kMaxLength);
do {
itoaBuf[--i] = "0123456789abcdef"[n % 16];
n /= 16;
} while (n);
return Key{itoaBuf, kMaxLength};
}
} // namespace
struct ConflictSet::Impl {
@@ -378,12 +390,13 @@ ConflictSet &ConflictSet::operator=(ConflictSet &&other) noexcept {
#ifdef ENABLE_TESTS
int main(void) {
ConflictSet::Impl cs{0};
ConflictSet::WriteRange write;
write.begin.p = (const uint8_t *)"0000";
write.begin.len = 4;
write.end.len = 0;
write.writeVersion = 1;
cs.addWrites(&write, 1);
for (int i = 0; i < 10; ++i) {
ConflictSet::WriteRange write;
write.begin = toKey(i);
write.end.len = 0;
write.writeVersion = i;
cs.addWrites(&write, 1);
}
debugPrintDot(stdout, cs.root);
}
#endif