Fix VSIM single-element query vector missing VALUES num prefix - #3863
Open
renechoi wants to merge 2 commits into
Open
Fix VSIM single-element query vector missing VALUES num prefix#3863renechoi wants to merge 2 commits into
renechoi wants to merge 2 commits into
Conversation
Signed-off-by: renechoi <renechoi90@gmail.com>
Collaborator
|
Hey @renechoi |
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.
Description
When
vsim,vsimWithScore, orvsimWithScoreWithAttribsis invoked with a single-element query vector (i.e.vectors.length == 1), the command currently omits the requiredVALUESkeyword and the number of elements. Instead of emittingVSIM key VALUES 1 0.1, it erroneously emitsVSIM key 0.1.This fixes the issue by removing the
if (vectors.length > 1)check, guaranteeing thatVALUES <num>is consistently emitted regardless of array length, similar to howvaddhandles it.Added corresponding tests to
RedisVectorSetCommandBuilderUnitTeststo verify the fix.Note
Low Risk
Localized protocol-encoding bug fix in vector-set command builders with new unit tests; no auth, persistence, or broad API changes.
Overview
Fixes incorrect VSIM wire encoding when the query vector is a single-element
Double[]. Those code paths used to send only the lone float (e.g.VSIM key 0.1) instead of the requiredVALUEScount and components (e.g.VSIM key VALUES 1 0.1).RedisVectorSetCommandBuildernow always emitsVALUES, the length, and each component for vector-basedvsim,vsimWithScore, andvsimWithScoreWithAttribs, matchingvaddand multi-element VSIM behavior. Unit tests assert the encoded RESP for one-dimensional queries across all three variants.Reviewed by Cursor Bugbot for commit d98a0eb. Bugbot is set up for automated code reviews on this repo. Configure here.