Class CollectionDistinctIterable<T,F>
java.lang.Object
com.datastax.astra.client.core.paging.PageableIterable<T>
com.datastax.astra.client.collections.commands.cursor.CollectionDistinctIterable<T,F>
- Type Parameters:
T
- type of the document used in the associated collection.F
- type of the field we are looping on.
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<F>
Iterator to get all distinct value for a particular field.
-
Field Summary
Fields inherited from class com.datastax.astra.client.core.paging.PageableIterable
active, collection, currentPage, currentPageAvailable, exhausted, filter, options, totalItemProcessed
-
Constructor Summary
ConstructorDescriptionCollectionDistinctIterable
(Collection<T> collection, String fieldName, Filter filter, Class<F> fieldClass) Constructs an iterable that provides distinct elements from a specified collection, optionally filtered by a given criterion. -
Method Summary
Methods inherited from class com.datastax.astra.client.core.paging.PageableIterable
close, fetchNextPage, getSortVector
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
-
currentPageIterator
Iterator on fields.
-
-
Constructor Details
-
CollectionDistinctIterable
public CollectionDistinctIterable(Collection<T> collection, String fieldName, Filter filter, Class<F> fieldClass) Constructs an iterable that provides distinct elements from a specified collection, optionally filtered by a given criterion. This iterable allows for iterating over unique values of a specific field within the collection's documents, which can be particularly useful for data analysis, reporting, or implementing specific business logic that requires uniqueness in the dataset.The distinct elements are determined based on the
fieldName
parameter, ensuring that each value provided during iteration is unique with respect to this field across all documents in the collection. Thefilter
parameter allows for narrowing down the documents considered by this iterable, offering the capability to perform more targeted queries.- Parameters:
collection
- The source collection client, used to fetch documents and, if necessary, subsequent pages of results. This collection should be capable of executing queries and returning filtered results.fieldName
- The name of the field for which unique values are to be iterated over. This field's values are used to determine the distinctness of elements provided by this iterable.filter
- The original filter used to limit the documents considered for finding distinct values. This filter allows for the specification of criteria that documents must meet to be included in the iteration.fieldClass
- The class of the field values being iterated over. This parameter is used to ensure type safety and proper casting of the field values extracted from the documents in the collection.
-
-
Method Details