public class QueryResults extends Iterations
Constructor and Description |
---|
QueryResults() |
Modifier and Type | Method and Description |
---|---|
static Model |
asModel(CloseableIteration<? extends Statement,? extends RDF4JException> iteration)
Get a
Model containing all elements obtained from the specified query result. |
static boolean |
bindingSetsCompatible(BindingSet bs1,
BindingSet bs2)
Check whether two
BindingSet s are compatible. |
static GraphQueryResult |
distinctResults(GraphQueryResult queryResult)
Returns a
GraphQueryResult that filters out any duplicate solutions from the supplied queryResult. |
static TupleQueryResult |
distinctResults(TupleQueryResult queryResult)
Returns a
TupleQueryResult that filters out any duplicate solutions from the supplied queryResult. |
static boolean |
equals(GraphQueryResult result1,
GraphQueryResult result2)
Compares two graph query results and returns
true if they are equal. |
static boolean |
equals(TupleQueryResult tqr1,
TupleQueryResult tqr2)
Compares two tuple query results and returns
true if they are equal. |
static boolean |
isSubset(TupleQueryResult tqr1,
TupleQueryResult tqr2) |
static GraphQueryResult |
limitResults(GraphQueryResult queryResult,
long limit,
long offset)
Returns a
GraphQueryResult that returns at most the specified maximum number of solutions, starting at
the supplied offset. |
static TupleQueryResult |
limitResults(TupleQueryResult queryResult,
long limit,
long offset)
Returns a
TupleQueryResult that returns at most the specified maximum number of solutions, starting at
the supplied offset. |
static GraphQueryResult |
parseGraphBackground(InputStream in,
String baseURI,
RDFFormat format)
Parses an RDF document and returns it as a GraphQueryResult object, with parsing done on a separate thread in the
background.
IMPORTANT: As this method will spawn a new thread in the background, it is vitally important that the resulting GraphQueryResult be closed consistently when it is no longer required, to prevent resource leaks. |
static void |
report(GraphQueryResult gqr,
RDFHandler rdfHandler)
Reports a graph query result to an
RDFHandler . |
static void |
report(TupleQueryResult tqr,
QueryResultHandler handler)
Reports a tuple query result to a
TupleQueryResultHandler . |
static Statement |
singleResult(GraphQueryResult result)
Returns a single element from the query result.
|
static BindingSet |
singleResult(TupleQueryResult result)
Returns a single element from the query result.
|
addAll, asList, asSet, closeCloseable, stream, toString, toString
public static Model asModel(CloseableIteration<? extends Statement,? extends RDF4JException> iteration) throws QueryEvaluationException
Model
containing all elements obtained from the specified query result.iteration
- the source iteration to get the statements from. This can be a GraphQueryResult
, a
RepositoryResult<Statement>
, or any other instance of <Statement>
Model
containing all statements obtained from the specified source iteration.QueryEvaluationException
public static Statement singleResult(GraphQueryResult result) throws QueryEvaluationException
QueryEvaluationException
public static BindingSet singleResult(TupleQueryResult result) throws QueryEvaluationException
QueryEvaluationException
public static GraphQueryResult distinctResults(GraphQueryResult queryResult)
GraphQueryResult
that filters out any duplicate solutions from the supplied queryResult.queryResult
- a queryResult containing possible duplicate statements.GraphQueryResult
with any duplicates filtered out.public static TupleQueryResult distinctResults(TupleQueryResult queryResult)
TupleQueryResult
that filters out any duplicate solutions from the supplied queryResult.queryResult
- a queryResult containing possible duplicate solutions.TupleQueryResult
with any duplicates filtered out.public static TupleQueryResult limitResults(TupleQueryResult queryResult, long limit, long offset)
TupleQueryResult
that returns at most the specified maximum number of solutions, starting at
the supplied offset.queryResult
- a query result possibly containing more solutions than the specified maximum.limit
- the maximum number of solutions to return. If set to 0 or lower, no limit will be applied.offset
- the number of solutions to skip at the beginning. If set to 0 or lower, no offset will be
applied.TupleQueryResult
that will at return at most the specified maximum number of solutions. If
neither limit
nor offset
are applied, this returns the original queryResult
.public static GraphQueryResult limitResults(GraphQueryResult queryResult, long limit, long offset)
GraphQueryResult
that returns at most the specified maximum number of solutions, starting at
the supplied offset.queryResult
- a query result possibly containing more solutions than the specified maximum.limit
- the maximum number of solutions to return. If set to 0 or lower, no limit will be applied.offset
- the number of solutions to skip at the beginning. If set to 0 or lower, no offset will be
applied.GraphQueryResult
that will at return at most the specified maximum number of solutions. If
neither limit
nor offset
are applied, this returns the original queryResult
.public static GraphQueryResult parseGraphBackground(InputStream in, String baseURI, RDFFormat format) throws UnsupportedRDFormatException
in
- The InputStream
containing the RDF document.baseURI
- The base URI for the RDF document.format
- The RDFFormat
of the RDF document.GraphQueryResult
that parses in the background, and must be closed to prevent resource leaks.UnsupportedRDFormatException
public static void report(TupleQueryResult tqr, QueryResultHandler handler) throws TupleQueryResultHandlerException, QueryEvaluationException
TupleQueryResultHandler
. CloseableIteration.close()
method will always be called before this method returns. QueryResultHandler.endQueryResult()
will not
be called.tqr
- The query result to report.handler
- The handler to report the query result to.TupleQueryResultHandlerException
- If such an exception is thrown by the used query result writer.QueryEvaluationException
public static void report(GraphQueryResult gqr, RDFHandler rdfHandler) throws RDFHandlerException, QueryEvaluationException
RDFHandler
. CloseableIteration.close()
method will always be called before this method returns.RDFHandler.endRDF()
will not be called.gqr
- The query result to report.rdfHandler
- The handler to report the query result to.RDFHandlerException
- If such an exception is thrown by the used RDF writer.QueryEvaluationException
public static boolean equals(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException
true
if they are equal. Tuple query results are equal if
they contain the same set of BindingSet
s and have the same headers. Blank nodes identifiers are not
relevant for equality, they are matched by trying to find compatible mappings between BindingSets. Note that the
method consumes both query results fully.tqr1
- the first TupleQueryResult
to compare.tqr2
- the second TupleQueryResult
to compare.QueryEvaluationException
public static boolean isSubset(TupleQueryResult tqr1, TupleQueryResult tqr2) throws QueryEvaluationException
QueryEvaluationException
public static boolean equals(GraphQueryResult result1, GraphQueryResult result2) throws QueryEvaluationException
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.result1
- the first query result to compareresult2
- the second query result to compare.true
iff the supplied graph query results are isomorphic graphs, false
otherwise.QueryEvaluationException
Models#isomorphic(Iterable, Iterable)}
public static boolean bindingSetsCompatible(BindingSet bs1, BindingSet bs2)
BindingSet
s are compatible. Two binding sets are compatible if they have equal values
for each binding name that occurs in both binding sets.Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.