Search in sources :

Example 31 with Record

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

the class TestBPTreeRecords method bpt_shift_2.

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

Example 32 with Record

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

the class TestBPlusTreeRewriter method createData2.

static List<Record> createData2(int ORDER, int N, RecordFactory recordFactory) {
    // Use a B+Tree - so original data can be unsorted.
    BPlusTree bpt = SetupIndex.createBPTree(FileSet.mem(), ORDER, -1, -1, -1, recordFactory);
    for (int i = 0; i < N; i++) {
        Record record = recordFactory.create();
        Bytes.setInt(i + 1, record.getKey());
        bpt.add(record);
    }
    return Iter.toList(bpt.iterator());
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 33 with Record

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

the class TestBPlusTreeRewriter method findComparison.

public static void findComparison(List<Record> originaldata, BPlusTree bpt2) {
    Iterator<Record> iter1 = originaldata.iterator();
    long count = 0;
    for (; iter1.hasNext(); ) {
        count++;
        Record r1 = iter1.next();
        Record r3 = bpt2.find(r1);
        if (r3 == null) {
            r3 = bpt2.find(r1);
            error("Deviation in find at record %d: %s : null", count, r1);
        }
        if (!Record.equals(r1, r3))
            error("Deviation in find at record %d: %s : %s", count, r1, r3);
    }
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 34 with Record

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

the class TestBPlusTreeRewriter method runOneTest.

static void runOneTest(int order, int N, RecordFactory recordFactory, boolean debug) {
    BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
    BPlusTreeRewriter.debug = debug;
    // ---- Test data
    List<Record> originaldata = TestBPlusTreeRewriter.createData(N, recordFactory);
    FileSet destination = FileSet.mem();
    // ---- Rewrite
    // Write leaves to ...
    BlockMgr blkMgr1 = BlockMgrFactory.create(destination, Names.bptExtTree, bptParams.getCalcBlockSize(), 10, 10);
    // Write nodes to ...
    BlockMgr blkMgr2 = BlockMgrFactory.create(destination, Names.bptExtTree, bptParams.getCalcBlockSize(), 10, 10);
    BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(originaldata.iterator(), bptParams, recordFactory, blkMgr1, blkMgr2);
    if (debug) {
        BPlusTreeRewriterUtils.divider();
        bpt2.dump();
    }
    // ---- Checking
    bpt2.check();
    scanComparision(originaldata, bpt2);
    findComparison(originaldata, bpt2);
    sizeComparison(originaldata, bpt2);
}
Also used : FileSet(org.apache.jena.tdb.base.file.FileSet) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) Record(org.apache.jena.tdb.base.record.Record)

Example 35 with Record

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

the class ExtHashTestBase method delete.

public static ExtHash delete(ExtHash extHash, int... recs) {
    for (int i : recs) {
        Record r = intToRecord(i);
        extHash.delete(r);
    }
    return extHash;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Aggregations

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