Search in sources :

Example 11 with BlockMgr

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

the class SetupIndex method createBPTree.

/** Knowing all the parameters, create a B+Tree */
public static BPlusTree createBPTree(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);
    BlockMgr blkMgrNodes = BlockMgrFactory.create(fileset, Names.bptExtTree, blockSize, readCacheSize, writeCacheSize);
    BlockMgr blkMgrRecords = BlockMgrFactory.create(fileset, Names.bptExtRecords, blockSize, readCacheSize, writeCacheSize);
    return BPlusTree.create(params, blkMgrNodes, blkMgrRecords);
}
Also used : BPlusTreeParams(org.apache.jena.tdb.index.bplustree.BPlusTreeParams) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr)

Example 12 with BlockMgr

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

the class BPlusTree method addTracking.

/** Debugging */
public static BPlusTree addTracking(BPlusTree bpTree) {
    BlockMgr mgr1 = bpTree.getNodeManager().getBlockMgr();
    BlockMgr mgr2 = bpTree.getRecordsMgr().getBlockMgr();
    //        mgr1 = BlockMgrTracker.track("BPT/Nodes", mgr1) ;
    //        mgr2 = BlockMgrTracker.track("BPT/Records", mgr2) ;
    mgr1 = BlockMgrTracker.track(mgr1);
    mgr2 = BlockMgrTracker.track(mgr2);
    return BPlusTree.attach(bpTree.getParams(), mgr1, mgr2);
}
Also used : BlockMgr(org.apache.jena.tdb.base.block.BlockMgr)

Example 13 with BlockMgr

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

Example 14 with BlockMgr

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

the class TestExtHash method makeIndex.

@Override
protected Index makeIndex(int kLen, int vLen) {
    RecordFactory factory = new RecordFactory(kLen, vLen);
    BlockMgr mgr = BlockMgrFactory.createMem("EXT", 32);
    ExtHash eHash = new ExtHash(new PlainFileMem(), factory, mgr);
    return eHash;
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) ExtHash(org.apache.jena.tdb.index.ext.ExtHash) PlainFileMem(org.apache.jena.tdb.base.file.PlainFileMem)

Aggregations

BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)14 FileSet (org.apache.jena.tdb.base.file.FileSet)3 Record (org.apache.jena.tdb.base.record.Record)3 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)3 BPlusTreeParams (org.apache.jena.tdb.index.bplustree.BPlusTreeParams)3 BaseTest (org.apache.jena.atlas.junit.BaseTest)2 PlainFileMem (org.apache.jena.tdb.base.file.PlainFileMem)2 RecordBufferPage (org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)2 RecordBufferPageMgr (org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr)2 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)2 Test (org.junit.Test)2 InputStream (java.io.InputStream)1 AtlasException (org.apache.jena.atlas.AtlasException)1 BlockMgrFileAccess (org.apache.jena.tdb.base.block.BlockMgrFileAccess)1 BlockAccess (org.apache.jena.tdb.base.file.BlockAccess)1 BlockAccessDirect (org.apache.jena.tdb.base.file.BlockAccessDirect)1 BufferChannel (org.apache.jena.tdb.base.file.BufferChannel)1 Location (org.apache.jena.tdb.base.file.Location)1 RangeIndex (org.apache.jena.tdb.index.RangeIndex)1 ExtHash (org.apache.jena.tdb.index.ext.ExtHash)1