Skip to content

Commit

Permalink
Change the InsertManyCommand.Options.ordered to false as default (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshrajamani authored Jan 10, 2024
1 parent 32cbd79 commit e25e8da
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,10 @@ public void ordered() {
"_id": "doc5",
"username": "user5"
}
]
],
"options" : {
"ordered" : true
}
}
}
""";
Expand Down Expand Up @@ -1089,7 +1092,10 @@ public void orderedDuplicateIds() {
"_id": "doc5",
"username": "user5"
}
]
],
"options" : {
"ordered" : true
}
}
}
""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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);
});
}
Expand All @@ -204,7 +204,7 @@ public void optionsNotOrdered() throws Exception {
}
],
"options": {
"ordered": false
"ordered": true
}
}
}
Expand All @@ -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);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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);
});
}
Expand Down

0 comments on commit e25e8da

Please sign in to comment.