55
55
import com .datastax .astra .client .core .types .UUIDv6 ;
56
56
import com .datastax .astra .client .core .types .UUIDv7 ;
57
57
import com .datastax .astra .client .databases .Database ;
58
- import com .datastax .astra .client .exception .DataAPIFaultyResponseException ;
58
+ import com .datastax .astra .client .exception .UnexpectedDataAPIResponseException ;
59
59
import com .datastax .astra .client .exception .DataAPIException ;
60
- import com .datastax .astra .client .exception .TooManyDocumentsToCountException ;
61
- import com .datastax .astra .internal .api .ApiResponse ;
60
+ import com .datastax .astra .client .collections .exceptions .TooManyDocumentsToCountException ;
61
+ import com .datastax .astra .internal .api .DataAPIResponse ;
62
+ import com .datastax .astra .internal .api .DataAPIStatus ;
62
63
import com .datastax .astra .internal .command .AbstractCommandRunner ;
63
64
import com .datastax .astra .internal .command .CommandObserver ;
64
65
import com .datastax .astra .internal .serdes .DataAPISerializer ;
@@ -632,8 +633,8 @@ public InsertManyResult insertMany(List<? extends T> documents, InsertManyOption
632
633
if (options .getConcurrency () > 1 && options .isOrdered ()) {
633
634
throw new IllegalArgumentException ("Cannot run ordered insert_many concurrently." );
634
635
}
635
- if (options .getChunkSize () > dataAPIOptions .getMaxDocumentsInInsert ()) {
636
- throw new IllegalArgumentException ("Cannot insert more than " + dataAPIOptions .getMaxDocumentsInInsert () + " at a time." );
636
+ if (options .getChunkSize () > dataAPIOptions .getMaxRecordsInInsert ()) {
637
+ throw new IllegalArgumentException ("Cannot insert more than " + dataAPIOptions .getMaxRecordsInInsert () + " at a time." );
637
638
}
638
639
long start = System .currentTimeMillis ();
639
640
ExecutorService executor = Executors .newFixedThreadPool (options .getConcurrency ());
@@ -1175,7 +1176,7 @@ public Page<T> findPage(Filter filter, FindOptions options) {
1175
1176
.appendIfNotNull (INPUT_PAGE_STATE , options .getPageState ())
1176
1177
.appendIfNotNull (INPUT_INCLUDE_SORT_VECTOR , options .getIncludeSortVector ())
1177
1178
.appendIfNotNull (INPUT_INCLUDE_SIMILARITY , options .getIncludeSimilarity ()));
1178
- ApiResponse apiResponse = runCommand (findCommand , options );
1179
+ DataAPIResponse apiResponse = runCommand (findCommand , options );
1179
1180
1180
1181
// load sortVector if available
1181
1182
float [] sortVector = null ;
@@ -1313,7 +1314,7 @@ public long estimatedDocumentCount() {
1313
1314
public long estimatedDocumentCount (EstimatedCountDocumentsOptions options ) {
1314
1315
Command command = new Command ("estimatedDocumentCount" );
1315
1316
// Run command
1316
- ApiResponse response = runCommand (command , options );
1317
+ DataAPIResponse response = runCommand (command , options );
1317
1318
// Build Result
1318
1319
return response .getStatus ().getInteger (RESULT_COUNT );
1319
1320
}
@@ -1348,13 +1349,13 @@ public long estimatedDocumentCount(EstimatedCountDocumentsOptions options) {
1348
1349
public int countDocuments (Filter filter , int upperBound , CountDocumentsOptions options )
1349
1350
throws TooManyDocumentsToCountException {
1350
1351
// Argument Validation
1351
- if (upperBound <1 || upperBound > dataAPIOptions .getMaxDocumentCount ()) {
1352
- throw new IllegalArgumentException ("UpperBound limit should be in between 1 and " + dataAPIOptions .getMaxDocumentCount ());
1352
+ if (upperBound <1 || upperBound > dataAPIOptions .getMaxRecordCount ()) {
1353
+ throw new IllegalArgumentException ("UpperBound limit should be in between 1 and " + dataAPIOptions .getMaxRecordCount ());
1353
1354
}
1354
1355
// Build command
1355
1356
Command command = new Command ("countDocuments" ).withFilter (filter );
1356
1357
// Run command
1357
- ApiResponse response = runCommand (command , options );
1358
+ DataAPIResponse response = runCommand (command , options );
1358
1359
// Build Result
1359
1360
Boolean moreData = response .getStatus ().getBoolean (RESULT_MORE_DATA );
1360
1361
Integer count = response .getStatus ().getInteger (RESULT_COUNT );
@@ -1418,7 +1419,7 @@ public DeleteResult deleteOne(Filter filter, DeleteOneOptions deleteOneOptions)
1418
1419
.withFilter (filter )
1419
1420
.withSort (deleteOneOptions .getSort ());
1420
1421
1421
- ApiResponse apiResponse = runCommand (deleteOne , deleteOneOptions );
1422
+ DataAPIResponse apiResponse = runCommand (deleteOne , deleteOneOptions );
1422
1423
int deletedCount = apiResponse .getStatus ().getInteger (RESULT_DELETED_COUNT );
1423
1424
return new DeleteResult (deletedCount );
1424
1425
}
@@ -1441,8 +1442,8 @@ public DeleteResult deleteMany(Filter filter, DeleteManyOptions options) {
1441
1442
.create ("deleteMany" )
1442
1443
.withFilter (filter );
1443
1444
1444
- ApiResponse apiResponse = runCommand (deleteMany , options );
1445
- Document status = apiResponse .getStatus ();
1445
+ DataAPIResponse apiResponse = runCommand (deleteMany , options );
1446
+ DataAPIStatus status = apiResponse .getStatus ();
1446
1447
if (status != null ) {
1447
1448
if (status .containsKey (RESULT_DELETED_COUNT )) {
1448
1449
totalCount .addAndGet (status .getInteger (RESULT_DELETED_COUNT ));
@@ -1542,7 +1543,7 @@ public Optional<T> findOneAndReplace(Filter filter, T replacement, FindOneAndRep
1542
1543
.appendIfNotNull (INPUT_RETURN_DOCUMENT , options .getReturnDocument ())
1543
1544
);
1544
1545
1545
- ApiResponse res = runCommand (findOneAndReplace , options );
1546
+ DataAPIResponse res = runCommand (findOneAndReplace , options );
1546
1547
if (res .getData ()!= null && res .getData ().getDocument () != null ) {
1547
1548
return Optional .ofNullable (res
1548
1549
.getData ()
@@ -1616,19 +1617,19 @@ public UpdateResult replaceOne(Filter filter, T replacement, ReplaceOneOptions r
1616
1617
*/
1617
1618
private FindOneAndReplaceResult <T > executeFindOneAndReplace (Command cmd , CommandOptions <?> options ) {
1618
1619
// Run Command
1619
- ApiResponse apiResponse = runCommand (cmd , options );
1620
+ DataAPIResponse apiResponse = runCommand (cmd , options );
1620
1621
// Parse Command Result
1621
1622
FindOneAndReplaceResult <T > result = new FindOneAndReplaceResult <>();
1622
1623
if (apiResponse .getData () == null ) {
1623
- throw new DataAPIFaultyResponseException (cmd , apiResponse ,"Faulty response from find_one_and_replace API command." );
1624
+ throw new UnexpectedDataAPIResponseException (cmd , apiResponse ,"Faulty response from find_one_and_replace API command." );
1624
1625
}
1625
1626
if (apiResponse .getData ().getDocument () != null ) {
1626
1627
result .setDocument (apiResponse
1627
1628
.getData ()
1628
1629
.getDocument ()
1629
1630
.map (getDocumentClass ()));
1630
1631
}
1631
- Document status = apiResponse .getStatus ();
1632
+ DataAPIStatus status = apiResponse .getStatus ();
1632
1633
if (status != null ) {
1633
1634
if (status .containsKey (RESULT_MATCHED_COUNT )) {
1634
1635
result .setMatchedCount (status .getInteger (RESULT_MATCHED_COUNT ));
@@ -1684,7 +1685,7 @@ public Optional<T> findOneAndUpdate(Filter filter, Update update, FindOneAndUpda
1684
1685
.append (INPUT_RETURN_DOCUMENT , options .getReturnDocument ())
1685
1686
);
1686
1687
1687
- ApiResponse res = runCommand (cmd , options );
1688
+ DataAPIResponse res = runCommand (cmd , options );
1688
1689
if (res .getData ()!= null && res .getData ().getDocument () != null ) {
1689
1690
return Optional .ofNullable (res
1690
1691
.getData ()
@@ -1742,9 +1743,9 @@ public UpdateResult updateOne(Filter filter, Update update, UpdateOneOptions upd
1742
1743
* @return
1743
1744
* the result of the update many operation
1744
1745
*/
1745
- private static UpdateResult getUpdateResult (ApiResponse apiResponse ) {
1746
+ private static UpdateResult getUpdateResult (DataAPIResponse apiResponse ) {
1746
1747
UpdateResult result = new UpdateResult ();
1747
- Document status = apiResponse .getStatus ();
1748
+ DataAPIStatus status = apiResponse .getStatus ();
1748
1749
if (status != null ) {
1749
1750
if (status .containsKey (RESULT_MATCHED_COUNT )) {
1750
1751
result .setMatchedCount (status .getInteger (RESULT_MATCHED_COUNT ));
@@ -1800,13 +1801,13 @@ public UpdateResult updateMany(Filter filter, Update update, UpdateManyOptions o
1800
1801
.withOptions (new Document ()
1801
1802
.appendIfNotNull (INPUT_UPSERT , options .getUpsert ())
1802
1803
.appendIfNotNull (INPUT_PAGE_STATE , nextPageState ));
1803
- ApiResponse res = runCommand (cmd , options );
1804
+ DataAPIResponse res = runCommand (cmd , options );
1804
1805
// Data
1805
1806
if (res .getData () != null ) {
1806
1807
nextPageState = res .getData ().getNextPageState ();
1807
1808
}
1808
1809
// Status
1809
- Document status = res .getStatus ();
1810
+ DataAPIStatus status = res .getStatus ();
1810
1811
if (status .containsKey (RESULT_MATCHED_COUNT )) {
1811
1812
result .setMatchedCount (result .getMatchedCount () + status .getInteger (RESULT_MATCHED_COUNT ));
1812
1813
}
@@ -1861,7 +1862,7 @@ public Optional<T> findOneAndDelete(Filter filter, FindOneAndDeleteOptions optio
1861
1862
.withSort (options .getSort ())
1862
1863
.withProjection (options .getProjection ());
1863
1864
1864
- ApiResponse res = runCommand (findOneAndReplace , options );
1865
+ DataAPIResponse res = runCommand (findOneAndReplace , options );
1865
1866
if (res .getData ()!= null && res .getData ().getDocument () != null ) {
1866
1867
return Optional .ofNullable (res
1867
1868
.getData ()
0 commit comments