Search in sources :

Example 81 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class TestRecordBufferPage method get.

private static int get(RecordBuffer rb, int idx) {
    Record r = rb.get(idx);
    int v = (r.getKey()[0]) << 8 | ((r.getKey()[1]) & 0xFF);
    return v;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 82 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class IndexTestLib method testIndexContents.

public static void testIndexContents(Index index, int[] records) {
    List<Integer> x = toIntList(index.iterator());
    // Make a unique list of expected records.  Remove duplicates
    List<Integer> y = unique(asList(records));
    assertEquals("Expected records size and tree size different", y.size(), index.size());
    assertEquals("Expected records size and iteration over all keys are of different sizes", y.size(), x.size());
    if (index instanceof RangeIndex) {
        // Check sorted order
        for (int i = 0; i < x.size() - 2; i++) {
            if (x.get(i) > x.get(i + 1)) {
                fail("check failed: " + strings(records));
                return;
            }
        }
    }
    // Check each expected record is in the tree
    for (int k : y) {
        Record rec = intToRecord(k);
        Record r2 = index.find(rec);
        assertNotNull("Finding " + rec, r2);
    }
}
Also used : Record(org.apache.jena.tdb.base.record.Record) RecordLib.intToRecord(org.apache.jena.tdb.base.record.RecordLib.intToRecord)

Example 83 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class TestBPTreeRecords method bpt_shift_3.

@Test
public void bpt_shift_3() {
    BPTreeRecords bpr1 = make();
    BPTreeRecords bpr2 = make();
    insert(bpr1, 10, 20);
    insert(bpr2, 99);
    Record r = bpr1.shiftRight(bpr2, null);
    assertTrue(r + " != " + RecordLib.intToRecord(10), Record.keyEQ(r, RecordLib.intToRecord(10)));
    contains(bpr1, 10);
    contains(bpr2, 20, 99);
    bpr1.release();
    bpr2.release();
}
Also used : Record(org.apache.jena.tdb.base.record.Record) Test(org.junit.Test)

Example 84 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class TestBPTreeRecords method check.

private static void check(BPTreeRecords bpr) {
    assertTrue(bpr.getCount() >= 0);
    assertTrue(bpr.getCount() <= bpr.getMaxSize());
    assertEquals(bpr.getRecordBuffer().getLow(), bpr.getLowRecord());
    assertEquals(bpr.getRecordBuffer().getHigh(), bpr.getHighRecord());
    for (int i = 1; i < bpr.getCount(); i++) {
        Record r1 = bpr.getRecordBuffer().get(i - 1);
        Record r2 = bpr.getRecordBuffer().get(i);
        assertTrue(Record.keyLE(r1, r2));
    }
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 85 with Record

use of org.apache.jena.tdb.base.record.Record in project jena by apache.

the class TestBPTreeRecords method bpt_shift_4.

@Test
public void bpt_shift_4() {
    BPTreeRecords bpr1 = make();
    BPTreeRecords bpr2 = make();
    insert(bpr1, 10, 20);
    insert(bpr2, 5);
    Record r = bpr2.shiftLeft(bpr1, null);
    assertTrue(Record.keyEQ(r, RecordLib.intToRecord(10)));
    contains(bpr1, 20);
    contains(bpr2, 5, 10);
    bpr1.release();
    bpr2.release();
}
Also used : Record(org.apache.jena.tdb.base.record.Record) Test(org.junit.Test)

Aggregations

Record (org.apache.jena.tdb.base.record.Record)95 Test (org.junit.Test)20 RecordLib.intToRecord (org.apache.jena.tdb.base.record.RecordLib.intToRecord)15 RecordBuffer (org.apache.jena.tdb.base.buffer.RecordBuffer)14 BaseTest (org.apache.jena.atlas.junit.BaseTest)10 RangeIndex (org.apache.jena.tdb.index.RangeIndex)8 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)6 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)6 NoSuchElementException (java.util.NoSuchElementException)5 FileSet (org.apache.jena.tdb.base.file.FileSet)5 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)5 NodeId (org.apache.jena.tdb.store.NodeId)5 Pair (org.apache.jena.atlas.lib.Pair)4 Location (org.apache.jena.tdb.base.file.Location)4 BPlusTreeParams (org.apache.jena.tdb.index.bplustree.BPlusTreeParams)4 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)3 StorageException (org.apache.jena.tdb.base.StorageException)3 RecordBufferPage (org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)3 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)3 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)3