Class TableCursor<T,R>
java.lang.Object
com.datastax.astra.client.tables.cursor.TableCursor<T,R>
- Type Parameters:
T
- working bean of parent tableR
- working bean returned for the find
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Cloneable
,Iterable<R>
Implementation of a cursor across the find items
-
Constructor Summary
ConstructorDescriptionTableCursor
(Table<T> table, Filter filter, TableFindOptions options, Class<R> rowType) Cursor to iterate on the result of a query. -
Method Summary
Modifier and TypeMethodDescriptionclone()
void
close()
Change the state of the cursor to close.consumeBuffer
(int n) Consume the buffer and return the list of items.Immutable methods that return a new Cursor instance.int
Access the size of the buffer.Retrieve keyspace name.Access to the Sort Vector.boolean
hasNext()
Checks if there are more elements in the cursor.Creates a newTableCursor
that includes similarity scores in the results.Creates a newTableCursor
that includes sort vector metadata in the results.iterator()
Iterate over the cursor.limit
(int newLimit) Creates a newTableCursor
with a specified limit on the number of results.next()
Retrieves the next element from the cursor.project
(Projection... newProjection) Creates a newTableCursor
with an updated projection.skip
(int newSkip) Creates a newTableCursor
that skips a specified number of results.Creates a newTableCursor
with a specified sort order.toList()
Collects all remaining elements in the cursor into a list.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TableCursor
Cursor to iterate on the result of a query.- Parameters:
table
- source tablefilter
- current filteroptions
- options of the find operationrowType
- row type returned with the cursor
-
-
Method Details
-
clone
-
filter
Immutable methods that return a new Cursor instance.- Parameters:
newFilter
- a new filter- Returns:
- a new cursor
-
project
Creates a newTableCursor
with an updated projection.- Parameters:
newProjection
- the new projection to apply- Returns:
- a new
TableCursor
instance with the specified projection
-
sort
Creates a newTableCursor
with a specified sort order.- Parameters:
sort
- the sort criteria to apply- Returns:
- a new
TableCursor
instance with the specified sort order
-
limit
Creates a newTableCursor
with a specified limit on the number of results.- Parameters:
newLimit
- the maximum number of results to retrieve- Returns:
- a new
TableCursor
instance with the specified limit
-
skip
Creates a newTableCursor
that skips a specified number of results.- Parameters:
newSkip
- the number of results to skip- Returns:
- a new
TableCursor
instance with the specified skip value
-
includeSimilarity
Creates a newTableCursor
that includes similarity scores in the results.- Returns:
- a new
TableCursor
instance with similarity scores included
-
includeSortVector
Creates a newTableCursor
that includes sort vector metadata in the results.- Returns:
- a new
TableCursor
instance with sort vector metadata included
-
close
public void close()Change the state of the cursor to close.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
consumeBuffer
Consume the buffer and return the list of items.- Parameters:
n
- number of items to consume- Returns:
- list of items
-
iterator
Iterate over the cursor. -
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
-
getBufferedCount
public int getBufferedCount()Access the size of the buffer.- Returns:
- buffer count
-
getKeyspace
Retrieve keyspace name.- Returns:
- keyspace name
-
getSortVector
Access to the Sort Vector.- Returns:
- sort vector
-