Search in sources :

Example 1 with ProgressMonitor

use of org.apache.jena.system.progress.ProgressMonitor 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 2 with ProgressMonitor

use of org.apache.jena.system.progress.ProgressMonitor in project jena by apache.

the class ProcNodeTableDataBuilder method exec.

public static void exec(Location location, String dataFileTriples, String dataFileQuads, List<String> datafiles, boolean collectStats) {
    // Possible parser speed up. This has no effect if parsing in parallel
    // because the parser isn't the slowest step in loading at scale.
    IRIProvider provider = SystemIRIx.getProvider();
    // SystemIRIx.setProvider(new IRIProviderAny());
    // This formats the location correctly.
    // But we're not really interested in it all.
    DatasetGraphTDB dsg = DatasetBuilderStd.create(location);
    // so close indexes and the prefix table.
    dsg.getTripleTable().getNodeTupleTable().getTupleTable().close();
    dsg.getQuadTable().getNodeTupleTable().getTupleTable().close();
    ProgressMonitor monitor = ProgressMonitorOutput.create(cmdLog, "Data", BulkLoader.DataTickPoint, BulkLoader.superTick);
    // WriteRows does it's own buffering and has direct write-to-buffer.
    // Do not buffer here.
    OutputStream outputTriples = IO.openOutputFile(dataFileTriples);
    OutputStream outputQuads = IO.openOutputFile(dataFileQuads);
    build(dsg, monitor, outputTriples, outputQuads, datafiles);
    TDBInternal.expel(dsg);
    SystemIRIx.setProvider(provider);
}
Also used : ProgressMonitor(org.apache.jena.system.progress.ProgressMonitor) OutputStream(java.io.OutputStream) IRIProvider(org.apache.jena.irix.IRIProvider) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

Example 3 with ProgressMonitor

use of org.apache.jena.system.progress.ProgressMonitor in project jena by apache.

the class ProcIndexCopy method tupleIndexCopy.

private static void tupleIndexCopy(TupleIndex index1, TupleIndex index2, String label) {
    ProgressMonitor monitor = ProgressMonitorOutput.create(log, label, tickQuantum, superTick);
    Timer timer = new Timer();
    timer.startTimer();
    monitor.start();
    Iterator<Tuple<NodeId>> iter1 = index1.all();
    long counter = 0;
    for (; iter1.hasNext(); ) {
        counter++;
        Tuple<NodeId> tuple = iter1.next();
        index2.add(tuple);
        monitor.tick();
    }
    index2.sync();
    monitor.finish();
    long time = timer.endTimer();
    float elapsedSecs = time / 1000F;
    float rate = (elapsedSecs != 0) ? counter / elapsedSecs : 0;
    print("Total: %,d records : %,.2f seconds : %,.2f records/sec [%s]", counter, elapsedSecs, rate, DateTimeUtils.nowAsString());
}
Also used : ProgressMonitor(org.apache.jena.system.progress.ProgressMonitor) Timer(org.apache.jena.atlas.lib.Timer) NodeId(org.apache.jena.tdb.store.NodeId) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Example 4 with ProgressMonitor

use of org.apache.jena.system.progress.ProgressMonitor in project jena by apache.

the class LoaderBase method load.

@Override
public void load(List<String> filenames) {
    if (filenames.isEmpty()) {
        output.print("No files to load");
        return;
    }
    ProgressMonitor monitor = createProgressMonitor(output);
    boolean multipleFiles = (filenames.size() > 1);
    String file1 = null;
    if (!multipleFiles) {
        file1 = filenames.get(0);
        if (file1.equals("-"))
            file1 = "stdin";
    }
    try {
        if (multipleFiles)
            monitor.startMessage("Start: " + filenames.size() + " files");
        else
            monitor.startMessage("Start: " + file1);
        monitor.start();
        filenames.forEach(fn -> {
            if (multipleFiles)
                monitor.startSection();
            loadOne(fn, monitor);
            if (multipleFiles)
                monitor.finishSection();
        });
        monitor.finish();
        if (multipleFiles)
            monitor.finishMessage("Finished: " + filenames.size() + " files");
        else
            monitor.finishMessage("Finished: " + file1);
    } catch (Exception ex) {
        finishException(ex);
        throw ex;
    }
}
Also used : ProgressMonitor(org.apache.jena.system.progress.ProgressMonitor)

Example 5 with ProgressMonitor

use of org.apache.jena.system.progress.ProgressMonitor 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)

Aggregations

ProgressMonitor (org.apache.jena.system.progress.ProgressMonitor)7 OutputStream (java.io.OutputStream)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 IRIProvider (org.apache.jena.irix.IRIProvider)2 TupleIndex (org.apache.jena.tdb2.store.tupletable.TupleIndex)2 IOException (java.io.IOException)1 JsonObject (org.apache.jena.atlas.json.JsonObject)1 BitsLong (org.apache.jena.atlas.lib.BitsLong)1 Timer (org.apache.jena.atlas.lib.Timer)1 TupleMap (org.apache.jena.atlas.lib.tuple.TupleMap)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 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)1 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)1 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 ProgressIterator (org.apache.jena.system.progress.ProgressIterator)1