Package com.stardog.stark.query
Interface QueryResult<T>
- All Superinterfaces:
AutoCloseable,CloseableIterator<T>,Iterator<T>
- All Known Subinterfaces:
BooleanQueryResult,GraphQueryResult,PathQueryResult,SelectQueryResult
- All Known Implementing Classes:
AsyncGraphQueryResult,AsyncSelectQueryResult,IteratorAsBooleanQueryResult,IteratorAsGraphQueryResult,IteratorAsPathQueryResult,IteratorAsTupleQueryResult,PathsAsTupleQueryResult,TuplesAsPathQueryResult
The results of executing a Query
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.complexible.common.base.CloseableIterator
CloseableIterator.AbstractCloseableIterator<T>, CloseableIterator.DelegatingCloseableIterator<T>, CloseableIterator.EmptyCloseableIterator<T> -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the query results and return any resources in use back to the system.booleanhasNext()default Optionsmetadata()Return any metadata associated with the query results, such as runtime, number of results, etc.next()stream()Return the results as aStream.Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Method Details
-
metadata
Return any metadata associated with the query results, such as runtime, number of results, etc.- Returns:
- the metadata
-
close
void close()Close the query results and return any resources in use back to the system. This *must* be called on all result sets to avoid resource leaks.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseableIterator<T>- Throws:
RuntimeException- if there was a fatal error while closing- Implementation Requirements:
- Once closed, a result cannot be re-used. Additionally, close is idempotent.
-
hasNext
boolean hasNext() -
next
T next()- Specified by:
nextin interfaceIterator<T>- Throws:
IllegalStateException- if the results have been closed
-
stream
Return the results as aStream. The `Stream` *must be*closedwhen no longer in use so that the results are closed. Optionally, the caller can close the results directly after using the `Stream`.- Returns:
- the results as a stream
- Throws:
IllegalStateException- Obtaining the stream, or iterating through the stream can throw this exception of the underlying results are closed at any time.- Implementation Notes:
- The underlying `Stream` is `Spliterator.IMMUTABLE | Spliterator.NONNULL` and *NOT* parallel.
Additionally, the `Stream` uses
ClosingSpliteratorto *auto-close* these results when the last item is iterated over in an effort to help users who are forgetful about closing Streams since that is not common.
-