Search in sources :

Example 6 with RecordFactory

use of org.apache.jena.dboe.base.record.RecordFactory 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)

Example 7 with RecordFactory

use of org.apache.jena.dboe.base.record.RecordFactory in project jena by apache.

the class BPlusTreeFactory method makeBPlusTree.

public static RangeIndex makeBPlusTree(ComponentId cid, FileSet fs, int blkSize, int readCacheSize, int writeCacheSize, int dftKeyLength, int dftValueLength) {
    RecordFactory recordFactory = makeRecordFactory(dftKeyLength, dftValueLength);
    int order = BPlusTreeParams.calcOrder(blkSize, recordFactory.recordLength());
    RangeIndex rIndex = createBPTree(cid, fs, order, blkSize, readCacheSize, writeCacheSize, recordFactory);
    return rIndex;
}
Also used : RecordFactory(org.apache.jena.dboe.base.record.RecordFactory) RangeIndex(org.apache.jena.dboe.index.RangeIndex)

Example 8 with RecordFactory

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

RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)8 RangeIndex (org.apache.jena.dboe.index.RangeIndex)4 NodeTableTRDF (org.apache.jena.tdb2.store.nodetable.NodeTableTRDF)3 TupleIndex (org.apache.jena.tdb2.store.tupletable.TupleIndex)3 TupleMap (org.apache.jena.atlas.lib.tuple.TupleMap)2 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)2 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)2 FileSet (org.apache.jena.dboe.base.file.FileSet)2 Record (org.apache.jena.dboe.base.record.Record)2 Index (org.apache.jena.dboe.index.Index)2 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)2 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)2 NodeTable (org.apache.jena.tdb2.store.nodetable.NodeTable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1