public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames, Iteration<? extends BindingSet, E> bindingSetIter) throws E { this.bindingNames.addAll(bindingNames); Iterations.addAll(bindingSetIter, this.bindingSets); }
/** * Compares two graph query results and returns {@code true} if they are equal. Two graph query results * are considered equal if they are isomorphic graphs. Note that the method consumes both query results * fully. * * @param result1 * the first query result to compare * @param result2 * the second query result to compare. * @return {@code true} iff the supplied graph query results are isomorphic graphs, {@code false} * otherwise. * @throws QueryEvaluationException * @see {@link Models#isomorphic(Iterable, Iterable)} */ public static boolean equals(GraphQueryResult result1, GraphQueryResult result2) throws QueryEvaluationException { Set<? extends Statement> graph1 = Iterations.asSet(result1); Set<? extends Statement> graph2 = Iterations.asSet(result2); return Models.isomorphic(graph1, graph2); }
@Override public void close() throws IOException { Iterations.closeCloseable(iteration); } }
private CloseableIteration<Tuple, SailException> cachedIterator(CloseableIteration<Tuple, SailException> fromIterator) { try (Stream<Tuple> stream = Iterations.stream(fromIterator)) { List<Tuple> collect = stream.collect(Collectors.toList()); return new CloseableIteration<Tuple, SailException>() { Iterator<Tuple> iterator = collect.iterator(); @Override public void close() throws SailException { } @Override public boolean hasNext() throws SailException { return iterator.hasNext(); } @Override public Tuple next() throws SailException { return iterator.next(); } @Override public void remove() throws SailException { } }; } }
/** * Converts an Iteration to a string by concatenating all of the string representations of objects in the * Iteration, divided by a separator. * * @param iter * An Iteration over arbitrary objects that are expected to implement {@link Object#toString()}. * @param separator * The separator to insert between the object strings. * @return A String representation of the objects provided by the supplied Iteration. */ public static <X extends Exception> String toString(Iteration<?, X> iter, String separator) throws X { StringBuilder sb = new StringBuilder(); toString(iter, separator, sb); return sb.toString(); }
@Override public void close() throws IOException { Iterations.closeCloseable(iteration); } }
SimplePath(Resource id, SailRepositoryConnection connection) { super(id); try (Stream<Statement> stream = Iterations.stream(connection.getStatements(id, SHACL.PATH, null, true))) { path = stream.map(Statement::getObject).map(v -> (IRI) v).findAny().orElseThrow(() -> new RuntimeException("Expected to find sh:path on " + id)); } }
/** * Converts an Iteration to a string by concatenating all of the string representations of objects in the * Iteration, divided by a separator. * * @param iter * An Iteration over arbitrary objects that are expected to implement {@link Object#toString()}. * @param separator * The separator to insert between the object strings. * @return A String representation of the objects provided by the supplied Iteration. */ public static <X extends Exception> String toString(Iteration<?, X> iter, String separator) throws X { StringBuilder sb = new StringBuilder(); toString(iter, separator, sb); return sb.toString(); }
private <E extends Exception> ImmutableTupleQueryResult (final Collection<String> bindingNames, final Iteration<? extends BindingSet, E> iteration) throws E { this.bindingNames.addAll(bindingNames); Iterations.addAll(iteration, this.bindingSets); // this also closes iteration }
/** * Compares two graph query results and returns {@code true} if they are equal. Two graph query results * are considered equal if they are isomorphic graphs. Note that the method consumes both query results * fully. * * @param result1 * the first query result to compare * @param result2 * the second query result to compare. * @return {@code true} iff the supplied graph query results are isomorphic graphs, {@code false} * otherwise. * @throws QueryEvaluationException * @see {@link Models#isomorphic(Iterable, Iterable)} */ public static boolean equals(GraphQueryResult result1, GraphQueryResult result2) throws QueryEvaluationException { Set<? extends Statement> graph1 = Iterations.asSet(result1); Set<? extends Statement> graph2 = Iterations.asSet(result2); return Models.isomorphic(graph1, graph2); }
public static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException { List<BindingSet> list1 = Iterations.asList(tqr1); List<BindingSet> list2 = Iterations.asList(tqr2); // Compare the number of statements in both sets if (list1.size() > list2.size()) { return false; } return matchBindingSets(list1, list2); }
@Override public void close() throws IOException { Iterations.closeCloseable(iteration); } }
MinCountPropertyShape(Resource id, SailRepositoryConnection connection, Shape shape) { super(id, connection, shape); try (Stream<Statement> stream = Iterations.stream(connection.getStatements(id, SHACL.MIN_COUNT, null, true))) { minCount = stream.map(Statement::getObject).map(v -> (Literal) v).map(Literal::longValue).findAny().orElseThrow(() -> new RuntimeException("Expect to find sh:minCount on " + id)); } }
/** * Converts an Iteration to a string by concatenating all of the string representations of objects in the * Iteration, divided by a separator. * * @param iter * An Iteration over arbitrary objects that are expected to implement {@link Object#toString()}. * @param separator * The separator to insert between the object strings. * @return A String representation of the objects provided by the supplied Iteration. */ public static <X extends Exception> String toString(Iteration<?, X> iter, String separator) throws X { StringBuilder sb = new StringBuilder(); toString(iter, separator, sb); return sb.toString(); }
public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames, Iteration<? extends BindingSet, E> bindingSetIter) throws E { this.bindingNames.addAll(bindingNames); Iterations.addAll(bindingSetIter, this.bindingSets); }
/** * Compares two graph query results and returns {@code true} if they are equal. Two graph query results * are considered equal if they are isomorphic graphs. Note that the method consumes both query results * fully. * * @param result1 * the first query result to compare * @param result2 * the second query result to compare. * @return {@code true} iff the supplied graph query results are isomorphic graphs, {@code false} * otherwise. * @throws QueryEvaluationException * @see {@link Models#isomorphic(Iterable, Iterable)} */ public static boolean equals(GraphQueryResult result1, GraphQueryResult result2) throws QueryEvaluationException { Set<? extends Statement> graph1 = Iterations.asSet(result1); Set<? extends Statement> graph2 = Iterations.asSet(result2); return Models.isomorphic(graph1, graph2); }
public static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException { List<BindingSet> list1 = Iterations.asList(tqr1); List<BindingSet> list2 = Iterations.asList(tqr2); // Compare the number of statements in both sets if (list1.size() > list2.size()) { return false; } return matchBindingSets(list1, list2); }
@Override protected void handleClose() throws X { try { super.handleClose(); } finally { Iterations.closeCloseable(arg2); } }
DatatypePropertyShape(Resource id, SailRepositoryConnection connection, Shape shape) { super(id, connection, shape); try (Stream<Statement> stream = Iterations.stream(connection.getStatements(id, SHACL.DATATYPE, null, true))) { datatype = stream.map(Statement::getObject).map(v -> (Resource) v).findAny().orElseThrow(() -> new RuntimeException("Expected to find sh:datatype on " + id)); } }