Search in sources :

Example 16 with AtlasException

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);
}
Also used : ProgressMonitor(org.apache.jena.atlas.lib.ProgressMonitor) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) AtlasException(org.apache.jena.atlas.AtlasException) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB)

Example 17 with AtlasException

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;
}
Also used : IOException(java.io.IOException) AtlasException(org.apache.jena.atlas.AtlasException)

Example 18 with AtlasException

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);
    }
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException) AtlasException(org.apache.jena.atlas.AtlasException)

Example 19 with AtlasException

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);
    }
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException) AtlasException(org.apache.jena.atlas.AtlasException)

Example 20 with AtlasException

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;
}
Also used : AtlasException(org.apache.jena.atlas.AtlasException)

Aggregations

AtlasException (org.apache.jena.atlas.AtlasException)27 IOException (java.io.IOException)5 FileNotFoundException (java.io.FileNotFoundException)4 File (java.io.File)3 InputStream (java.io.InputStream)3 RiotParseException (org.apache.jena.riot.RiotParseException)3 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 Token (org.apache.jena.riot.tokens.Token)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 Iterator (java.util.Iterator)1 InStreamUTF8 (org.apache.jena.atlas.io.InStreamUTF8)1 InputStreamBuffered (org.apache.jena.atlas.io.InputStreamBuffered)1 IteratorResourceClosing (org.apache.jena.atlas.iterator.IteratorResourceClosing)1 ProgressMonitor (org.apache.jena.atlas.lib.ProgressMonitor)1 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)1 FileSet (org.apache.jena.tdb.base.file.FileSet)1 Location (org.apache.jena.tdb.base.file.Location)1