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