the root node can have more than two children it it is an inner node

It is not yet possible to split inner nodes or the root node.
This commit is contained in:
2018-10-27 10:17:45 +02:00
parent 8b48b8c3e7
commit c6782df0e5
4 changed files with 130 additions and 38 deletions

View File

@@ -1,6 +1,7 @@
package org.lucares.pdb.map;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
@@ -78,13 +79,22 @@ public class PersistentMapTest {
try (final DiskStorage ds = new DiskStorage(file)) {
final PersistentMap map = new PersistentMap(ds);
map.visitPreOrder((nodeEntry, depth) -> {
map.visitNodeEntriesPreOrder((nodeEntry, depth) -> {
if (nodeEntry.isInnerNode()) {
System.out.println(" ".repeat(depth) + nodeEntry);
} else {
System.out.println(" ".repeat(depth) + nodeEntry);
}
});
final AtomicInteger counter = new AtomicInteger();
map.visitPreOrder((nodeEntry, depth) -> counter.addAndGet(nodeEntry.isInnerNode() ? 1 : 0));
map.visitNodeEntriesPreOrder((nodeEntry, depth) -> counter.addAndGet(nodeEntry.isInnerNode() ? 1 : 0));
System.out.println(" -------------");
map.visitNodesPreOrder((node, depth) -> {
final String key = new String(node.getTopNodeEntry().getKey(), StandardCharsets.UTF_8);
System.out.println(" ".repeat(depth) + node.getNodeOffset() + " " + key + " (children: "
+ node.getEntries().size() + ")");
});
// Assert.assertEquals(counter.get(), 3,
// "number of nodes should be small. Any number larger than 3 indicates, "