Search in sources :

Example 66 with Record

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

the class TestBPTreeRecordsNonTxn 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.dboe.base.record.Record)

Example 67 with Record

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

the class TestBPTreeRecordsNonTxn 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.dboe.base.record.Record)

Example 68 with Record

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

the class BPlusTreeRewriterUtils method summarizeDataBlocks.

static Iterator<Pair<Integer, Record>> summarizeDataBlocks(Iterator<Pair<Integer, Record>> iter, RecordBufferPageMgr recordPageMgr) {
    divider();
    List<Pair<Integer, Record>> pairs = Iter.toList(iter);
    System.out.println("summarizeDataBlocks: " + pairs);
    for (Pair<Integer, Record> pair : pairs) {
        RecordBufferPage rbp = recordPageMgr.getRead(pair.car());
        System.out.printf("%s -- RecordBufferPage[id=%d,link=%d] (%d) -> [%s]\n", pair, rbp.getId(), rbp.getLink(), rbp.getCount(), rbp.getRecordBuffer().getHigh());
        recordPageMgr.release(rbp);
    }
    return pairs.iterator();
}
Also used : Record(org.apache.jena.dboe.base.record.Record) Pair(org.apache.jena.atlas.lib.Pair) RecordBufferPage(org.apache.jena.dboe.base.recordbuffer.RecordBufferPage)

Example 69 with Record

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

the class RecordBufferPagePacker method hasNext.

@Override
public boolean hasNext() {
    if (recordBufferPage == null) {
        if (records == null)
            return false;
        if (!records.hasNext()) {
            records = null;
            return false;
        }
        // At least one record to be processed.
        // No pending RecordBufferPage
        // ==> There will be a RecordBufferPage to yield.
        // int id = rbMgr.allocateId();
        // //System.out.println("Allocate : "+id);
        recordBufferPage = rbMgr.create();
        RecordBuffer rb = recordBufferPage.getRecordBuffer();
        while (!rb.isFull() && records.hasNext()) {
            Record r = records.next();
            rb.add(r);
        }
        if (!records.hasNext())
            records = null;
        return true;
    }
    return true;
}
Also used : Record(org.apache.jena.dboe.base.record.Record) RecordBuffer(org.apache.jena.dboe.base.buffer.RecordBuffer)

Example 70 with Record

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

the class TestBPlusTreeRewriterNonTxn method createData.

static List<Record> createData(int N, RecordFactory recordFactory) {
    List<Record> originaldata = new ArrayList<>(N);
    for (int i = 0; i < N; i++) {
        Record record = recordFactory.create();
        Bytes.setInt(i + 1, record.getKey());
        if (recordFactory.hasValue())
            Bytes.setInt(10 * i + 1, record.getValue());
        originaldata.add(record);
    }
    return originaldata;
}
Also used : ArrayList(java.util.ArrayList) Record(org.apache.jena.dboe.base.record.Record)

Aggregations

Record (org.apache.jena.dboe.base.record.Record)71 RecordLib.intToRecord (org.apache.jena.dboe.test.RecordLib.intToRecord)6 Pair (org.apache.jena.atlas.lib.Pair)5 NoSuchElementException (java.util.NoSuchElementException)3 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)3 FileSet (org.apache.jena.dboe.base.file.FileSet)3 RecordBufferPage (org.apache.jena.dboe.base.recordbuffer.RecordBufferPage)3 BPTreeNode (org.apache.jena.dboe.trans.bplustree.BPTreeNode)3 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)3 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)3 NodeId (org.apache.jena.tdb2.store.NodeId)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 StorageException (org.apache.jena.dboe.base.StorageException)2 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)2 RecordBuffer (org.apache.jena.dboe.base.buffer.RecordBuffer)2 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)2 Index (org.apache.jena.dboe.index.Index)2 RangeIndex (org.apache.jena.dboe.index.RangeIndex)2 TDBException (org.apache.jena.tdb2.TDBException)2