Search in sources :

Example 1 with RecordBufferPageMgr

use of org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr in project jena by apache.

the class TestRecordBufferPage method recBufferPage02.

@Test
public void recBufferPage02() {
    BlockMgr blkMgr = makeBlockMgr();
    blkMgr.beginUpdate();
    RecordBufferPageMgr rpm = new RecordBufferPageMgr(factory, blkMgr);
    int x = -99;
    {
        RecordBufferPage page1 = rpm.create();
        fill(page1.getRecordBuffer(), 10, 20, 30);
        x = page1.getId();
        rpm.put(page1);
        page1 = null;
    }
    blkMgr.endUpdate();
    blkMgr.beginRead();
    {
        RecordBufferPage page2 = rpm.getRead(x);
        assertEquals(10, get(page2, 0));
        assertEquals(20, get(page2, 1));
        assertEquals(30, get(page2, 2));
        rpm.release(page2);
    }
    blkMgr.endRead();
}
Also used : RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) RecordBufferPage(org.apache.jena.tdb.base.recordbuffer.RecordBufferPage) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 2 with RecordBufferPageMgr

use of org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr in project jena by apache.

the class BPlusTree method iterator.

/** Iterate over a range of fromRec (inclusive) to toRec (exclusive) */
private static Iterator<Record> iterator(BPTreeNode node, Record fromRec, Record toRec) {
    // Look for starting RecordsBufferPage id.
    int id = BPTreeNode.recordsPageId(node, fromRec);
    if (id < 0)
        return Iter.nullIter();
    RecordBufferPageMgr pageMgr = node.getBPlusTree().getRecordsMgr().getRecordBufferPageMgr();
    // No pages are active at this point.
    return RecordRangeIterator.iterator(id, fromRec, toRec, pageMgr);
}
Also used : RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr)

Example 3 with RecordBufferPageMgr

use of org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr in project jena by apache.

the class BPlusTreeRewriter method writePackedDataBlocks.

// **** data block phase
/** Pack record blocks into linked RecordBufferPages */
private static Iterator<Pair<Integer, Record>> writePackedDataBlocks(Iterator<Record> records, final BPlusTree bpt) {
    if (debug) {
        divider();
        System.out.println("---- Data level");
    }
    final RecordBufferPageMgr mgr = bpt.getRecordsMgr().getRecordBufferPageMgr();
    Iterator<RecordBufferPage> iter = new RecordBufferPageLinker(new RecordBufferPagePacker(records, mgr));
    Function<RecordBufferPage, Pair<Integer, Record>> transform = rbp -> {
        mgr.put(rbp);
        Record r = rbp.getRecordBuffer().getHigh();
        r = bpt.getRecordFactory().createKeyOnly(r);
        return new Pair<>(rbp.getId(), r);
    };
    // Write and convert to split pairs.
    Iterator<Pair<Integer, Record>> iter2 = Iter.map(iter, transform);
    if (debug) {
        if (rebalance)
            System.out.println("Before rebalance (data)");
        iter2 = summarizeDataBlocks(iter2, bpt.getRecordsMgr().getRecordBufferPageMgr());
    //iter2 = printDataBlocks(iter2, bpt.getRecordsMgr().getRecordBufferPageMgr()) ;
    }
    if (rebalance)
        iter2 = new RebalenceDataEnd(iter2, bpt);
    // Testing - materialize - debug wil have done this
    if (materialize && !debug)
        iter2 = Iter.toList(iter2).iterator();
    if (debug && rebalance) {
        System.out.println("After rebalance (data)");
        iter2 = summarizeDataBlocks(iter2, bpt.getRecordsMgr().getRecordBufferPageMgr());
    //iter2 = printDataBlocks(iter2, bpt.getRecordsMgr().getRecordBufferPageMgr()) ;
    }
    return iter2;
}
Also used : IteratorWithBuffer(org.apache.jena.atlas.iterator.IteratorWithBuffer) Record(org.apache.jena.tdb.base.record.Record) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) LoggerFactory(org.slf4j.LoggerFactory) BPlusTreeRewriterUtils.summarizeDataBlocks(org.apache.jena.tdb.index.bplustree.BPlusTreeRewriterUtils.summarizeDataBlocks) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) Function(java.util.function.Function) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) BPlusTreeRewriterUtils.printIndexBlocks(org.apache.jena.tdb.index.bplustree.BPlusTreeRewriterUtils.printIndexBlocks) BPlusTreeRewriterUtils.divider(org.apache.jena.tdb.index.bplustree.BPlusTreeRewriterUtils.divider) RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr) Pair(org.apache.jena.atlas.lib.Pair) RecordBuffer(org.apache.jena.tdb.base.buffer.RecordBuffer) Iter(org.apache.jena.atlas.iterator.Iter) PtrBuffer(org.apache.jena.tdb.base.buffer.PtrBuffer) RecordBufferPage(org.apache.jena.tdb.base.recordbuffer.RecordBufferPage) RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr) Record(org.apache.jena.tdb.base.record.Record) RecordBufferPage(org.apache.jena.tdb.base.recordbuffer.RecordBufferPage) Pair(org.apache.jena.atlas.lib.Pair)

