65
65
import com .datastax .astra .client .exceptions .DataAPIException ;
66
66
import com .datastax .astra .client .exceptions .UnexpectedDataAPIResponseException ;
67
67
import com .datastax .astra .client .tables .commands .options .TableDistinctOptions ;
68
- import com .datastax .astra .client .tables .definition .rows .Row ;
69
68
import com .datastax .astra .internal .api .DataAPIResponse ;
70
69
import com .datastax .astra .internal .api .DataAPIStatus ;
71
70
import com .datastax .astra .internal .command .AbstractCommandRunner ;
72
71
import com .datastax .astra .internal .serdes .DataAPISerializer ;
73
72
import com .datastax .astra .internal .serdes .collections .DocumentSerializer ;
74
- import com .datastax .astra .internal .serdes .tables .RowMapper ;
75
73
import com .datastax .astra .internal .utils .Assert ;
76
74
import com .datastax .astra .internal .utils .BetaPreview ;
77
75
import com .datastax .astra .internal .utils .EscapeUtils ;
103
101
import static com .datastax .astra .client .core .options .DataAPIClientOptions .MAX_COUNT ;
104
102
import static com .datastax .astra .client .exceptions .DataAPIException .ERROR_CODE_INTERRUPTED ;
105
103
import static com .datastax .astra .client .exceptions .DataAPIException .ERROR_CODE_TIMEOUT ;
106
- import static com .datastax .astra .internal .serdes .tables .RowMapper .mapFromRow ;
107
104
import static com .datastax .astra .internal .utils .AnsiUtils .cyan ;
108
105
import static com .datastax .astra .internal .utils .AnsiUtils .green ;
109
106
import static com .datastax .astra .internal .utils .AnsiUtils .magenta ;
@@ -793,8 +790,8 @@ private Callable<CollectionInsertManyResult> getInsertManyResultCallable(List<?
793
790
Command insertMany = new Command ("insertMany" )
794
791
.withDocuments (documents .subList (start , end ))
795
792
.withOptions (new Document ()
796
- .append (INPUT_ORDERED , collectionInsertManyOptions .isOrdered ())
797
- .append (INPUT_RETURN_DOCUMENT_RESPONSES , collectionInsertManyOptions .isReturnDocumentResponses ()));
793
+ .append (OPTIONS_ORDERED , collectionInsertManyOptions .isOrdered ())
794
+ .append (OPTIONS_RETURN_DOCUMENT_RESPONSES , collectionInsertManyOptions .isReturnDocumentResponses ()));
798
795
799
796
DataAPIStatus status = runCommand (insertMany , collectionInsertManyOptions ).getStatus ();
800
797
CollectionInsertManyResult result = new CollectionInsertManyResult ();
@@ -894,8 +891,8 @@ public Optional<T> findOne(Filter filter, CollectionFindOneOptions findOneOption
894
891
.withSort (findOneOptions .getSortArray ())
895
892
.withProjection (findOneOptions .getProjectionArray ())
896
893
.withOptions (new Document ()
897
- .appendIfNotNull (INPUT_INCLUDE_SIMILARITY , findOneOptions .includeSimilarity ())
898
- .appendIfNotNull (INPUT_INCLUDE_SORT_VECTOR , findOneOptions .includeSortVector ())
894
+ .appendIfNotNull (OPTIONS_INCLUDE_SIMILARITY , findOneOptions .includeSimilarity ())
895
+ .appendIfNotNull (OPTIONS_INCLUDE_SORT_VECTOR , findOneOptions .includeSortVector ())
899
896
);
900
897
901
898
return Optional
@@ -1073,6 +1070,19 @@ public Page<T> findPage(Filter filter, CollectionFindOptions options) {
1073
1070
// --- Find and Rerank ----
1074
1071
// -----------------------------
1075
1072
1073
+ /**
1074
+ * Finds all documents in the collection.
1075
+ *
1076
+ * @param options
1077
+ * options of find one
1078
+ * @return
1079
+ * the find iterable interface
1080
+ */
1081
+ @ BetaPreview
1082
+ public CollectionFindAndRerankCursor <T ,T > findAndRerank (CollectionFindAndRerankOptions options ) {
1083
+ return findAndRerank (null , options , getDocumentClass ());
1084
+ }
1085
+
1076
1086
/**
1077
1087
* Finds all documents in the collection.
1078
1088
*
@@ -1093,6 +1103,7 @@ public <R> CollectionFindAndRerankCursor<T, R> findAndRerank(Filter filter, Coll
1093
1103
return new CollectionFindAndRerankCursor <>(this , filter , options , newRowType );
1094
1104
}
1095
1105
1106
+
1096
1107
@ BetaPreview
1097
1108
public <R > Page <RerankResult <R >> findAndRerankPage (Filter filter , CollectionFindAndRerankOptions options , Class <R > newRowType ) {
1098
1109
Command findAndRerankCommand = Command
@@ -1103,12 +1114,13 @@ public <R> Page<RerankResult<R>> findAndRerankPage(Filter filter, CollectionFind
1103
1114
.withSort (options .getSortArray ())
1104
1115
.withProjection (options .getProjectionArray ())
1105
1116
.withOptions (new Document ()
1106
- .appendIfNotNull ("rerankOn" , options .rerankOn ())
1107
- .appendIfNotNull ("limit" , options .limit ())
1108
- .appendIfNotNull ("hybridLimits" , options .hybridLimits ())
1109
- .appendIfNotNull (INPUT_INCLUDE_SORT_VECTOR , options .includeSortVector ())
1110
- .appendIfNotNull (INPUT_INCLUDE_SCORES , options .includeScores ())
1111
- .appendIfNotNull (INPUT_INCLUDE_SIMILARITY , options .includeSimilarity ()));
1117
+ .appendIfNotNull (OPTIONS_RERANK_QUERY , options .rerankQuery ())
1118
+ .appendIfNotNull (OPTIONS_RERANK_ON , options .rerankOn ())
1119
+ .appendIfNotNull (OPTIONS_LIMIT , options .limit ())
1120
+ .appendIfNotNull (OPTIONS_HYBRID_LIMITS , options .hybridLimits ())
1121
+ .appendIfNotNull (OPTIONS_INCLUDE_SORT_VECTOR , options .includeSortVector ())
1122
+ .appendIfNotNull (OPTIONS_INCLUDE_SCORES , options .includeScores ())
1123
+ );
1112
1124
}
1113
1125
1114
1126
// Responses MOCK for now
@@ -1183,9 +1195,9 @@ public <R> Page<R> findPage(Filter filter, CollectionFindOptions options, Class<
1183
1195
.withOptions (new Document ()
1184
1196
.appendIfNotNull ("skip" , options .skip ())
1185
1197
.appendIfNotNull ("limit" , options .limit ())
1186
- .appendIfNotNull (INPUT_PAGE_STATE , options .pageState ())
1187
- .appendIfNotNull (INPUT_INCLUDE_SORT_VECTOR , options .includeSortVector ())
1188
- .appendIfNotNull (INPUT_INCLUDE_SIMILARITY , options .includeSimilarity ()));
1198
+ .appendIfNotNull (OPTIONS_PAGE_STATE , options .pageState ())
1199
+ .appendIfNotNull (OPTIONS_INCLUDE_SORT_VECTOR , options .includeSortVector ())
1200
+ .appendIfNotNull (OPTIONS_INCLUDE_SIMILARITY , options .includeSimilarity ()));
1189
1201
}
1190
1202
DataAPIResponse apiResponse = runCommand (findCommand , options );
1191
1203
@@ -1619,8 +1631,8 @@ public Optional<T> findOneAndReplace(Filter filter, T replacement, CollectionFin
1619
1631
.withSort (options .getSortArray ())
1620
1632
.withProjection (options .getProjectionArray ())
1621
1633
.withOptions (new Document ()
1622
- .appendIfNotNull (INPUT_UPSERT , options .upsert ())
1623
- .appendIfNotNull (INPUT_RETURN_DOCUMENT , options .returnDocument ())
1634
+ .appendIfNotNull (OPTIONS_UPSERT , options .upsert ())
1635
+ .appendIfNotNull (OPTIONS_RETURN_DOCUMENT , options .returnDocument ())
1624
1636
);
1625
1637
1626
1638
DataAPIResponse res = runCommand (findOneAndReplace , options );
@@ -1667,8 +1679,8 @@ public CollectionUpdateResult replaceOne(Filter filter, T replacement, Collectio
1667
1679
.withFilter (filter )
1668
1680
.withReplacement (replacement )
1669
1681
.withOptions (new Document ()
1670
- .appendIfNotNull (INPUT_UPSERT , collectionReplaceOneOptions .upsert ())
1671
- .append (INPUT_RETURN_DOCUMENT , ReturnDocument .BEFORE .getKey ())
1682
+ .appendIfNotNull (OPTIONS_UPSERT , collectionReplaceOneOptions .upsert ())
1683
+ .append (OPTIONS_RETURN_DOCUMENT , ReturnDocument .BEFORE .getKey ())
1672
1684
);
1673
1685
1674
1686
// Execute the `findOneAndReplace`
@@ -1761,8 +1773,8 @@ public Optional<T> findOneAndUpdate(Filter filter, Update update, CollectionFind
1761
1773
.withSort (options .getSortArray ())
1762
1774
.withProjection (options .getProjectionArray ())
1763
1775
.withOptions (new Document ()
1764
- .appendIfNotNull (INPUT_UPSERT , options .upsert ())
1765
- .append (INPUT_RETURN_DOCUMENT , options .returnDocument ())
1776
+ .appendIfNotNull (OPTIONS_UPSERT , options .upsert ())
1777
+ .append (OPTIONS_RETURN_DOCUMENT , options .returnDocument ())
1766
1778
);
1767
1779
1768
1780
DataAPIResponse res = runCommand (cmd , options );
@@ -1810,7 +1822,7 @@ public CollectionUpdateResult updateOne(Filter filter, Update update, Collection
1810
1822
.withUpdate (update )
1811
1823
.withSort (updateOptions .getSortArray ())
1812
1824
.withOptions (new Document ()
1813
- .appendIfNotNull (INPUT_UPSERT , updateOptions .upsert ())
1825
+ .appendIfNotNull (OPTIONS_UPSERT , updateOptions .upsert ())
1814
1826
);
1815
1827
return getUpdateResult (runCommand (cmd , updateOptions ));
1816
1828
}
@@ -1879,8 +1891,8 @@ public CollectionUpdateResult updateMany(Filter filter, Update update, Collectio
1879
1891
.withFilter (filter )
1880
1892
.withUpdate (update )
1881
1893
.withOptions (new Document ()
1882
- .appendIfNotNull (INPUT_UPSERT , options .upsert ())
1883
- .appendIfNotNull (INPUT_PAGE_STATE , nextPageState ));
1894
+ .appendIfNotNull (OPTIONS_UPSERT , options .upsert ())
1895
+ .appendIfNotNull (OPTIONS_PAGE_STATE , nextPageState ));
1884
1896
DataAPIResponse res = runCommand (cmd , options );
1885
1897
// Data
1886
1898
if (res .getData () != null ) {
0 commit comments