Search in sources :

Example 1 with Timer

use of org.apache.jena.atlas.lib.Timer 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 2 with Timer

use of org.apache.jena.atlas.lib.Timer in project jena by apache.

the class ProcNodeTableDataBuilder method build.

private static void build(DatasetGraph dsg, ProgressMonitor monitor, OutputStream outputTriples, OutputStream outputQuads, List<String> datafiles) {
    DatasetGraphTDB dsgtdb = TDBInternal.getDatasetGraphTDB(dsg);
    NodeTableBuilder sink = new NodeTableBuilder(dsgtdb, monitor, outputTriples, outputQuads, false);
    Timer timer = new Timer();
    timer.startTimer();
    monitor.start();
    sink.startBulk();
    AsyncParser.asyncParse(datafiles, sink);
    // for( String filename : datafiles) {
    // if ( datafiles.size() > 0 )
    // cmdLog.info("Load: "+filename+" -- "+DateTimeUtils.nowAsString());
    // RDFParser.source(filename).parse(sink);
    // }
    sink.finishBulk();
    IO.close(outputTriples);
    IO.close(outputQuads);
    // See Stats class.
    if (sink.getCollector() != null) {
        Location location = dsgtdb.getLocation();
        if (!location.isMem())
            Stats.write(location.getPath(Names.optStats), sink.getCollector().results());
    }
    // ---- Monitor
    monitor.finish();
    long time = timer.endTimer();
    long total = monitor.getTicks();
    float elapsedSecs = time / 1000F;
    float rate = (elapsedSecs != 0) ? total / elapsedSecs : 0;
    String str = String.format("Total: %,d tuples : %,.2f seconds : %,.2f tuples/sec [%s]", total, elapsedSecs, rate, DateTimeUtils.nowAsString());
    cmdLog.info(str);
}
Also used : Timer(org.apache.jena.atlas.lib.Timer) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) Location(org.apache.jena.tdb.base.file.Location)

Example 3 with Timer

use of org.apache.jena.atlas.lib.Timer in project jena by apache.

the class BuilderSecondaryIndexesInterleaved method createSecondaryIndexes.

// Do as one pass over the SPO index, creating both other indexes at the same time.
// Can be hugely costly in system resources.
@Override
public void createSecondaryIndexes(TupleIndex primaryIndex, TupleIndex[] secondaryIndexes) {
    Timer timer = new Timer();
    timer.startTimer();
    long time1 = timer.readTimer();
    LoaderNodeTupleTable.copyIndex(primaryIndex.all(), secondaryIndexes, "All", monitor);
    long time2 = timer.readTimer();
    monitor.print("Time for all indexes: %.2fs\n", (time2 - time1) / 1000.0);
}
Also used : Timer(org.apache.jena.atlas.lib.Timer)

Example 4 with Timer

use of org.apache.jena.atlas.lib.Timer in project jena by apache.

the class BuilderSecondaryIndexesParallel method createSecondaryIndexes.

@Override
public void createSecondaryIndexes(TupleIndex primaryIndex, TupleIndex[] secondaryIndexes) {
    monitor.print("** Parallel index building");
    Timer timer = new Timer();
    timer.startTimer();
    int semaCount = 0;
    Semaphore sema = new Semaphore(0);
    for (TupleIndex index : secondaryIndexes) {
        if (index != null) {
            Runnable builder = setup(sema, primaryIndex, index, index.getMappingStr());
            new Thread(builder).start();
            semaCount++;
        }
    }
    try {
        sema.acquire(semaCount);
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
    long time = timer.readTimer();
    timer.endTimer();
    monitor.print("Time for parallel indexing: %.2fs\n", time / 1000.0);
}
Also used : Timer(org.apache.jena.atlas.lib.Timer) Semaphore(java.util.concurrent.Semaphore) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Example 5 with Timer

use of org.apache.jena.atlas.lib.Timer in project jena by apache.

the class SinkProgress method resetTimer.

public void resetTimer() {
    if (timer != null)
        timer.endTimer();
    timer = new Timer();
    timer.startTimer();
}
Also used : Timer(org.apache.jena.atlas.lib.Timer)

Aggregations

Timer (org.apache.jena.atlas.lib.Timer)15 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)2 InputStream (java.io.InputStream)1 Semaphore (java.util.concurrent.Semaphore)1 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 Location (org.apache.jena.dboe.base.file.Location)1 Token (org.apache.jena.riot.tokens.Token)1 Tokenizer (org.apache.jena.riot.tokens.Tokenizer)1 ProgressMonitor (org.apache.jena.system.progress.ProgressMonitor)1 Location (org.apache.jena.tdb.base.file.Location)1 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)1 NodeId (org.apache.jena.tdb.store.NodeId)1 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)1