Package com.stardog.stark.query
Class QueryResults
java.lang.Object
com.stardog.stark.query.QueryResults
Utilities for working with QueryResults
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove, Jeen Broekstra
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseQuietly(QueryResult<?> theResult) "Quietly"closetheQueryResult; any exception throw while closing will simply be logged.static voidconsume(QueryResult<?> theResult) Iterate over all of the results and close the result set.static booleanequals(SelectQueryResult tqr1, SelectQueryResult tqr2) Compares two tuple query results and returnstrueif they are equal.static booleanequalsWithOrder(SelectQueryResult tqr1, SelectQueryResult tqr2) Similar toequals(SelectQueryResult, SelectQueryResult)but also checks the order of binding sets.static booleanisSubset(SelectQueryResult tqr1, SelectQueryResult tqr2) Compares two tuple query results and returnstrueif the the first is a subset of the other.static voidreport(SelectQueryResult theResult, SelectQueryResultHandler theHandler) Iterate over the query result and send the results to the given handlerstatic <T> Optional<T> singleResult(QueryResult<T> theResult) Return the next result from the results and close the results.static longsize(QueryResult<?> theResult) Return the number of results present in this result setstatic <T> List<T> toList(QueryResult<T> theResult)
-
Method Details
-
toList
- Parameters:
theResult- the query result- Returns:
- the results as a `List`
- Implementation Notes:
- * This pulls all of the results into memory so it is not appropriate for a large result set.
* The side effect of this call is that `theResult` is
closed.
-
report
public static void report(@Nonnull SelectQueryResult theResult, @Nonnull SelectQueryResultHandler theHandler) Iterate over the query result and send the results to the given handler- Parameters:
theResult- the resulttheHandler- the result handler- Throws:
QueryExecutionFailure- if the next result could not be computed- Implementation Notes:
- The side effect of this call is that `theResult` is
closed.
-
singleResult
Return the next result from the results and close the results.- Parameters:
theResult- the result- Returns:
- the next result
- Throws:
QueryExecutionFailure- if the next result could not be computed- Implementation Notes:
- The side effect of this call is that `theResult` is
closed.
-
size
Return the number of results present in this result set- Parameters:
theResult- the results- Returns:
- the number of results
- Throws:
QueryExecutionFailure- if the results count not be computed- Implementation Notes:
- The side effect of this call is that `theResult` is exhausted and
closed.
-
consume
Iterate over all of the results and close the result set. The results of the query are simply thrown away.- Parameters:
theResult- the results- Throws:
QueryExecutionFailure- if the execution failed in any way
-
closeQuietly
"Quietly"closetheQueryResult; any exception throw while closing will simply be logged.- Parameters:
theResult- the result to close
-
equals
public static boolean equals(@Nonnull SelectQueryResult tqr1, @Nonnull SelectQueryResult tqr2) throws QueryExecutionFailure Compares two tuple query results and returnstrueif they are equal. Tuple query results are equal if they contain the same set ofBindingSets 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.- Parameters:
tqr1- the firstSelectQueryResultto compare.tqr2- the secondSelectQueryResultto compare.- Throws:
QueryExecutionFailure- Implementation Notes:
- This will consume both sets of results and they will both be closed as a side effect of calling this method. The results are also pulled into memory for the comparison, so this may not be suitable for use for large result sets.
-
equalsWithOrder
public static boolean equalsWithOrder(@Nonnull SelectQueryResult tqr1, @Nonnull SelectQueryResult tqr2) Similar toequals(SelectQueryResult, SelectQueryResult)but also checks the order of binding sets. -
isSubset
public static boolean isSubset(@Nonnull SelectQueryResult tqr1, @Nonnull SelectQueryResult tqr2) throws QueryExecutionFailure Compares two tuple query results and returnstrueif the the first is a subset of the other. Uses the same notion ofBindingSetequality asequals(SelectQueryResult, SelectQueryResult).- Parameters:
tqr1- the firstSelectQueryResultto compare.tqr2- the secondSelectQueryResultto compare.- Throws:
QueryExecutionFailure- Implementation Notes:
- This will consume both sets of results and they will both be closed as a side effect of calling this method. The results are also pulled into memory for the comparison, so this may not be suitable for use for large result sets.
-