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());
}
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);
}
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);
}
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);
}
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();
}
Aggregations