Search in sources :

Example 1 with RecordBufferPageMgr

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

the class BPlusTreeFactory method attach.

/**
 * Create the in-memory structures to correspond to the supplied block
 * managers for the persistent storage. Does not initialize the B+Tree - it
 * assumes the block managers correspond to an existing B+Tree.
 */
private static BPlusTree attach(ComponentId cid, BPlusTreeParams params, boolean isReset, BufferChannel rootData, BlockMgr blkMgrNodes, BlockMgr blkMgrRecords) {
    // Creating and initializing the BPlusTree object is a two stage process.
    // * Create the Java object so it can be in other structures
    // but it is not fully initialized yet.
    // * Create datastructures being careful not to use the object
    // * Ensure formatted
    // * Initialize.
    BPlusTree bpt = new BPlusTree(cid, params);
    BPTStateMgr stateMgr = new BPTStateMgr(rootData);
    blkMgrNodes.resetAlloc(stateMgr.getNodeBlocksLimit());
    blkMgrRecords.resetAlloc(stateMgr.getRecordsBlocksLimit());
    BPTreeNodeMgr nodeManager = new BPTreeNodeMgr(bpt, blkMgrNodes);
    RecordBufferPageMgr recordPageMgr = new RecordBufferPageMgr(params.getRecordFactory(), blkMgrRecords);
    BPTreeRecordsMgr recordsMgr = new BPTreeRecordsMgr(bpt, params.getRecordFactory(), recordPageMgr);
    createIfAbsent(isReset, stateMgr, nodeManager, recordsMgr);
    bpt.init(stateMgr, nodeManager, recordsMgr);
    if (BPT.CheckingNode) {
        nodeManager.startRead();
        BPTreeNode root = nodeManager.getRead(bpt.getRootId(), BPlusTreeParams.RootParent);
        root.checkNodeDeep();
        nodeManager.release(root);
        nodeManager.finishRead();
    }
    return bpt;
}
Also used : RecordBufferPageMgr(org.apache.jena.dboe.base.recordbuffer.RecordBufferPageMgr)

Example 2 with RecordBufferPageMgr

use of org.apache.jena.dboe.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.dboe.base.recordbuffer.RecordBufferPageMgr) BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) RecordBufferPage(org.apache.jena.dboe.base.recordbuffer.RecordBufferPage) Test(org.junit.Test)

Example 3 with RecordBufferPageMgr

use of org.apache.jena.dboe.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.dboe.base.recordbuffer.RecordBufferPageMgr) BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) RecordBufferPage(org.apache.jena.dboe.base.recordbuffer.RecordBufferPage) Test(org.junit.Test)

Example 4 with RecordBufferPageMgr

use of org.apache.jena.dboe.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));
    // Write and convert to split pairs.
    Iterator<Pair<Integer, Record>> iter2 = Iter.map(iter, rbp -> {
        mgr.put(rbp);
        Record r = rbp.getRecordBuffer().getHigh();
        r = bpt.getRecordFactory().createKeyOnly(r);
        return new Pair<>(rbp.getId(), r);
    });
    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 will 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 : RecordBufferPageMgr(org.apache.jena.dboe.base.recordbuffer.RecordBufferPageMgr) Record(org.apache.jena.dboe.base.record.Record) RecordBufferPage(org.apache.jena.dboe.base.recordbuffer.RecordBufferPage) Pair(org.apache.jena.atlas.lib.Pair)

Example 5 with RecordBufferPageMgr

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

the class TestBPTreeRecordsNonTxn method beforeClass.

@BeforeClass
public static void beforeClass() {
    oldNullOut = SystemIndex.getNullOut();
    SystemIndex.setNullOut(true);
    // Which is 6 int records
    blockSize = 4 * 8;
    recordFactory = new RecordFactory(4, 0);
    bufSizeRecord = RecordBufferPage.calcRecordSize(recordFactory, blockSize);
    blkMgrRecords = BlockMgrFactory.createMem("BPTreeRecords", blockSize);
    recordBufferPageMgr = new RecordBufferPageMgr(recordFactory, blkMgrRecords);
    BlockMgr blkMgrNodes = BlockMgrFactory.createMem("BPTreeNs", blockSize);
    // Copy on write.
    BPT.forcePromoteModes = true;
    BPT.promoteDuplicateRecords = true;
}
Also used : RecordFactory(org.apache.jena.dboe.base.record.RecordFactory) RecordBufferPageMgr(org.apache.jena.dboe.base.recordbuffer.RecordBufferPageMgr) BlockMgr(org.apache.jena.dboe.base.block.BlockMgr)

Aggregations

RecordBufferPageMgr (org.apache.jena.dboe.base.recordbuffer.RecordBufferPageMgr)5 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)3 RecordBufferPage (org.apache.jena.dboe.base.recordbuffer.RecordBufferPage)3 Test (org.junit.Test)2 Pair (org.apache.jena.atlas.lib.Pair)1 Record (org.apache.jena.dboe.base.record.Record)1 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)1