Search in sources :

Example 1 with PipedQuadsStream

use of org.apache.jena.riot.lang.PipedQuadsStream in project jena by apache.

the class RDFDataMgr method createIteratorQuads.

/**
     * Creates an iterator over parsing of quads
     * @param input Input Stream
     * @param lang Language
     * @param baseIRI Base IRI
     * @return Iterator over the quads
     */
public static Iterator<Quad> createIteratorQuads(InputStream input, Lang lang, String baseIRI) {
    // Special case N-Quads, because the RIOT reader has a pull interface
    if (RDFLanguages.sameLang(RDFLanguages.NQUADS, lang)) {
        return new IteratorResourceClosing<>(RiotParsers.createIteratorNQuads(input, null, RiotLib.dftProfile()), input);
    }
    // Otherwise, we have to spin up a thread to deal with it
    final PipedRDFIterator<Quad> it = new PipedRDFIterator<>();
    final PipedQuadsStream out = new PipedQuadsStream(it);
    Thread t = new Thread(() -> parseFromInputStream(out, input, baseIRI, lang, null));
    t.start();
    return it;
}
Also used : Quad(org.apache.jena.sparql.core.Quad) IteratorResourceClosing(org.apache.jena.atlas.iterator.IteratorResourceClosing) PipedRDFIterator(org.apache.jena.riot.lang.PipedRDFIterator) PipedQuadsStream(org.apache.jena.riot.lang.PipedQuadsStream)

Aggregations

IteratorResourceClosing (org.apache.jena.atlas.iterator.IteratorResourceClosing)1 PipedQuadsStream (org.apache.jena.riot.lang.PipedQuadsStream)1 PipedRDFIterator (org.apache.jena.riot.lang.PipedRDFIterator)1 Quad (org.apache.jena.sparql.core.Quad)1