Search in sources :

Example 1 with BlockMgr

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

the class BPlusTreeFactory method addLogging.

/**
 * Debugging
 */
public static BPlusTree addLogging(BPlusTree bpTree) {
    BufferChannel mgrRoot = null;
    BlockMgr mgr1 = bpTree.getNodeManager().getBlockMgr();
    BlockMgr mgr2 = bpTree.getRecordsMgr().getBlockMgr();
    mgr1 = new BlockMgrLogger(mgr1, false);
    mgr2 = new BlockMgrLogger(mgr2, false);
    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) BlockMgrLogger(org.apache.jena.dboe.base.block.BlockMgrLogger)

Example 2 with BlockMgr

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

the class TestBPlusTreeRewriterNonTxn method runOneTest.

public static void runOneTest(int order, int N, RecordFactory recordFactory, boolean debug) {
    BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
    BPlusTreeRewriter.debug = debug;
    // ---- Test data
    List<Record> originaldata = TestBPlusTreeRewriterNonTxn.createData(N, recordFactory);
    if (debug)
        System.out.println("Test data: " + originaldata);
    FileSet destination = FileSet.mem();
    // ---- Rewrite
    BufferChannel rootState = FileFactory.createBufferChannel(destination, Names.extBptState);
    // Write leaves to ...
    BlockMgr blkMgr1 = BlockMgrFactory.create(destination, Names.extBptTree, bptParams.getCalcBlockSize(), 10, 10);
    // Write nodes to ...
    BlockMgr blkMgr2 = BlockMgrFactory.create(destination, Names.extBptTree, bptParams.getCalcBlockSize(), 10, 10);
    BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(originaldata.iterator(), bptParams, recordFactory, rootState, blkMgr1, blkMgr2);
    if (debug) {
        BPlusTreeRewriterUtils.divider();
        bpt2.dump();
    }
    // ---- Checking
    bpt2.check();
    scanComparision(originaldata, bpt2);
    findComparison(originaldata, bpt2);
    sizeComparison(originaldata, bpt2);
}
Also used : BPlusTreeParams(org.apache.jena.dboe.trans.bplustree.BPlusTreeParams) FileSet(org.apache.jena.dboe.base.file.FileSet) BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) Record(org.apache.jena.dboe.base.record.Record) BPlusTree(org.apache.jena.dboe.trans.bplustree.BPlusTree)

Example 3 with BlockMgr

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

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

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

the class ProcBuildIndexX method indexBuilder.

private static long indexBuilder(DatasetGraph dsg, InputStream input, String indexName) {
    long tickPoint = BulkLoaderX.DataTick;
    int superTick = BulkLoaderX.DataSuperTick;
    // Location of storage, not the DB.
    DatasetGraphTDB dsgtdb = TDBInternal.getDatasetGraphTDB(dsg);
    Location location = dsgtdb.getLocation();
    int keyLength = SystemTDB.SizeOfNodeId * indexName.length();
    int valueLength = 0;
    // The name is the order.
    String primary = indexName;
    String primaryOrder;
    int dftKeyLength;
    int dftValueLength;
    int tupleLength = indexName.length();
    TupleIndex index;
    if (tupleLength == 3) {
        primaryOrder = Names.primaryIndexTriples;
        dftKeyLength = SystemTDB.LenIndexTripleRecord;
        dftValueLength = 0;
        // Find index.
        index = findIndex(dsgtdb.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
    } else if (tupleLength == 4) {
        primaryOrder = Names.primaryIndexQuads;
        dftKeyLength = SystemTDB.LenIndexQuadRecord;
        dftValueLength = 0;
        index = findIndex(dsgtdb.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes(), indexName);
    } else {
        throw new TDBException("Index name: " + indexName);
    }
    TupleMap colMap = TupleMap.create(primaryOrder, indexName);
    int readCacheSize = 10;
    int writeCacheSize = 100;
    int blockSize = SystemTDB.BlockSize;
    RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength);
    int order = BPlusTreeParams.calcOrder(blockSize, recordFactory);
    BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
    int blockSizeNodes = blockSize;
    int blockSizeRecords = blockSize;
    FileSet destination = new FileSet(location, indexName);
    BufferChannel blkState = FileFactory.createBufferChannel(destination, Names.extBptState);
    BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.extBptTree, blockSizeNodes, readCacheSize, writeCacheSize);
    BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.extBptRecords, blockSizeRecords, readCacheSize, writeCacheSize);
    int rowBlock = 1000;
    Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
    // ProgressMonitor.
    ProgressMonitor monitor = ProgressMonitorOutput.create(BulkLoaderX.LOG_Index, indexName, tickPoint, superTick);
    ProgressIterator<Record> iter2 = new ProgressIterator<>(iter, monitor);
    monitor.start();
    BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter2, bptParams, recordFactory, blkState, blkMgrNodes, blkMgrRecords);
    bpt2.close();
    monitor.finish();
    // [BULK] End stage.
    long count = monitor.getTicks();
    return count;
}
Also used : BPlusTreeParams(org.apache.jena.dboe.trans.bplustree.BPlusTreeParams) FileSet(org.apache.jena.dboe.base.file.FileSet) TDBException(org.apache.jena.tdb2.TDBException) BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB) TupleMap(org.apache.jena.atlas.lib.tuple.TupleMap) ProgressIterator(org.apache.jena.system.progress.ProgressIterator) ProgressMonitor(org.apache.jena.system.progress.ProgressMonitor) RecordFactory(org.apache.jena.dboe.base.record.RecordFactory) BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) Record(org.apache.jena.dboe.base.record.Record) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex) BPlusTree(org.apache.jena.dboe.trans.bplustree.BPlusTree) Location(org.apache.jena.dboe.base.file.Location)

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