use of org.exist.storage.btree.Value 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.Value 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();
}
}
}
use of org.exist.storage.btree.Value in project exist by eXist-db.
the class ValueIndexFactoryTest method negativeNumbersComparison.
@Ignore
@Test
public void negativeNumbersComparison() {
// -8.6...
final ByteBuffer data1 = encode(-8.612328);
// 1.0
final ByteBuffer data2 = encode(1.0);
// // print data
// print(data1);
// print(data2);
// -8.6 < 1.0
assertTrue(data1.compareTo(data2) <= -1);
// -8.6 < 1.0
assertEquals("v1 < v2", -1, new Value(data1.array()).compareTo(new Value(data2.array())));
}
use of org.exist.storage.btree.Value in project exist by eXist-db.
the class ValueIndexFactoryTest method negativeNumbersComparison2.
@Ignore
@Test
public void negativeNumbersComparison2() {
// -8.6...
final ByteBuffer data1 = encode(8.612328);
// 1.0
final ByteBuffer data2 = encode(-1.0);
// // print data
// print(data1);
// print(data2);
// -8.6 < 1.0
assertTrue(data1.compareTo(data2) >= 1);
// -8.6 < 1.0
assertEquals("v1 < v2", 1, new Value(data1.array()).compareTo(new Value(data2.array())));
}
Aggregations