Class CollectionCursor<T>
java.lang.Object
com.datastax.astra.client.collections.commands.cursor.CollectionCursor<T>
- Type Parameters:
T
- type of the table
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Cloneable
,Iterable<T>
Implementation of a cursor across the find items
-
Constructor Summary
ConstructorsConstructorDescriptionCollectionCursor
(Collection<T> col, Filter filter, CollectionFindOptions options) 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 results.Immutable methods that return a new Cursor instance.int
Access the size of the buffer.Retrieve keyspace name.boolean
hasNext()
Check if there is a next element.Includes similarity information in the results.Includes sort vector information in the results.iterator()
limit
(int newLimit) Sets a limit on the number of results returned by the cursor.next()
Retrieve the next element.project
(Projection... newProjection) Immutable methods that return a new Cursor instance.skip
(int newSkip) Skips the specified number of results.Applies a sorting order to the cursor.toList()
Retrieve all the elements in 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
-
CollectionCursor
Cursor to iterate on the result of a query.- Parameters:
col
- source collectionfilter
- current filteroptions
- options of the find operation
-
-
Method Details
-
clone
-
filter
Immutable methods that return a new Cursor instance.- Parameters:
newFilter
- a new filter- Returns:
- a new
CollectionCursor
instance with the filter applied
-
project
Immutable methods that return a new Cursor instance.- Parameters:
newProjection
- a new projection- Returns:
- a new
CollectionCursor
instance with the projection applied
-
sort
Applies a sorting order to the cursor. Creates a new instance of the cursor with the specified sort options applied.- Parameters:
sort
- the sort options to apply- Returns:
- a new
CollectionCursor
instance with the sorting applied - Throws:
IllegalStateException
- if the cursor is not in an idle state
-
limit
Sets a limit on the number of results returned by the cursor. Creates a new instance of the cursor with the specified limit applied.- Parameters:
newLimit
- the maximum number of results to return- Returns:
- a new
CollectionCursor
instance with the limit applied - Throws:
IllegalStateException
- if the cursor is not in an idle state
-
skip
Skips the specified number of results. Creates a new instance of the cursor with the specified skip applied.- Parameters:
newSkip
- the number of results to skip- Returns:
- a new
CollectionCursor
instance with the skip applied - Throws:
IllegalStateException
- if the cursor is not in an idle state
-
includeSimilarity
Includes similarity information in the results. Creates a new instance of the cursor with similarity information included.- Returns:
- a new
CollectionCursor
instance with similarity information included - Throws:
IllegalStateException
- if the cursor is not in an idle state
-
includeSortVector
Includes sort vector information in the results. Creates a new instance of the cursor with sort vector information included.- Returns:
- a new
CollectionCursor
instance with sort vector information included - Throws:
IllegalStateException
- if the cursor is not in an idle state
-
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 results.- Parameters:
n
- consume n elements from the buffer- Returns:
- list of results
-
iterator
-
hasNext
public boolean hasNext()Check if there is a next element.- Returns:
- true if there is a next element
-
next
Retrieve the next element.- Returns:
- next element
-
toList
Retrieve all the elements in a list.- Returns:
- list of elements
-
getBufferedCount
public int getBufferedCount()Access the size of the buffer.- Returns:
- buffer count
-
getKeyspace
Retrieve keyspace name.- Returns:
- keyspace name
-