Prepare for new invariant

This commit is contained in:
2024-02-07 13:44:46 -08:00
parent 98124d5493
commit 855b7fa069

View File

@@ -1121,35 +1121,38 @@ namespace {
[[maybe_unused]] void debugPrintDot(FILE *file, Node *node) {
constexpr int kSeparation = 2;
struct DebugDotPrinter {
explicit DebugDotPrinter(FILE *file) : file(file) {}
void print(Node *n) {
void print(Node *n, int y = 0) {
assert(n != nullptr);
auto partialKey = printable(Key{n->partialKey, n->partialKeyLen});
if (n->entryPresent) {
fprintf(file,
" k_%p [label=\"m=%" PRId64 " p=%" PRId64 " r=%" PRId64
" %s\"];\n",
"\n%s\", pos=\"%d,%d!\"];\n",
(void *)n, n->maxVersion, n->entry.pointVersion,
n->entry.rangeVersion, partialKey.c_str());
n->entry.rangeVersion, getSearchPath(n).c_str(), x, y);
} else {
fprintf(file, " k_%p [label=\"m=%" PRId64 " %s\"];\n", (void *)n,
n->maxVersion, partialKey.c_str());
fprintf(file, " k_%p [label=\"m=%" PRId64 "\n%s\", pos=\"%d,%d!\"];\n",
(void *)n, n->maxVersion, getSearchPath(n).c_str(), x, y);
}
x += kSeparation;
for (int child = getChildGeq(n, 0); child >= 0;
child = getChildGeq(n, child + 1)) {
auto *c = getChildExists(n, child);
fprintf(file, " k_%p -> k_%p [label=\"x%02x\"];\n", (void *)n,
(void *)c, child);
print(c);
fprintf(file, " k_%p -> k_%p;\n", (void *)n, (void *)c);
print(c, y - kSeparation);
}
}
int x = 0;
FILE *file;
};
fprintf(file, "digraph ConflictSet {\n");
fprintf(file, " node [shape = box];\n");
assert(node != nullptr);
DebugDotPrinter printer{file};
printer.print(node);