use of org.apache.jena.atlas.AtlasException in project jena by apache.
the class ProcNodeTableBuilder method exec.
public static void exec(Location location, String dataFileTriples, String dataFileQuads, List<String> datafiles, boolean collectStats) {
// 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 = ProgressMonitor.create(cmdLog, "Data", BulkLoader.DataTickPoint, BulkLoader.superTick);
OutputStream outputTriples = null;
OutputStream outputQuads = null;
try {
outputTriples = new FileOutputStream(dataFileTriples);
outputQuads = new FileOutputStream(dataFileQuads);
} catch (FileNotFoundException e) {
throw new AtlasException(e);
}
NodeTableBuilder sink = new NodeTableBuilder(dsg, monitor, outputTriples, outputQuads, collectStats);
monitor.start();
sink.startBulk();
for (String filename : datafiles) {
if (datafiles.size() > 0)
cmdLog.info("Load: " + filename + " -- " + DateTimeUtils.nowAsString());
RDFDataMgr.parse(sink, filename);
}
sink.finishBulk();
IO.close(outputTriples);
IO.close(outputQuads);
// See Stats class.
if (!location.isMem() && sink.getCollector() != null)
Stats.write(dsg.getLocation().getPath(Names.optStats), sink.getCollector().results());
// ---- Monitor
long time = monitor.finish();
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.AtlasException in project jena by apache.
the class WriteRows method flush.
public void flush() {
try {
output.write(b, 0, rows * rowLength);
} catch (IOException e) {
throw new AtlasException(e);
}
idx = 0;
rows = 0;
}
use of org.apache.jena.atlas.AtlasException in project jena by apache.
the class LogCtl method setJavaLoggingDft.
public static void setJavaLoggingDft() {
try {
InputStream details = new ByteArrayInputStream(defaultProperties.getBytes("UTF-8"));
java.util.logging.LogManager.getLogManager().readConfiguration(details);
} catch (Exception ex) {
throw new AtlasException(ex);
}
}
use of org.apache.jena.atlas.AtlasException in project jena by apache.
the class LogCtl method setJavaLogging.
public static void setJavaLogging(String file) {
try {
InputStream details = new FileInputStream(file);
details = new BufferedInputStream(details);
java.util.logging.LogManager.getLogManager().readConfiguration(details);
} catch (Exception ex) {
throw new AtlasException(ex);
}
}
use of org.apache.jena.atlas.AtlasException in project jena by apache.
the class InStreamASCII method read.
@Override
public int read(char[] cbuf, int off, int len) {
for (int i = off; i < off + len; i++) {
int x = read();
if (x == -1) {
if (i == off)
return -1;
return (i - off);
}
if (x > 128)
throw new AtlasException("Illegal ASCII character : " + x);
cbuf[i] = (char) x;
}
return len;
}
Aggregations