fix(collection): preserve empty result shape for zero-limit batches#9677
Merged
Merged
Conversation
timvisee
reviewed
Jul 7, 2026
Comment on lines
+137
to
+144
| #[test] | ||
| fn empty_batch_results_preserves_outer_shape() { | ||
| assert_eq!( | ||
| empty_batch_results::<usize>(2), | ||
| vec![Vec::<usize>::new(), Vec::<usize>::new()], | ||
| ); | ||
| assert!(empty_batch_results::<usize>(0).is_empty()); | ||
| } |
Member
There was a problem hiding this comment.
Key result of the change is visible here.
A batch of two searches both having limit 0 will now return [[], []] rather than [].
timvisee
approved these changes
Jul 7, 2026
timvisee
left a comment
Member
There was a problem hiding this comment.
This change makes sense.
Thanks for taking the time to implement it 🙏
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
devbranch (notmaster) and my branch was created fromdev.Changes to Core Features:
What this changes
This fixes a batch response-shape bug in the all-zero-limit fast paths for search, query, recommend, and discover.
For a single request,
limit = 0correctly means "return zero points", so the result is[]. For a batch request,limit = 0should only make that individual result slot empty; it should not remove the slot from the outer batch response.Before this change, the all-zero-limit batch shortcuts returned
vec![], so a non-empty batch could return zero outer result slots. This PR adds a small shared helper,empty_batch_results(request_count), and uses it in those shortcuts so each input request keeps a corresponding empty result vector.Affected paths
Changed collection-level fast paths:
Only the all-zero-limit batch shortcut changes. Single-request zero-limit behavior still returns
[], and mixed batches still use the existing non-shortcut path for shard routing, vector resolution, scoring, payload loading, and filtering.Evidence
The batch cardinality invariant should be:
For a two-request batch where both requests have
limit = 0, the changed shortcut now preserves the outer result shape:The added focused regression test covers the shared helper shape used by the four fast paths:
This is source-level before/after evidence for the changed fast path. Local runtime validation is currently limited to
git diff --checkbecause the Rust toolchain is unavailable in the current Windows PATH and WSL environment.Validation
git diff --checkgh search prs --repo qdrant/qdrant --state open 'zero limit batch'andgh search prs --repo qdrant/qdrant --state open 'empty batch results'returned only this PR.CodeRabbitpassed.cargo test -p collection empty_batch_results_preserves_outer_shape- not run locally becausecargois not available in the current Windows PATH or WSL environment.cargo +nightly fmt --all -- --check- not run locally because the Rust toolchain is unavailable.cargo clippy --workspace --all-targets --all-features -- -D warnings- not run locally because the Rust toolchain is unavailable.cargo build --workspace --tests --locked- not run locally because the Rust toolchain is unavailable.AI assistance disclosure
Initial prompt intent for AI-assisted implementation and drafting:
Commit authorship disclosure: