Package com.stardog.stark.query
Interface QueryResult<T>
-
- All Superinterfaces:
java.lang.AutoCloseable
,CloseableIterator<T>
,java.util.Iterator<T>
- All Known Subinterfaces:
BooleanQueryResult
,GraphQueryResult
,PathQueryResult
,SelectQueryResult
- All Known Implementing Classes:
AsyncGraphQueryResult
,AsyncSelectQueryResult
,IteratorAsBooleanQueryResult
,IteratorAsGraphQueryResult
,IteratorAsPathQueryResult
,IteratorAsTupleQueryResult
,PathsAsTupleQueryResult
,TuplesAsPathQueryResult
public interface QueryResult<T> extends CloseableIterator<T>
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
Close the query results and return any resources in use back to the system.boolean
hasNext()
default Options
metadata()
Return any metadata associated with the query results, such as runtime, number of results, etc.T
next()
default java.util.stream.Stream<T>
stream()
Return the results as aStream
.
-
-
-
Method Detail
-
metadata
@Nonnull default Options 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceCloseableIterator<T>
- Throws:
java.lang.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()
- Specified by:
hasNext
in interfacejava.util.Iterator<T>
- Implementation Requirements:
- A closed result set should return `false`
-
next
T next()
- Specified by:
next
in interfacejava.util.Iterator<T>
- Throws:
java.lang.IllegalStateException
- if the results have been closed
-
stream
default java.util.stream.Stream<T> stream()
Return the results as aStream
. The `Stream` *must be*closed
when 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:
java.lang.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
ClosingSpliterator
to *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.
-
-