use of suite.btree.impl.B_TreeBuilder in project suite by stupidsing.
the class B_TreeTest method testAccess.
@Test
public void testAccess() throws IOException {
int pageSize = 4096;
Path path = Constants.tmp("b_tree-file");
Files.deleteIfExists(path);
B_TreeBuilder<Integer, String> builder = new B_TreeBuilder<>(serialize.int_, serialize.string(16));
shuffleNumbers();
try (JournalledPageFile jpf = JournalledFileFactory.journalled(path, pageSize);
B_Tree<Integer, String> b_tree = builder.build(jpf, comparator, pageSize)) {
b_tree.create();
testStep0(b_tree);
jpf.commit();
jpf.sync();
}
shuffleNumbers();
try (JournalledPageFile jpf = JournalledFileFactory.journalled(path, pageSize);
B_Tree<Integer, String> b_tree = builder.build(jpf, comparator, pageSize)) {
testStep1(b_tree);
jpf.commit();
jpf.sync();
}
try (JournalledPageFile jpf = JournalledFileFactory.journalled(path, pageSize);
B_Tree<Integer, String> b_tree = builder.build(jpf, comparator, pageSize)) {
testStep2(b_tree);
jpf.commit();
jpf.sync();
jpf.applyJournal();
}
}
use of suite.btree.impl.B_TreeBuilder in project suite by stupidsing.
the class B_TreeTest method testDump.
@Test
public void testDump() throws IOException {
int pageSize = 4096;
Path path = Constants.tmp("b_tree-dump");
Files.deleteIfExists(path);
B_TreeBuilder<Integer, String> builder = new B_TreeBuilder<>(serialize.int_, serialize.string(16));
try (JournalledPageFile jpf = JournalledFileFactory.journalled(path, pageSize);
B_Tree<Integer, String> b_tree = builder.build(jpf, comparator, pageSize)) {
b_tree.create();
for (int i = 0; i < 32; i++) b_tree.put(i, Integer.toString(i));
b_tree.dump(System.out);
System.out.println(To.list(b_tree.keys(3, 10)));
jpf.commit();
}
}
use of suite.btree.impl.B_TreeBuilder in project suite by stupidsing.
the class B_TreeTest method testInsertPerformance.
@Test
public void testInsertPerformance() throws IOException {
int nKeys = 16384;
keys = Ints_.toArray(nKeys, i -> i);
int pageSize = 4096;
Path path = Constants.tmp("b_tree-file");
for (int i = 0; i < nKeys; i++) {
int j = random.nextInt(nKeys);
Integer temp = keys[i];
keys[i] = keys[j];
keys[j] = temp;
}
Files.deleteIfExists(path);
B_TreeBuilder<Integer, Bytes> builder = new B_TreeBuilder<>(serialize.int_, serialize.bytes(64));
try (JournalledPageFile jpf = JournalledFileFactory.journalled(path, pageSize);
B_Tree<Integer, Bytes> b_tree = builder.build(jpf, comparator, 9999)) {
new Profiler().profile(() -> {
b_tree.create();
for (int i = 0; i < nKeys; i++) {
int key = keys[i];
b_tree.put(key, To.bytes(Integer.toString(key)));
}
jpf.commit();
jpf.sync();
});
}
}
Aggregations