Interface QueryResult<T>

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

        T next()
        Specified by:
        next in interface java.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 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:
        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.