use of org.eclipse.rdf4j.query.resultio.helpers.BackgroundTupleResult in project rdf4j by eclipse.
the class BackgroundResultExecutor method parse.
public TupleQueryResult parse(TupleQueryResultParser parser, InputStream in) {
BackgroundTupleResult result = new BackgroundTupleResult(parser, in);
autoCloseRunnable(result, result);
return result;
}
use of org.eclipse.rdf4j.query.resultio.helpers.BackgroundTupleResult 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