-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[vector sets] VRANGE implementation #14235
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
base: unstable
Are you sure you want to change the base?
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
New Issues (7)Checkmarx found the following issues in this Pull Request
Fixed Issues (4)Great job! The following issues were fixed in this Pull Request
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Are tests not running on CI? Coverage is 0
- Are we set on
VRANGE
as the command name? IMO it's confusing with vector range queries. MaybeVLEXRANGE
?
void *data; | ||
while ((key_data = RedisModule_DictNextC(iter, &key_len, &data)) != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using data
, and it's an optional parameter of the API. Consider removing
void *data; | |
while ((key_data = RedisModule_DictNextC(iter, &key_len, &data)) != NULL) { | |
while ((key_data = RedisModule_DictNextC(iter, &key_len, NULL)) != NULL) { |
result = self.redis.execute_command('VRANGE', self.test_key, '(apple', '[cherry', '10') | ||
result = [r.decode() for r in result] | ||
assert 'apple' not in result, "Exclusive boundary should not include 'apple'" | ||
assert 'apricot' in result and 'banana' in result and 'cherry' in result, "Should include elements after apple up to cherry" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider asserting the full reply
result = self.redis.execute_command('VRANGE', self.test_key, '[banana', '(cherry', '10') | ||
result = [r.decode() for r in result] | ||
assert 'banana' in result, "Should include banana" | ||
assert 'cherry' not in result, "Exclusive end should not include cherry" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider asserting the full reply.
The same comment applies to the cases listed below.
|
||
# Test 8: Count of 0 returns empty array | ||
result = self.redis.execute_command('VRANGE', self.test_key, '-', '+', '0') | ||
assert len(result) == 0, "Count of 0 should return empty array" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider asserting the returned value, and not its size. If something breaks, we won't know what we have got.
assert len(result) == 0, "Count of 0 should return empty array" | |
assert result == [], "Count of 0 should return empty array" |
Same comment for the other cases below
This is basically the Vector Set iteration primitive.
It exploits the underlying radix tree implementation.
The usage pattern is strongly reminiscent of other Redis commands doing similar things.
The command usage is straightforward:
The above command returns 10 (or less, if less are available in the specified range) elements from "Redis" (inclusive) to the maximum possible element. The comparison is performed byte by byte, as
memcmp()
would do, in this way the elements have a total order. The start and end range can be either a string, prefixedby
[
or(
(the prefix is mandatory) to tell the command if the range is inclusive or exclusive, or can be the special symbols-
and+
that means the maximum and minimum element.More info can be found in the implementation itself and in the README file change.