Class AbstractCursor<T,R>
java.lang.Object
com.datastax.astra.internal.command.AbstractCursor<T,R>
- Type Parameters:
T
- working bean of parent tableR
- working bean returned for the find
- Direct Known Subclasses:
CollectionFindAndRerankCursor
,CollectionFindCursor
,TableFindCursor
Implementation of a cursor across the find items
-
Field Summary
FieldsModifier and TypeFieldDescriptionRecords to processprotected int
How many consumed in the current buffer.Current pageType of the row to returnprotected CursorState
Cursor state. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCursor
(Class<R> recordType) Cursor to iterate on the result of a query. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Validate that the cursor is in the IDLE state.void
close()
Change the state of the cursor to close.consumeBuffer
(int n) Consume the buffer and return the list of items.protected abstract void
Fetches the next batch of documents into the buffer.int
Access the size of the buffer.Access to the Sort Vector.boolean
hasNext()
Checks if there are more elements in the cursor.iterator()
Iterate over the cursor.next()
Retrieves the next element from the cursor.void
rewind()
Rewind the cursor to the beginning.stream()
Convert the current cursor as a streamtoList()
Collects all remaining elements in the cursor into a list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
state
Cursor state. -
buffer
Records to process -
currentPage
Current page -
consumed
protected int consumedHow many consumed in the current buffer. -
recordType
Type of the row to return
-
-
Constructor Details
-
AbstractCursor
Cursor to iterate on the result of a query.- Parameters:
recordType
- row type returned with the cursor
-
-
Method Details
-
close
public void close()Change the state of the cursor to close. -
rewind
public void rewind()Rewind the cursor to the beginning. -
consumeBuffer
Consume the buffer and return the list of items.- Parameters:
n
- number of items to consume- Returns:
- list of items
-
checkIdleState
protected void checkIdleState()Validate that the cursor is in the IDLE state. -
iterator
Iterate over the cursor. -
fetchNextBatch
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
public boolean hasNext()Checks if there are more elements in the cursor.- Returns:
true
if there are more elements,false
otherwise
-
next
Retrieves the next element from the cursor.- Returns:
- the next element of type
R
- Throws:
NoSuchElementException
- if no more elements are available
-
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
Convert the current cursor as a stream- Returns:
- current as a stream
-
getBufferedSize
public int getBufferedSize()Access the size of the buffer.- Returns:
- buffer count
-
getSortVector
Access to the Sort Vector.- Returns:
- sort vector
-