From a24517aff2b093a6e4d57406d1d965aa48d980fe Mon Sep 17 00:00:00 2001 From: maheshrajamani <99678631+maheshrajamani@users.noreply.github.com> Date: Wed, 10 Jan 2024 09:56:15 -0500 Subject: [PATCH 1/3] Change the InsertManyCommand.Options.ordered to false as default --- .../api/model/command/impl/InsertManyCommand.java | 4 ++-- .../operation/model/impl/InsertOperation.java | 2 +- .../model/impl/InsertManyCommandResolver.java | 3 ++- .../configuration/ObjectMapperConfigurationTest.java | 1 + .../model/impl/InsertManyCommandResolverTest.java | 12 ++++++------ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/impl/InsertManyCommand.java b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/impl/InsertManyCommand.java index 56b7d1e5ce..6928984e0a 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/impl/InsertManyCommand.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/api/model/command/impl/InsertManyCommand.java @@ -37,6 +37,6 @@ public record Options( @Schema( description = "When `true` the server will insert the documents in sequential order, ensuring each document is successfully inserted before starting the next. Additionally the command will \"fail fast\", failing the first document that fails to insert. When `false` the server is free to re-order the inserts and parallelize them for performance. In this mode more than one document may fail to be inserted (aka \"fail silently\" mode).", - defaultValue = "true") - Boolean ordered) {} + defaultValue = "false") + boolean ordered) {} } diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/InsertOperation.java b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/InsertOperation.java index ddf76b916c..5ae38b0b11 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/InsertOperation.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/operation/model/impl/InsertOperation.java @@ -28,7 +28,7 @@ public record InsertOperation( implements ModifyOperation { public InsertOperation(CommandContext commandContext, WritableShreddedDocument document) { - this(commandContext, List.of(document), true); + this(commandContext, List.of(document), false); } /** {@inheritDoc} */ diff --git a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolver.java b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolver.java index 7afc739c13..5d0f204cc0 100644 --- a/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolver.java +++ b/src/main/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolver.java @@ -40,7 +40,8 @@ public Operation resolveCommand(CommandContext ctx, InsertManyCommand command) { // resolve ordered InsertManyCommand.Options options = command.options(); - boolean ordered = null == options || !Boolean.FALSE.equals(options.ordered()); + + boolean ordered = null != options && Boolean.TRUE.equals(options.ordered()); return new InsertOperation(ctx, shreddedDocuments, ordered); } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java index 4010fa5371..5faf792b20 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/configuration/ObjectMapperConfigurationTest.java @@ -662,6 +662,7 @@ public void happyPath() throws Exception { assertThat(documents).hasSize(2); final InsertManyCommand.Options options = insertManyCommand.options(); assertThat(options).isNotNull(); + assertThat(options.ordered()).isFalse(); }); } } diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolverTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolverTest.java index 14a7a1a684..feebaf913b 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolverTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertManyCommandResolverTest.java @@ -64,7 +64,7 @@ public void happyPath() throws Exception { WritableShreddedDocument second = shredder.shred(command.documents().get(1)); assertThat(op.commandContext()).isEqualTo(commandContext); - assertThat(op.ordered()).isTrue(); + assertThat(op.ordered()).isFalse(); assertThat(op.documents()).containsExactly(first, second); }); } @@ -102,7 +102,7 @@ public void happyPathVectorSearch() throws Exception { WritableShreddedDocument second = shredder.shred(command.documents().get(1)); assertThat(op.commandContext()).isEqualTo(commandContext); - assertThat(op.ordered()).isTrue(); + assertThat(op.ordered()).isFalse(); assertThat(op.documents()).containsExactly(first, second); }); } @@ -144,7 +144,7 @@ public void happyPathVectorizeSearch() throws Exception { assertThat(second.queryVectorValues()).containsExactly(0.25f, 0.25f, 0.25f); assertThat(op.commandContext()) .isEqualTo(TestEmbeddingService.commandContextWithVectorize); - assertThat(op.ordered()).isTrue(); + assertThat(op.ordered()).isFalse(); assertThat(op.documents()).containsExactly(first, second); }); } @@ -182,7 +182,7 @@ public void optionsEmpty() throws Exception { WritableShreddedDocument second = shredder.shred(command.documents().get(1)); assertThat(op.commandContext()).isEqualTo(commandContext); - assertThat(op.ordered()).isTrue(); + assertThat(op.ordered()).isFalse(); assertThat(op.documents()).containsExactly(first, second); }); } @@ -204,7 +204,7 @@ public void optionsNotOrdered() throws Exception { } ], "options": { - "ordered": false + "ordered": true } } } @@ -221,7 +221,7 @@ public void optionsNotOrdered() throws Exception { WritableShreddedDocument second = shredder.shred(command.documents().get(1)); assertThat(op.commandContext()).isEqualTo(commandContext); - assertThat(op.ordered()).isFalse(); + assertThat(op.ordered()).isTrue(); assertThat(op.documents()).containsExactly(first, second); }); } From 93bea593f2b7c925ec70186c50ca768252f52aad Mon Sep 17 00:00:00 2001 From: maheshrajamani <99678631+maheshrajamani@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:28:27 -0500 Subject: [PATCH 2/3] Fixed the InsertOne resolver --- .../resolver/model/impl/InsertOneCommandResolverTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertOneCommandResolverTest.java b/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertOneCommandResolverTest.java index d7cf02a4b9..5bc535da03 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertOneCommandResolverTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/service/resolver/model/impl/InsertOneCommandResolverTest.java @@ -57,7 +57,7 @@ public void happyPath() throws Exception { WritableShreddedDocument expected = shredder.shred(command.document()); assertThat(op.commandContext()).isEqualTo(commandContext); - assertThat(op.ordered()).isTrue(); + assertThat(op.ordered()).isFalse(); assertThat(op.documents()).singleElement().isEqualTo(expected); }); } @@ -86,7 +86,7 @@ public void happyPathWithVector() throws Exception { WritableShreddedDocument expected = shredder.shred(command.document()); assertThat(op.commandContext()).isEqualTo(commandContext); - assertThat(op.ordered()).isTrue(); + assertThat(op.ordered()).isFalse(); assertThat(op.documents()).singleElement().isEqualTo(expected); }); } @@ -118,7 +118,7 @@ public void happyPathWithVectorize() throws Exception { assertThat(expected.queryVectorValues()).containsExactly(0.25f, 0.25f, 0.25f); assertThat(op.commandContext()) .isEqualTo(TestEmbeddingService.commandContextWithVectorize); - assertThat(op.ordered()).isTrue(); + assertThat(op.ordered()).isFalse(); assertThat(op.documents()).singleElement().isEqualTo(expected); }); } From 81cfc43e7a160b10ec71c654fe41a1c662c0099c Mon Sep 17 00:00:00 2001 From: maheshrajamani <99678631+maheshrajamani@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:56:22 -0500 Subject: [PATCH 3/3] Fixed IT test cases for ordered --- .../sgv2/jsonapi/api/v1/InsertIntegrationTest.java | 10 ++++++++-- .../jsonapi/api/v1/VectorSearchIntegrationTest.java | 5 ++++- .../jsonapi/api/v1/VectorizeSearchIntegrationTest.java | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java index 21f7ff9646..01b58a619d 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/InsertIntegrationTest.java @@ -1033,7 +1033,10 @@ public void ordered() { "_id": "doc5", "username": "user5" } - ] + ], + "options" : { + "ordered" : true + } } } """; @@ -1089,7 +1092,10 @@ public void orderedDuplicateIds() { "_id": "doc5", "username": "user5" } - ] + ], + "options" : { + "ordered" : true + } } } """; diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java index a512b32009..765e923644 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorSearchIntegrationTest.java @@ -397,7 +397,10 @@ public void insertVectorSearch() { "description": "Vision Vector Frame', 'A deep learning display that controls your mood", "$vector": [0.12, 0.05, 0.08, 0.32, 0.6] } - ] + ], + "options" : { + "ordered" : true + } } } """; diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java index d95a9bd73c..b4db1fffd1 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java @@ -205,7 +205,10 @@ public void insertVectorSearch() { "description": "A deep learning display that controls your mood", "$vectorize": "A deep learning display that controls your mood" } - ] + ], + "options" : { + "ordered" : true + } } } """;