public MutableTupleQueryResult(TupleQueryResult tqr) throws QueryEvaluationException { this(tqr.getBindingNames(), tqr); }
TupleQueryResultIteration(TupleQueryResult queryResult) throws QueryEvaluationException { this.queryResult = queryResult; this.bindingNames = queryResult.getBindingNames(); }
@Override public List<String> getBindingNames() throws QueryEvaluationException { return unfiltered.getBindingNames(); }
@Override public List<String> getBindingNames() throws QueryEvaluationException { return unfiltered.getBindingNames(); }
public MutableTupleQueryResult(TupleQueryResult tqr) throws QueryEvaluationException { this(tqr.getBindingNames(), tqr); }
public ImmutableTupleQueryResult (final TupleQueryResult tqr) throws QueryEvaluationException { this(tqr.getBindingNames(), tqr); }
@Override public List<String> getBindingNames() throws QueryEvaluationException { return unfiltered.getBindingNames(); }
public MutableTupleQueryResult(TupleQueryResult tqr) throws QueryEvaluationException { this(tqr.getBindingNames(), tqr); }
@Override public List<String> getBindingNames() throws QueryEvaluationException { return result.getBindingNames(); }
@Override public List<String> getResultVars() { try { return result.getBindingNames(); } catch (QueryEvaluationException e) { throw new RuntimeException(e); } }
/** * Returns a {@link TupleQueryResult} that returns at most the specified maximum number of solutions, * starting at the supplied offset. * * @param queryResult * a query result possibly containing more solutions than the specified maximum. * @param limit * the maximum number of solutions to return. If set to 0 or lower, no limit will be applied. * @param offset * the number of solutions to skip at the beginning. If set to 0 or lower, no offset will be * applied. * @return A {@link TupleQueryResult} that will at return at most the specified maximum number of * solutions. If neither {@code limit} nor {@code offset} are applied, this returns the original * {@code queryResult}. */ public static TupleQueryResult limitResults(TupleQueryResult queryResult, long limit, long offset) { CloseableIteration<BindingSet, QueryEvaluationException> iter = queryResult; if (offset > 0) { iter = new OffsetIteration<>(iter, offset); } if (limit > 0) { iter = new LimitIteration<>(iter, limit); } if (!(iter instanceof TupleQueryResult)) { return new IteratingTupleQueryResult(queryResult.getBindingNames(), iter); } return (TupleQueryResult)iter; }
/** * Returns a {@link TupleQueryResult} that returns at most the specified maximum number of solutions, * starting at the supplied offset. * * @param queryResult * a query result possibly containing more solutions than the specified maximum. * @param limit * the maximum number of solutions to return. If set to 0 or lower, no limit will be applied. * @param offset * the number of solutions to skip at the beginning. If set to 0 or lower, no offset will be * applied. * @return A {@link TupleQueryResult} that will at return at most the specified maximum number of * solutions. If neither {@code limit} nor {@code offset} are applied, this returns the original * {@code queryResult}. */ public static TupleQueryResult limitResults(TupleQueryResult queryResult, long limit, long offset) { CloseableIteration<BindingSet, QueryEvaluationException> iter = queryResult; if (offset > 0) { iter = new OffsetIteration<>(iter, offset); } if (limit > 0) { iter = new LimitIteration<>(iter, limit); } if (!(iter instanceof TupleQueryResult)) { return new IteratingTupleQueryResult(queryResult.getBindingNames(), iter); } return (TupleQueryResult)iter; }
@Override public void evaluate(TupleQueryResultHandler handler) throws QueryEvaluationException, TupleQueryResultHandlerException { TupleQueryResult result = evaluate(); handler.startQueryResult(result.getBindingNames()); while (result.hasNext()) { handler.handleSolution(result.next()); } handler.endQueryResult(); }
@Override public void evaluate(TupleQueryResultHandler handler) throws QueryEvaluationException, TupleQueryResultHandlerException { TupleQueryResult result = evaluate(); handler.startQueryResult(result.getBindingNames()); while (result.hasNext()) { handler.handleSolution(result.next()); } handler.endQueryResult(); }
/** * */ @Override public void evaluate(TupleQueryResultHandler handler) throws QueryEvaluationException, TupleQueryResultHandlerException { TupleQueryResult result = evaluate(); handler.startQueryResult(result.getBindingNames()); while (result.hasNext()) { handler.handleSolution(result.next()); } handler.endQueryResult(); }
public static Graph toGraph(TupleQueryResult tqr) throws QueryEvaluationException { Graph graph = new GraphImpl(); DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(graph)); try { writer.startQueryResult(tqr.getBindingNames()); while (tqr.hasNext()) { writer.handleSolution(tqr.next()); } writer.endQueryResult(); } catch (TupleQueryResultHandlerException e) { // No exceptions expected from DAWGTestResultSetWriter or // StatementCollector, foud a bug? throw new RuntimeException(e); } return graph; }
public static Graph toGraph(TupleQueryResult tqr) throws QueryEvaluationException { Graph graph = new GraphImpl(); DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(graph)); try { writer.startQueryResult(tqr.getBindingNames()); while (tqr.hasNext()) { writer.handleSolution(tqr.next()); } writer.endQueryResult(); } catch (TupleQueryResultHandlerException e) { // No exceptions expected from DAWGTestResultSetWriter or // StatementCollector, foud a bug? throw new RuntimeException(e); } return graph; }
public static Graph toGraph(TupleQueryResult tqr) throws QueryEvaluationException { Graph graph = new GraphImpl(); DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(graph)); try { writer.startQueryResult(tqr.getBindingNames()); while (tqr.hasNext()) { writer.handleSolution(tqr.next()); } writer.endQueryResult(); } catch (TupleQueryResultHandlerException e) { // No exceptions expected from DAWGTestResultSetWriter or // StatementCollector, foud a bug? throw new RuntimeException(e); } return graph; }
/** * Reports a tuple query result to a {@link TupleQueryResultHandler}. <br> * The {@link TupleQueryResult#close()} method will always be called before this method returns. <br> * If there is an exception generated by the TupleQueryResult, {@link QueryResultHandler#endQueryResult()} * will not be called. * * @param tqr * The query result to report. * @param handler * The handler to report the query result to. * @throws TupleQueryResultHandlerException * If such an exception is thrown by the used query result writer. */ public static void report(TupleQueryResult tqr, QueryResultHandler handler) throws TupleQueryResultHandlerException, QueryEvaluationException { try { handler.startQueryResult(tqr.getBindingNames()); while (tqr.hasNext()) { BindingSet bindingSet = tqr.next(); handler.handleSolution(bindingSet); } } finally { tqr.close(); } handler.endQueryResult(); }
/** * Reports a tuple query result to a {@link TupleQueryResultHandler}. <br> * The {@link TupleQueryResult#close()} method will always be called before this method returns. <br> * If there is an exception generated by the TupleQueryResult, {@link QueryResultHandler#endQueryResult()} * will not be called. * * @param tqr * The query result to report. * @param handler * The handler to report the query result to. * @throws TupleQueryResultHandlerException * If such an exception is thrown by the used query result writer. */ public static void report(TupleQueryResult tqr, QueryResultHandler handler) throws TupleQueryResultHandlerException, QueryEvaluationException { try { handler.startQueryResult(tqr.getBindingNames()); while (tqr.hasNext()) { BindingSet bindingSet = tqr.next(); handler.handleSolution(bindingSet); } } finally { tqr.close(); } handler.endQueryResult(); }