Class DistinctIterator<T,F>

java.lang.Object
com.datastax.astra.client.model.DistinctIterator<T,F>
Type Parameters:
T - working class representing the document
F - working class representing the field to extract from the document.
All Implemented Interfaces:
Iterator<F>

public class DistinctIterator<T,F> extends Object implements Iterator<F>
Iterator to retrieve distinct values of a field in a document.
  • Constructor Details

    • DistinctIterator

      public DistinctIterator(PageableIterable<T> findIterable, String fieldName, Class<F> fieldClass)
      Starting the cursor on an iterable to fetch more pages.
      Parameters:
      findIterable - iterable
      fieldName - name of the field to pick
      fieldClass - type of the field to pick
  • Method Details

    • hasNext

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

      public F next()
      Implementing a logic of iterator combining current page and paging. A 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