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;
}
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);
}
}
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();
}
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));
}
}
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();
}
Aggregations