Search in sources :

Example 6 with TupleIndex

use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.

the class LoaderMain method finishBulk.

@Override
public void finishBulk() {
    // Close off the data pipeline
    BulkProcesses.finish(dataProcess);
    boolean doTriples = countTriples() != 0;
    boolean doQuads = countQuads() != 0;
    if (doTriples) {
        TupleIndex srcIdx3 = PhasedOps.findInIndexMap(loaderPlan.primaryLoad3()[0], indexMap);
        TupleIndex[][] indexSets3 = PhasedOps.indexSetsFromNames(loaderPlan.secondaryIndex3(), indexMap);
        executeSecondary(srcIdx3, indexSets3, dsgtdb, output);
    }
    if (doQuads) {
        TupleIndex srcIdx4 = PhasedOps.findInIndexMap(loaderPlan.primaryLoad4()[0], indexMap);
        TupleIndex[][] indexSets4 = PhasedOps.indexSetsFromNames(loaderPlan.secondaryIndex4(), indexMap);
        executeSecondary(srcIdx4, indexSets4, dsgtdb, output);
    }
    super.finishBulk();
    dsgtdb.getTxnSystem().getTxnMgr().finishExclusiveMode();
}
Also used : TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex)

Example 7 with TupleIndex

use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.

the class TDB2StorageBuilder method buildPrefixTable.

private StoragePrefixesTDB buildPrefixTable(NodeTable prefixNodes) {
    String primary = params.getPrimaryIndexPrefix();
    String[] indexes = params.getPrefixIndexes();
    TupleIndex[] prefixIndexes = makeTupleIndexes(primary, indexes);
    if (prefixIndexes.length != 1)
        error(log, "Wrong number of triple table tuples indexes: " + prefixIndexes.length);
    // No cache - the prefix mapping is a cache
    // NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1);
    NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(), prefixIndexes, prefixNodes);
    StoragePrefixesTDB x = new StoragePrefixesTDB(txnSystem, prefixTable);
    // DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable);
    log.debug("Prefixes: " + primary + " :: " + String.join(",", indexes));
    return x;
}
Also used : NodeTupleTable(org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable) NodeTupleTableConcrete(org.apache.jena.tdb2.store.nodetupletable.NodeTupleTableConcrete) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex)

Example 8 with TupleIndex

use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.

the class TDB2StorageBuilder method makeTupleIndex.

private TupleIndex makeTupleIndex(String primary, String index, String name) {
    TupleMap cmap = TupleMap.create(primary, index);
    RecordFactory rf = new RecordFactory(SystemTDB.SizeOfNodeId * cmap.length(), 0);
    RangeIndex rIdx = makeRangeIndex(rf, index);
    TupleIndex tIdx = new TupleIndexRecord(primary.length(), cmap, index, rf, rIdx);
    return tIdx;
}
Also used : RecordFactory(org.apache.jena.dboe.base.record.RecordFactory) TupleIndexRecord(org.apache.jena.tdb2.store.tupletable.TupleIndexRecord) RangeIndex(org.apache.jena.dboe.index.RangeIndex) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex) TupleMap(org.apache.jena.atlas.lib.tuple.TupleMap)

Example 9 with TupleIndex

use of org.apache.jena.tdb2.store.tupletable.TupleIndex in project jena by apache.

the class BuilderSecondaryIndexes method createSecondaryIndexes.

public static void createSecondaryIndexes(MonitorOutput output, TupleIndex primaryIndex, TupleIndex[] secondaryIndexes) {
    boolean printTiming = true;
    for (TupleIndex index : secondaryIndexes) {
        String msg = primaryIndex.getName() + "->" + index.getName();
        if (index != null) {
            ProgressMonitor monitor = ProgressMonitorOutput.create(output, msg, LoaderSequential.IndexTickPoint, LoaderSequential.IndexSuperTick);
            monitor.startMessage(msg);
            monitor.start();
            LoaderOps.copyIndex(primaryIndex.all(), new TupleIndex[] { index }, monitor);
            monitor.finish();
            monitor.finishMessage(index.getName() + " indexing: ");
        }
    }
}
Also used : ProgressMonitor(org.apache.jena.system.progress.ProgressMonitor) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex)

Example 10 with TupleIndex

use of org.apache.jena.tdb2.store.tupletable.TupleIndex 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

TupleIndex (org.apache.jena.tdb2.store.tupletable.TupleIndex)8 NodeId (org.apache.jena.tdb2.store.NodeId)4 ProgressMonitor (org.apache.jena.system.progress.ProgressMonitor)3 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 TupleMap (org.apache.jena.atlas.lib.tuple.TupleMap)2 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)2 RangeIndex (org.apache.jena.dboe.index.RangeIndex)2 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)2 TDBException (org.apache.jena.tdb2.TDBException)2 TupleIndexRecord (org.apache.jena.tdb2.store.tupletable.TupleIndexRecord)2 List (java.util.List)1 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)1 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)1 FileSet (org.apache.jena.dboe.base.file.FileSet)1 Location (org.apache.jena.dboe.base.file.Location)1 Record (org.apache.jena.dboe.base.record.Record)1 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)1 ProgressIterator (org.apache.jena.system.progress.ProgressIterator)1 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)1 StoragePrefixesTDB (org.apache.jena.tdb2.store.StoragePrefixesTDB)1