Class AbstractCursor<T,R>

java.lang.Object
com.datastax.astra.internal.command.AbstractCursor<T,R>
Type Parameters:
T - working bean of parent table
R - working bean returned for the find
All Implemented Interfaces:
Cloneable, Iterable<R>
Direct Known Subclasses:
CollectionFindAndRerankCursor, CollectionFindCursor, TableFindCursor

public abstract class AbstractCursor<T,R> extends Object implements Iterable<R>, Cloneable
Implementation of a cursor across the find items
  • Field Details Link icon

    • state Link icon

      protected CursorState state
      Cursor state.
    • buffer Link icon

      protected List<R> buffer
      Records to process
    • currentPage Link icon

      protected Page<R> currentPage
      Current page
    • consumed Link icon

      protected int consumed
      How many consumed in the current buffer.
    • recordType Link icon

      protected Class<R> recordType
      Type of the row to return
  • Constructor Details Link icon

    • AbstractCursor Link icon

      protected AbstractCursor(Class<R> recordType)
      Cursor to iterate on the result of a query.
      Parameters:
      recordType - row type returned with the cursor
  • Method Details Link icon

    • close Link icon

      public void close()
      Change the state of the cursor to close.
    • rewind Link icon

      public void rewind()
      Rewind the cursor to the beginning.
    • consumeBuffer Link icon

      public List<R> consumeBuffer(int n)
      Consume the buffer and return the list of items.
      Parameters:
      n - number of items to consume
      Returns:
      list of items
    • checkIdleState Link icon

      protected void checkIdleState()
      Validate that the cursor is in the IDLE state.
    • iterator Link icon

      public Iterator<R> iterator()
      Iterate over the cursor.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      iterator over the results
    • fetchNextBatch Link icon

      protected abstract void fetchNextBatch()
      Fetches the next batch of documents into the buffer. This method handles paging, using the page state from the previous batch to fetch the next one.
    • hasNext Link icon

      public boolean hasNext()
      Checks if there are more elements in the cursor.
      Returns:
      true if there are more elements, false otherwise
    • next Link icon

      public R next()
      Retrieves the next element from the cursor.
      Returns:
      the next element of type R
      Throws:
      NoSuchElementException - if no more elements are available
    • toList Link icon

      public List<R> toList()
      Collects all remaining elements in the cursor into a list. Automatically closes the cursor after all elements are consumed.
      Returns:
      a List containing all remaining elements
    • stream Link icon

      public Stream<R> stream()
      Convert the current cursor as a stream
      Returns:
      current as a stream
    • getBufferedSize Link icon

      public int getBufferedSize()
      Access the size of the buffer.
      Returns:
      buffer count
    • getSortVector Link icon

      public Optional<DataAPIVector> getSortVector()
      Access to the Sort Vector.
      Returns:
      sort vector