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