Search in sources :

Example 41 with Value

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();
        }
    }
}
Also used : Value(org.exist.storage.btree.Value) BTree(org.exist.storage.btree.BTree)

Example 42 with Value

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();
        }
    }
}
Also used : Value(org.exist.storage.btree.Value) BTree(org.exist.storage.btree.BTree) OutputStreamWriter(java.io.OutputStreamWriter)

Example 43 with Value

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())));
}
Also used : DecimalValue(org.exist.xquery.value.DecimalValue) Value(org.exist.storage.btree.Value) ByteBuffer(java.nio.ByteBuffer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 44 with Value

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())));
}
Also used : DecimalValue(org.exist.xquery.value.DecimalValue) Value(org.exist.storage.btree.Value) ByteBuffer(java.nio.ByteBuffer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Value (org.exist.storage.btree.Value)44 ReentrantLock (java.util.concurrent.locks.ReentrantLock)28 IOException (java.io.IOException)19 IndexQuery (org.exist.storage.btree.IndexQuery)19 BTreeException (org.exist.storage.btree.BTreeException)16 EXistException (org.exist.EXistException)13 PermissionDeniedException (org.exist.security.PermissionDeniedException)11 LockException (org.exist.util.LockException)11 QName (org.exist.dom.QName)10 DatabaseConfigurationException (org.exist.util.DatabaseConfigurationException)10 NodeId (org.exist.numbering.NodeId)8 AtomicValue (org.exist.xquery.value.AtomicValue)8 StringValue (org.exist.xquery.value.StringValue)8 Test (org.junit.Test)8 TerminatedException (org.exist.xquery.TerminatedException)7 Collection (org.exist.collections.Collection)5 NodeProxy (org.exist.dom.persistent.NodeProxy)5 DocumentImpl (org.exist.dom.persistent.DocumentImpl)4 NewArrayNodeSet (org.exist.dom.persistent.NewArrayNodeSet)4 BFile (org.exist.storage.index.BFile)4