Search in sources :

Example 1 with TupleIndex

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

the class LoaderOps method copyIndex.

/**
 * Copy a stream to several indexes (sequential version)
 */
public static void copyIndex(Iterator<Tuple<NodeId>> srcIter, TupleIndex[] destIndexes, ProgressMonitor monitor) {
    long counter = 0;
    for (; srcIter.hasNext(); ) {
        counter++;
        Tuple<NodeId> tuple = srcIter.next();
        monitor.tick();
        for (TupleIndex destIdx : destIndexes) {
            if (destIdx != null)
                destIdx.add(tuple);
        }
    }
}
Also used : NodeId(org.apache.jena.tdb2.store.NodeId) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex)

Example 2 with TupleIndex

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

the class LoaderOps method idxBTree.

/**
 * Get the BPlusTree index for a {@Link TupleIndex}
 */
public static BPlusTree idxBTree(TupleIndex idx) {
    TupleIndexRecord idxr = (TupleIndexRecord) idx;
    RangeIndex rIndex = idxr.getRangeIndex();
    BPlusTree bpt = (BPlusTree) rIndex;
    return bpt;
}
Also used : TupleIndexRecord(org.apache.jena.tdb2.store.tupletable.TupleIndexRecord) RangeIndex(org.apache.jena.dboe.index.RangeIndex) BPlusTree(org.apache.jena.dboe.trans.bplustree.BPlusTree)

Example 3 with TupleIndex

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

the class Indexer method startBulk.

/**
 * Start the threads that will do the indexing
 */
@Override
public void startBulk() {
    for (int i = 0; i < N; i++) {
        TupleIndex idx = indexes[i];
        BlockingQueue<List<Tuple<NodeId>>> pipe = pipesTripleIndexers[i];
        new Thread(() -> stageIndex(pipe, idx)).start();
    }
}
Also used : NodeId(org.apache.jena.tdb2.store.NodeId) List(java.util.List) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex)

Example 4 with TupleIndex

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

the class PhasedOps method replay.

/**
 * Return (Number, Time in ms)
 */
static ReplayResult replay(TupleIndex srcIdx, Destination<Tuple<NodeId>> dest, MonitorOutput output) {
    ProgressMonitor monitor = ProgressMonitorFactory.progressMonitor("Index", output, LoaderMain.IndexTickPoint, LoaderMain.IndexSuperTick);
    List<Tuple<NodeId>> block = null;
    int len = srcIdx.getTupleLength();
    monitor.start();
    Iterator<Tuple<NodeId>> iter = srcIdx.all();
    while (iter.hasNext()) {
        if (block == null)
            block = new ArrayList<>(LoaderConst.ChunkSize);
        Tuple<NodeId> row = iter.next();
        block.add(row);
        monitor.tick();
        if (block.size() == LoaderConst.ChunkSize) {
            dest.deliver(block);
            block = null;
        }
    }
    if (block != null)
        dest.deliver(block);
    dest.deliver(Collections.emptyList());
    monitor.finish();
    // monitor.finishMessage("Tuples["+len+"]");
    return new ReplayResult(monitor.getTicks(), monitor.getTime());
}
Also used : ProgressMonitor(org.apache.jena.system.progress.ProgressMonitor) NodeId(org.apache.jena.tdb2.store.NodeId) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Example 5 with TupleIndex

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

the class LoaderMain method executeData.

/**
 * Create data ingestion and primary index building of a {@link LoaderPlan}.
 * In phase 1, separate threads for parsing, node table loading and primary index building,
 *
 * Used by {@link InputStage#MULTI}.
 */
private static StreamRDFCounting executeData(LoaderPlan loaderPlan, DatasetGraphTDB dsgtdb, Map<String, TupleIndex> indexMap, List<BulkStartFinish> dataProcess, MonitorOutput output) {
    StoragePrefixesTDB dps = (StoragePrefixesTDB) dsgtdb.getStoragePrefixes();
    PrefixHandlerBulk prefixHandler = new PrefixHandlerBulk(dps, output);
    dataProcess.add(prefixHandler);
    // -- Phase 2 block. Indexer and Destination (blocks of Tuple<NodeId>)
    TupleIndex[] idx3 = PhasedOps.indexSetFromNames(loaderPlan.primaryLoad3(), indexMap);
    Indexer indexer3 = new Indexer(output, idx3);
    TupleIndex[] idx4 = PhasedOps.indexSetFromNames(loaderPlan.primaryLoad4(), indexMap);
    Indexer indexer4 = new Indexer(output, idx4);
    dataProcess.add(indexer3);
    dataProcess.add(indexer4);
    Destination<Tuple<NodeId>> functionIndexer3 = indexer3.index();
    Destination<Tuple<NodeId>> functionIndexer4 = indexer4.index();
    // -- Phase 2 block.
    // -- Phase 1.
    // This is the other way round to AsyncParser.
    // Here, we return a StreamRDF to pump data into and the rest of the
    // processing is on other threads. AsyncParser has the processing on the caller thread
    // and so the current thread continues when the processing from the parser is finished.
    DataToTuples dtt = new DataToTuples(dsgtdb, functionIndexer3, functionIndexer4, output);
    DataBatcher dataBatcher = new DataBatcher(dtt.data(), prefixHandler.handler(), output);
    dataProcess.add(dtt);
    dataProcess.add(dataBatcher);
    return dataBatcher;
}
Also used : StoragePrefixesTDB(org.apache.jena.tdb2.store.StoragePrefixesTDB) TupleIndex(org.apache.jena.tdb2.store.tupletable.TupleIndex) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

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