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