Example 4 with RecordBufferPageMgr

use of org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr in project jena by apache.

the class BPlusTreeTools method bpt_scan_record_buffer.

/*public*/
private static void bpt_scan_record_buffer(BlockMgr blkMgr, boolean verbose) {
    RecordFactory f = SystemTDB.indexRecordTripleFactory;
    RecordBufferPageMgr recordPageMgr = new RecordBufferPageMgr(f, blkMgr);
    bpt_scan_record_buffer(recordPageMgr, verbose);
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr)

Example 5 with RecordBufferPageMgr

use of org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr in project jena by apache.

the class TestRecordBufferPage method recBufferPage01.

@Test
public void recBufferPage01() {
    BlockMgr blkMgr = makeBlockMgr();
    blkMgr.beginUpdate();
    RecordBufferPageMgr rpm = new RecordBufferPageMgr(factory, blkMgr);
    RecordBufferPage page = rpm.create();
    fill(page.getRecordBuffer(), 10, 20, 30);
    assertEquals(10, get(page, 0));
    assertEquals(20, get(page, 1));
    assertEquals(30, get(page, 2));
    rpm.release(page);
    blkMgr.endUpdate();
}
Also used : RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) RecordBufferPage(org.apache.jena.tdb.base.recordbuffer.RecordBufferPage) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Aggregations

RecordBufferPageMgr (org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr)6 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)3 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)3 RecordBufferPage (org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)3 BaseTest (org.apache.jena.atlas.junit.BaseTest)2 Test (org.junit.Test)2 Iterator (java.util.Iterator)1 Function (java.util.function.Function)1 Iter (org.apache.jena.atlas.iterator.Iter)1 IteratorWithBuffer (org.apache.jena.atlas.iterator.IteratorWithBuffer)1 Pair (org.apache.jena.atlas.lib.Pair)1 PtrBuffer (org.apache.jena.tdb.base.buffer.PtrBuffer)1 RecordBuffer (org.apache.jena.tdb.base.buffer.RecordBuffer)1 Record (org.apache.jena.tdb.base.record.Record)1 BPlusTreeParams (org.apache.jena.tdb.index.bplustree.BPlusTreeParams)1 BPlusTreeRewriterUtils.divider (org.apache.jena.tdb.index.bplustree.BPlusTreeRewriterUtils.divider)1 BPlusTreeRewriterUtils.printIndexBlocks (org.apache.jena.tdb.index.bplustree.BPlusTreeRewriterUtils.printIndexBlocks)1 BPlusTreeRewriterUtils.summarizeDataBlocks (org.apache.jena.tdb.index.bplustree.BPlusTreeRewriterUtils.summarizeDataBlocks)1 BeforeClass (org.junit.BeforeClass)1 Logger (org.slf4j.Logger)1