Search in sources :

Example 1 with TupleQueryResultBuilder

use of org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder in project rdf4j by eclipse.

the class RDF4JProtocolSession method getNamespaces.

/*---------------------------*
	 * Get/add/remove namespaces *
	 *---------------------------*/
public TupleQueryResult getNamespaces() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException {
    try {
        TupleQueryResultBuilder builder = new TupleQueryResultBuilder();
        getNamespaces(builder);
        return builder.getQueryResult();
    } catch (TupleQueryResultHandlerException e) {
        // Found a bug in TupleQueryResultBuilder?
        throw new RuntimeException(e);
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException)

Example 2 with TupleQueryResultBuilder

use of org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder in project rdf4j by eclipse.

the class RDF4JProtocolSession method getContextIDs.

/*-------------*
	 * Context IDs *
	 *-------------*/
public TupleQueryResult getContextIDs() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException {
    try {
        TupleQueryResultBuilder builder = new TupleQueryResultBuilder();
        getContextIDs(builder);
        return builder.getQueryResult();
    } catch (TupleQueryResultHandlerException e) {
        // Found a bug in TupleQueryResultBuilder?
        throw new RuntimeException(e);
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException)

Example 3 with TupleQueryResultBuilder

use of org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder in project rdf4j by eclipse.

the class RDF4JProtocolSession method getRepositoryList.

/*-----------------*
	 * Repository list *
	 *-----------------*/
public TupleQueryResult getRepositoryList() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException {
    try {
        TupleQueryResultBuilder builder = new TupleQueryResultBuilder();
        getRepositoryList(builder);
        return builder.getQueryResult();
    } catch (TupleQueryResultHandlerException e) {
        // Found a bug in TupleQueryResultBuilder?
        throw new RuntimeException(e);
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException)

Example 4 with TupleQueryResultBuilder

use of org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder in project rdf4j by eclipse.

the class DAWGTestResultSetUtil method toTupleQueryResult.

public static TupleQueryResult toTupleQueryResult(Iterable<? extends Statement> dawgGraph) throws DAWGTestResultSetParseException {
    TupleQueryResultBuilder tqrBuilder = new TupleQueryResultBuilder();
    DAWGTestResultSetParser parser = new DAWGTestResultSetParser(tqrBuilder);
    try {
        parser.startRDF();
        for (Statement st : dawgGraph) {
            parser.handleStatement(st);
        }
        parser.endRDF();
        return tqrBuilder.getQueryResult();
    } catch (RDFHandlerException e) {
        throw new DAWGTestResultSetParseException(e.getMessage(), e);
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) Statement(org.eclipse.rdf4j.model.Statement)

Example 5 with TupleQueryResultBuilder

use of org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder in project rdf4j by eclipse.

the class QueryResultIO method parseTupleInternal.

private static TupleQueryResult parseTupleInternal(InputStream in, QueryResultFormat format, boolean parseOnBackgroundThread) throws IOException, QueryResultParseException, TupleQueryResultHandlerException, UnsupportedQueryResultFormatException {
    TupleQueryResultParser parser = createTupleParser(format);
    if (parseOnBackgroundThread) {
        BackgroundTupleResult result = new BackgroundTupleResult(new QueueCursor<>(new LinkedBlockingQueue<>(1)), parser, in);
        // Start a new thread in the background, which will be completed
        // when the BackgroundTupleResult is either closed or interrupted
        boolean allGood = false;
        try {
            ForkJoinPool.commonPool().submit(result);
            allGood = true;
        } finally {
            if (!allGood) {
                result.close();
            }
        }
        return result;
    } else {
        TupleQueryResultBuilder qrBuilder = new TupleQueryResultBuilder();
        try {
            parser.setQueryResultHandler(qrBuilder).parseQueryResult(in);
        } catch (QueryResultHandlerException e) {
            if (e instanceof TupleQueryResultHandlerException) {
                throw (TupleQueryResultHandlerException) e;
            } else {
                throw new TupleQueryResultHandlerException(e);
            }
        }
        return qrBuilder.getQueryResult();
    }
}
Also used : TupleQueryResultBuilder(org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) BackgroundTupleResult(org.eclipse.rdf4j.query.resultio.helpers.BackgroundTupleResult) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) QueryResultHandlerException(org.eclipse.rdf4j.query.QueryResultHandlerException) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException)

Aggregations

TupleQueryResultBuilder (org.eclipse.rdf4j.query.impl.TupleQueryResultBuilder)5 TupleQueryResultHandlerException (org.eclipse.rdf4j.query.TupleQueryResultHandlerException)4 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 Statement (org.eclipse.rdf4j.model.Statement)1 QueryResultHandlerException (org.eclipse.rdf4j.query.QueryResultHandlerException)1 BackgroundTupleResult (org.eclipse.rdf4j.query.resultio.helpers.BackgroundTupleResult)1 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)1