use of org.exist.storage.btree.BTree in project exist by eXist-db.
the class BTreeTest method rebuild.
public void rebuild() throws DBException, IOException, TerminatedException {
BTree btree = null;
try {
System.out.println("Loading btree ...");
btree = new BTree(pool, BTREE_TEST_FILE_ID, BTREE_TEST_FILE_VERSION, false, pool.getCacheManager(), file);
btree.open((short) -1);
System.out.println("Rebuilding ...");
btree.rebuild();
try (final OutputStreamWriter writer = new OutputStreamWriter(System.out)) {
btree.dump(writer);
writer.flush();
}
} finally {
if (btree != null) {
btree.close();
}
}
}
use of org.exist.storage.btree.BTree in project exist by eXist-db.
the class CollectionTest method read.
public void read(final BrokerPool pool) throws EXistException, IOException, PermissionDeniedException, BTreeException, DatabaseConfigurationException, LockException {
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
BTree btree = ((NativeBroker) broker).getStorage(NativeBroker.COLLECTIONS_DBX_ID);
Writer writer = new StringWriter();
btree.dump(writer);
Collection test = broker.getCollection(TEST_COLLECTION_URI.append("test2"));
assertNotNull(test);
for (Iterator<DocumentImpl> i = test.iterator(broker); i.hasNext(); ) {
DocumentImpl next = i.next();
}
}
}
use of org.exist.storage.btree.BTree in project exist by eXist-db.
the class BTreeTest method read.
public void read(int count) throws DBException, IOException, TerminatedException {
BTree btree = null;
try {
System.out.println("Loading btree ...");
btree = new BTree(pool, BTREE_TEST_FILE_ID, BTREE_TEST_FILE_VERSION, false, pool.getCacheManager(), file);
btree.open((short) -1);
String prefixStr = "KEY";
for (int i = 1; i <= count; i++) {
Value value = new Value(prefixStr + Integer.toString(i));
long r = btree.findValue(value);
if (r == -1) {
System.out.println("Key not found: " + i);
}
}
} finally {
if (btree != null) {
btree.close();
}
}
}
use of org.exist.storage.btree.BTree in project exist by eXist-db.
the class BTreeTest method create.
public void create(int count) throws DBException, IOException {
FileUtils.deleteQuietly(file);
try (BTree btree = new BTree(pool, BTREE_TEST_FILE_ID, BTREE_TEST_FILE_VERSION, false, pool.getCacheManager(), file)) {
btree.create((short) -1);
String prefixStr = "KEY";
for (int i = 1; i <= count; i++) {
Value value = new Value(prefixStr + Integer.toString(i));
btree.addValue(value, i);
}
btree.flush();
try (final OutputStreamWriter writer = new OutputStreamWriter(System.out)) {
btree.dump(writer);
writer.flush();
}
}
}
Aggregations