Class FindIterator<T>

java.lang.Object
com.datastax.astra.client.model.FindIterator<T>
Type Parameters:
T - working document
All Implemented Interfaces:
Iterator<T>

public class FindIterator<T> extends Object implements Iterator<T>
Implementing a custom iterator that will load next page if needed when hitting the last item of page.
  • Constructor Details

    • FindIterator

      public FindIterator(PageableIterable<T> findIterable)
      Starting the cursor on an iterable to fetch more pages.
      Parameters:
      findIterable - iterable
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
    • next

      public T next()
      Implementing a logic of iterator combining current page and paging. An local iterator is started on elements of the processing page. If the local iterator is exhausted, the flag 'nextPageState' can tell us is there are more elements to retrieve. if 'nextPageState' is not null the next page is fetch at Iterable level and the local iterator is reinitialized on the new page.
      Specified by:
      next in interface Iterator<T>
      Returns:
      next document in the iterator
    • available

      public int available()
      Gets the number of results available locally without blocking, which may be 0.

      If the cursor is known to be exhausted, returns 0. If the cursor is closed before it's been exhausted, it may return a non-zero value.

      Returns:
      the number of results available locally without blocking
      Since:
      4.4