- All Superinterfaces:
- All Known Implementing Classes:
public interface QueryResult<T> extends CloseableIterator<T>
The results of executing a
- Michael Grove
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description
close()Close the query results and return any resources in use back to the system.
metadata()Return any metadata associated with the query results, such as runtime, number of results, etc.
stream()Return the results as a
@Nonnull default Options metadata()Return any metadata associated with the query results, such as runtime, number of results, etc.
- the metadata
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:
- Implementation Requirements:
- A closed result set should return `false`
- Specified by:
java.lang.IllegalStateException- if the results have been closed
default java.util.stream.Stream<T> stream()Return the results as a
Stream. 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`.
- the results as a stream
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
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.