Search in sources :

Example 6 with BlockMgr

use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.

the class BPlusTreeFactory method addTracking.

/**
 * Debugging
 */
public static BPlusTree addTracking(BPlusTree bpTree) {
    BufferChannel mgrRoot = null;
    BlockMgr mgr1 = bpTree.getNodeManager().getBlockMgr();
    BlockMgr mgr2 = bpTree.getRecordsMgr().getBlockMgr();
    mgr1 = BlockTracker.track(mgr1);
    mgr2 = BlockTracker.track(mgr2);
    return BPlusTreeFactory.rebuild(bpTree, mgrRoot, mgr1, mgr2);
}
Also used : BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) BufferChannel(org.apache.jena.dboe.base.file.BufferChannel)

Example 7 with BlockMgr

use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.

the class BPlusTreeFactory method makeMem.

/**
 * (Testing mainly) Make an in-memory B+Tree, with copy-in, copy-out block managers
 */
public static BPlusTree makeMem(String name, int order, int minDataRecords, int keyLength, int valueLength) {
    if (name == null)
        name = "Mem";
    BPlusTreeParams params = new BPlusTreeParams(order, keyLength, valueLength);
    int blkSize;
    if (minDataRecords > 0) {
        int maxDataRecords = 2 * minDataRecords;
        // int rSize = RecordBufferPage.HEADER+(maxRecords*params.getRecordLength());
        blkSize = RecordBufferPage.calcBlockSize(params.getRecordFactory(), maxDataRecords);
    } else
        blkSize = params.getCalcBlockSize();
    // By FileSet
    BufferChannel chan = BufferChannelMem.create(name + "(root)");
    BlockMgr mgr1 = BlockMgrFactory.createMem(name + "(nodes)", params.getCalcBlockSize());
    BlockMgr mgr2 = BlockMgrFactory.createMem(name + "(records)", blkSize);
    ComponentId cid = ComponentId.allocLocal();
    BPlusTree bpTree = BPlusTreeFactory.create(cid, params, chan, mgr1, mgr2);
    return bpTree;
}
Also used : BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) ComponentId(org.apache.jena.dboe.transaction.txn.ComponentId)

Example 8 with BlockMgr

use of org.apache.jena.dboe.base.block.BlockMgr in project jena by apache.

the class BPlusTreeFactory method createBPTree.

/**
 * Knowing all the parameters, create a B+Tree
 */
public static BPlusTree createBPTree(ComponentId cid, FileSet fileset, int order, int blockSize, int readCacheSize, int writeCacheSize, RecordFactory factory) {
    // ---- Checking
    if (blockSize < 0 && order < 0)
        throw new IllegalArgumentException("Neither blocksize nor order specified");
    if (blockSize >= 0 && order < 0)
        order = BPlusTreeParams.calcOrder(blockSize, factory.recordLength());
    if (blockSize >= 0 && order >= 0) {
        int order2 = BPlusTreeParams.calcOrder(blockSize, factory.recordLength());
        if (order != order2)
            throw new IllegalArgumentException("Wrong order (" + order + "), calculated = " + order2);
    }
    // Iffy - does not allow for slop.
    if (blockSize < 0 && order >= 0) {
        // Only in-memory.
        blockSize = BPlusTreeParams.calcBlockSize(order, factory);
    }
    BPlusTreeParams params = new BPlusTreeParams(order, factory);
    BufferChannel bptState = FileFactory.createBufferChannel(fileset, Names.extBptState);
    BlockMgr blkMgrNodes = BlockMgrFactory.create(fileset, Names.extBptTree, blockSize, readCacheSize, writeCacheSize);
    BlockMgr blkMgrRecords = BlockMgrFactory.create(fileset, Names.extBptRecords, blockSize, readCacheSize, writeCacheSize);
    return BPlusTreeFactory.create(cid, params, bptState, blkMgrNodes, blkMgrRecords);
}
Also used : BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) BufferChannel(org.apache.jena.dboe.base.file.BufferChannel)

Example 9 with BlockMgr

use of org.apache.jena.dboe.base.block.BlockMgr 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

BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)9 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)6 RecordBufferPageMgr (org.apache.jena.dboe.base.recordbuffer.RecordBufferPageMgr)3 FileSet (org.apache.jena.dboe.base.file.FileSet)2 Record (org.apache.jena.dboe.base.record.Record)2 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)2 RecordBufferPage (org.apache.jena.dboe.base.recordbuffer.RecordBufferPage)2 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)2 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)2 Test (org.junit.Test)2 TupleMap (org.apache.jena.atlas.lib.tuple.TupleMap)1 BlockMgrLogger (org.apache.jena.dboe.base.block.BlockMgrLogger)1 Location (org.apache.jena.dboe.base.file.Location)1 ComponentId (org.apache.jena.dboe.transaction.txn.ComponentId)1 ProgressIterator (org.apache.jena.system.progress.ProgressIterator)1 ProgressMonitor (org.apache.jena.system.progress.ProgressMonitor)1 TDBException (org.apache.jena.tdb2.TDBException)1 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)1 TupleIndex (org.apache.jena.tdb2.store.tupletable.TupleIndex)1