20
20
* #L%
21
21
*/
22
22
23
- import com .datastax .astra .client .exception .DataApiException ;
24
23
import com .datastax .astra .client .exception .DataAPIFaultyResponseException ;
24
+ import com .datastax .astra .client .exception .DataApiException ;
25
+ import com .datastax .astra .client .exception .DataApiResponseException ;
25
26
import com .datastax .astra .client .exception .TooManyDocumentsToCountException ;
26
27
import com .datastax .astra .client .model .BulkWriteOptions ;
27
28
import com .datastax .astra .client .model .BulkWriteResult ;
28
- import com .datastax .astra .client .model .CollectionIdTypes ;
29
29
import com .datastax .astra .client .model .CollectionInfo ;
30
30
import com .datastax .astra .client .model .CollectionOptions ;
31
31
import com .datastax .astra .client .model .Command ;
51
51
import com .datastax .astra .client .model .UUIDv6 ;
52
52
import com .datastax .astra .client .model .UUIDv7 ;
53
53
import com .datastax .astra .client .model .Update ;
54
+ import com .datastax .astra .client .model .UpdateManyOptions ;
54
55
import com .datastax .astra .client .model .UpdateOneOptions ;
55
56
import com .datastax .astra .client .model .UpdateResult ;
56
- import com .datastax .astra .internal .command .AbstractCommandRunner ;
57
57
import com .datastax .astra .internal .api .ApiResponse ;
58
+ import com .datastax .astra .internal .command .AbstractCommandRunner ;
58
59
import com .datastax .astra .internal .command .LoggingCommandObserver ;
59
60
import com .datastax .astra .internal .utils .Assert ;
60
- import com .datastax .astra .internal .utils .CustomEJsonInstantDeserializer ;
61
- import com .datastax .astra .internal .utils .CustomUuidv6Serializer ;
62
61
import com .datastax .astra .internal .utils .JsonUtils ;
63
62
import lombok .Getter ;
64
63
import lombok .extern .slf4j .Slf4j ;
71
70
import java .util .UUID ;
72
71
import java .util .concurrent .Callable ;
73
72
import java .util .concurrent .CompletableFuture ;
73
+ import java .util .concurrent .ExecutionException ;
74
74
import java .util .concurrent .ExecutorService ;
75
75
import java .util .concurrent .Executors ;
76
76
import java .util .concurrent .Future ;
@@ -354,7 +354,7 @@ public String getName() {
354
354
*/
355
355
public final InsertOneResult insertOne (T document ) {
356
356
Assert .notNull (document , "document" );
357
- return _insertOne (JsonUtils .convertValueForDataApi (document , Document .class ));
357
+ return _insertOne (JsonUtils .convertValue (document , Document .class ));
358
358
}
359
359
360
360
/**
@@ -428,7 +428,7 @@ public final CompletableFuture<InsertOneResult> insertOneAsync(T document) {
428
428
public final InsertOneResult insertOne (T document , float [] embeddings ) {
429
429
Assert .notNull (document , "document" );
430
430
Assert .notNull (embeddings , "vectorize" );
431
- return _insertOne (JsonUtils .convertValueForDataApi (document , Document .class ).vector (embeddings ));
431
+ return _insertOne (JsonUtils .convertValue (document , Document .class ).vector (embeddings ));
432
432
}
433
433
434
434
/**
@@ -510,7 +510,7 @@ public final CompletableFuture<InsertOneResult> insertOneAsync(T document, float
510
510
public final InsertOneResult insertOne (T document , String vectorize ) {
511
511
Assert .notNull (document , "document" );
512
512
Assert .hasLength (vectorize , "vectorize" );
513
- return _insertOne (JsonUtils .convertValueForDataApi (document , Document .class ).vectorize (vectorize ));
513
+ return _insertOne (JsonUtils .convertValue (document , Document .class ).vectorize (vectorize ));
514
514
}
515
515
516
516
/**
@@ -581,7 +581,7 @@ private InsertOneResult _insertOne(Document document) {
581
581
* unmarshalled id
582
582
*/
583
583
@ SuppressWarnings ("unchecked" )
584
- protected Object unmarshallDocumentId (Object id ) {
584
+ private Object unmarshallDocumentId (Object id ) {
585
585
if (id instanceof Map ) {
586
586
// only maps will required to be unmarshalled
587
587
Map <String , Object > mapId = (Map <String , Object >) id ;
@@ -700,13 +700,14 @@ public InsertManyResult insertMany(List<? extends T> documents, InsertManyOption
700
700
} else {
701
701
throw new TimeoutException ("Request did not complete withing " );
702
702
}
703
- } catch (InterruptedException e ) {
703
+ } catch (InterruptedException | ExecutionException e ) {
704
+ if (e .getCause () instanceof DataApiException ) {
705
+ throw (DataApiException ) e .getCause ();
706
+ }
704
707
Thread .currentThread ().interrupt ();
705
708
throw new RuntimeException ("Thread was interrupted while waiting" , e );
706
709
} catch (TimeoutException e ) {
707
710
throw new RuntimeException ("Operation timed out" , e );
708
- } catch (Exception e ) {
709
- throw new RuntimeException ("Error occurred during async operation" , e .getCause ());
710
711
}
711
712
return finalResult ;
712
713
}
@@ -1357,7 +1358,7 @@ public int countDocuments(Filter filter, int upperBound) throws TooManyDocuments
1357
1358
*
1358
1359
*/
1359
1360
public DeleteResult deleteOne (Filter filter ) {
1360
- return deleteOne (filter , new DeleteOneOptions ());
1361
+ return deleteOne (filter , DeleteOneOptions . builder (). build ());
1361
1362
}
1362
1363
1363
1364
/**
@@ -1406,9 +1407,7 @@ public DeleteResult deleteMany(Filter filter) {
1406
1407
if (status .containsKey (DELETED_COUNT )) {
1407
1408
totalCount .addAndGet (status .getInteger (DELETED_COUNT ));
1408
1409
}
1409
- if (status .containsKey (MORE_DATA )) {
1410
- moreData = status .getBoolean (MORE_DATA );
1411
- }
1410
+ moreData = status .containsKey (MORE_DATA );
1412
1411
}
1413
1412
} while (moreData );
1414
1413
return new DeleteResult (totalCount .get ());
@@ -1547,7 +1546,7 @@ public UpdateResult replaceOne(Filter filter, T replacement, ReplaceOneOptions r
1547
1546
result .setMatchedCount (res .getMatchedCount ());
1548
1547
result .setModifiedCount (res .getModifiedCount ());
1549
1548
if (res .getDocument () != null ) {
1550
- Document doc = JsonUtils .convertValueForDataApi (res .getDocument (), Document .class );
1549
+ Document doc = JsonUtils .convertValue (res .getDocument (), Document .class );
1551
1550
if (doc .getId (Object .class ) != null ) {
1552
1551
result .setUpsertedId (doc .getId (Object .class ));
1553
1552
}
@@ -1601,7 +1600,7 @@ private FindOneAndReplaceResult<T> executeFindOneAndReplace(Command cmd) {
1601
1600
* returned
1602
1601
*/
1603
1602
public Optional <T > findOneAndUpdate (Filter filter , Update update ) {
1604
- return findOneAndUpdate (filter , update , new FindOneAndUpdateOptions ());
1603
+ return findOneAndUpdate (filter , update , FindOneAndUpdateOptions . builder (). build ());
1605
1604
}
1606
1605
1607
1606
/**
@@ -1654,7 +1653,7 @@ public Optional<T> findOneAndUpdate(Filter filter, Update update, FindOneAndUpda
1654
1653
* the result of the update one operation
1655
1654
*/
1656
1655
public UpdateResult updateOne (Filter filter , Update update ) {
1657
- return updateOne (filter , update , new UpdateOneOptions ());
1656
+ return updateOne (filter , update , UpdateOneOptions . builder (). build ());
1658
1657
}
1659
1658
1660
1659
/**
@@ -1711,7 +1710,7 @@ private static UpdateResult getUpdateResult(ApiResponse apiResponse) {
1711
1710
* the result of the update many operation
1712
1711
*/
1713
1712
public UpdateResult updateMany (Filter filter , Update update ) {
1714
- return updateMany (filter , update , new UpdateOneOptions ());
1713
+ return updateMany (filter , update , UpdateManyOptions . builder (). build ());
1715
1714
}
1716
1715
1717
1716
/**
@@ -1726,7 +1725,7 @@ public UpdateResult updateMany(Filter filter, Update update) {
1726
1725
* @return
1727
1726
* the result of the update many operation
1728
1727
*/
1729
- public UpdateResult updateMany (Filter filter , Update update , UpdateOneOptions options ) {
1728
+ public UpdateResult updateMany (Filter filter , Update update , UpdateManyOptions options ) {
1730
1729
notNull (update , "update" );
1731
1730
notNull (options , "options" );
1732
1731
boolean moreData = true ;
0 commit comments