Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the InsertManyCommand.Options.ordered to false as default #782

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big deal, but name of test seems incorrect after change?

"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