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

public interface QueryResult<T> extends CloseableIterator<T>

The results of executing a Query

Since:
1.0
Version:
1.0
Author:
Michael Grove
  • Method Details

    • 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 interface AutoCloseable
      Specified by:
      close in interface CloseableIterator<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()
      Specified by:
      hasNext in interface Iterator<T>
      Implementation Requirements:
      A closed result set should return `false`
    • next

      T next()
      Specified by:
      next in interface Iterator<T>
      Throws:
      IllegalStateException - if the results have been closed
    • stream

      default Stream<T> stream()
      Return the results as a Stream. 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:
      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.