private static ClosableIterator < Tuple > doDistinct ( final MongoDBQueryDescriptor queryDescriptor , final MongoCollection < Document > collection ) { DistinctIterable < ? > distinctFieldValues = collection . distinct ( queryDescriptor . getDistinctFieldName ( ) , queryDescriptor . getCriteria ( ) , String . class ) ; Collation collation = getCollation ( queryDescriptor . getOptions ( ) ) ; distinctFieldValues = collation != null ? distinctFieldValues . collation ( collation ) : distinctFieldValues ; MongoCursor < ? > cursor = distinctFieldValues . iterator ( ) ; List < Object > documents = new ArrayList <> ( ) ; while ( cursor . hasNext ( ) ) { documents . add ( cursor . next ( ) ) ; } MapTupleSnapshot snapshot = new MapTupleSnapshot ( Collections . < String , Object > singletonMap ( "n" , documents ) ) ; return CollectionHelper . newClosableIterator ( Collections . singletonList ( new Tuple ( snapshot , SnapshotType . UNKNOWN ) ) ) ; }
do Distinct operation