Class FindIterable<T>

java.lang.Object
com.datastax.astra.client.model.PageableIterable<T>
com.datastax.astra.client.model.FindIterable<T>
Type Parameters:
T - The type of documents contained in the collection. This generic type allows FindIterable to be used with any type of document, making it a flexible solution for a wide variety of data models.
All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<T>

public class FindIterable<T> extends PageableIterable<T> implements Iterable<T>
Represents the result of a 'find' command executed on a collection, providing an iterable interface to navigate through the result set. This class extends PageableIterable to offer efficient, page-by-page iteration over the results, which is particularly useful for handling large datasets.

Utilizing a lazy-loading approach, FindIterable allows for seamless navigation through the result set without the necessity of loading all documents into memory at once. This makes it an ideal choice for applications that need to process or display large amounts of data with minimal memory footprint. As users iterate over the collection, subsequent pages of results are fetched as needed, ensuring efficient use of resources.

This approach is advantageous in scenarios where the full result set might be too large to store in memory comfortably or when only a portion of the results is needed by the application at any given time. By iterating over the results with FindIterable, applications can maintain lower memory usage while still having the flexibility to access the entire result set.

  • Field Details

    • currentPageIterator

      protected FindIterator<T> currentPageIterator
      Iterator on documents.
  • Constructor Details

    • FindIterable

      public FindIterable(Collection<T> collection, Filter filter, FindOptions options)
      Constructor for a cursor over the elements of the find.
      Parameters:
      collection - source collection client, use to fetch next pages
      filter - original filter used to renew the query
      options - list of options like the pageState, limit of skip
  • Method Details

    • iterator

      @NonNull public @NonNull FindIterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • all

      public List<T> all()
      Will exhaust the list and put all value in memory.
      Returns:
      all values of the iterable