Interface TupleIterator

All Superinterfaces:
AutoCloseable, Iterator<Tuple>
All Known Implementing Classes:
Singleton

public interface TupleIterator extends Iterator<Tuple>, AutoCloseable

Brings together the AutoCloseable and Iterator interface fo Iterators that come from Relations, so that iterators can clean up any resources they are derived from.

  • Field Details

  • Method Details

    • wrapped

      static TupleIterator wrapped(@NonNull @NonNull Iterator<Tuple> iterator, @NonNull @NonNull Optional<Runnable> onClose)

      Wraps a normal iterator with this interface, making the close a noop. TODO - maybe add an optional callback for closing?

    • wrappedAndMapped

      static <T> TupleIterator wrappedAndMapped(@NonNull @NonNull Iterator<T> iterator, @NonNull @NonNull Function<T,Tuple> mapper)

      Wraps a possibly normal Iterator with this interface, applying the given mapping functions to values yielded from the Tuple

    • close

      default void close()
      Specified by:
      close in interface AutoCloseable
    • collect

      default <A, R> R collect(Collector<? super Tuple,A,R> collector)

      Collect all values from this tuple iterator in to the given Collector, and ensures the iterator is closed.

      Returns:
      the result of Collection
    • forEachRemaining

      default void forEachRemaining(Consumer<? super Tuple> action)

      Pass each tuple to the given consumer, closing the iterator once complete (or if in exception is thrown)

      Specified by:
      forEachRemaining in interface Iterator<Tuple>
    • singleton

      static TupleIterator singleton(Tuple tuple)
      Returns:
      a TupleIterator that yields a single, fixed result.