@Override public void close() { try { tupleResult.close(); } catch (StoreException e1) { throw new RepositoryException(e1); } }
public MutableTupleResult(TupleResult tqr) throws StoreException { this(tqr.getBindingNames(), tqr); }
@Override public boolean hasNext() { try { return tupleResult.hasNext(); } catch (StoreException e) { throw new RepositoryException(e); } }
/** * Reports a tuple query result to a {@link TupleQueryResultHandler}. * * @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(TupleResult tqr, TupleQueryResultHandler handler) throws TupleQueryResultHandlerException, StoreException { handler.startQueryResult(tqr.getBindingNames()); try { while (tqr.hasNext()) { BindingSet bindingSet = tqr.next(); handler.handleSolution(bindingSet); } } finally { tqr.close(); } handler.endQueryResult(); }
public static Model toGraph(TupleResult tqr) throws StoreException { Model model = new LinkedHashModel(); DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(model)); 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 model; }
@Override public Map<String, NODE> next() { try { BindingSet bindingSet = tupleResult.next(); Map<String, NODE> row = new HashMap<String, NODE>(); for (String name : tupleResult.getBindingNames()) { Value value = bindingSet.getValue(name); if (value != null) { row.put(name, dialect.getNODE(value)); } else if (bindings.containsKey(name)) { row.put(name, bindings.get(name)); } } return row; } catch (StoreException e) { throw new RepositoryException(e); } }
/** * Compares the two query results by converting them to graphs and returns * true if they are equal. QueryResults are equal if they contain the same * set of BindingSet and have the headers. Blank nodes identifiers are not * relevant for equality, they are mapped from one model to the other by * using the attached properties. Note that the method consumes both query * results fully. * * @throws StoreException */ public static boolean equals(TupleResult tqr1, TupleResult tqr2) throws StoreException { List<BindingSet> list1 = tqr1.asList(); List<BindingSet> list2 = tqr2.asList(); // Compare the number of statements in both sets if (list1.size() != list2.size()) { return false; } return matchBindingSets(list1, list2); }
@Override public Map<String, NODE> next() { try { BindingSet bindingSet = tupleResult.next(); Map<String,NODE> row = new HashMap<String,NODE>(); for (String name : tupleResult.getBindingNames()){ Value value = bindingSet.getValue(name); if (value != null){ row.put(name, dialect.getNODE(value)); }else if (bindings.containsKey(name)){ row.put(name, bindings.get(name)); } } return row; } catch (StoreException e) { throw new RepositoryException(e); } }
@Override public List<String> getVariables() { try { return getResult().getBindingNames(); } catch (StoreException e) { throw new RepositoryException(e); } }
@Override public boolean hasNext() { try { return tupleResult.hasNext(); } catch (StoreException e) { throw new RepositoryException(e); } }
@Override public void close() { try { tupleResult.close(); } catch (StoreException e1) { throw new RepositoryException(e1); } }
@Override public List<String> getVariables() { try { return getResult().getBindingNames(); } catch (StoreException e) { throw new RepositoryException(e); } }