-
Notifications
You must be signed in to change notification settings - Fork 1k
Add support for new operations of BITOP command in Redis Community Edition 8.2 #3334
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: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR adds support for the new BITOP operations (DIFF, DIFF1, ANDOR, ONE) introduced in Redis Community Edition 8.2.
- Defines new commands in
RedisStringCommands
, clusterNodeSelectionString*Commands
, and their async/reactive variants - Extends
CommandKeyword
,RedisCommandBuilder
, and test suites (integration and builder unit tests) to handle the added operations
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/test/java/io/lettuce/core/commands/BitCommandIntegrationTests.java | Added integration tests for DIFF, DIFF1, ANDOR, ONE |
src/test/java/io/lettuce/core/RedisCommandBuilderUnitTests.java | Added unit tests for command encoding of new ops |
src/main/templates/io/lettuce/core/api/RedisStringCommands.java | Declared new bitopDiff, bitopDiff1, bitopAndor, bitopOne methods |
src/main/java/io/lettuce/core/protocol/CommandKeyword.java | Added DIFF , DIFF1 , ANDOR , ONE keywords |
src/main/java/io/lettuce/core/RedisCommandBuilder.java | Implemented builder methods for new operations |
src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java | Added reactive overrides for new operations |
src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java | Added async overrides for new operations |
src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionStringCommands.java | Declared cluster sync variants of new methods |
src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionStringAsyncCommands.java | Declared cluster async variants of new methods |
Comments suppressed due to low confidence (1)
src/test/java/io/lettuce/core/commands/BitCommandIntegrationTests.java:512
- [nitpick] The comment is misleading—ANDOR takes one source key and at least one additional key. Consider updating it to reflect that only one comparison key is required.
// ANDOR requires at least two keys - test with empty second key
@@ -308,6 +330,221 @@ void bitopXor() { | |||
assertThat(bitstring.get(key)).isEqualTo("00000100"); | |||
} | |||
|
|||
@Test | |||
void bitopDiff() { | |||
assumeTrue(RedisConditions.of(redis).hasVersionGreaterOrEqualsTo("8.1.240")); |
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.
The version check threshold for these new BITOP operations should be updated to Redis 8.2.0 (e.g., "8.2.0") instead of "8.1.240" to align with their official introduction.
assumeTrue(RedisConditions.of(redis).hasVersionGreaterOrEqualsTo("8.1.240")); | |
assumeTrue(RedisConditions.of(redis).hasVersionGreaterOrEqualsTo("8.2.0")); |
Copilot uses AI. Check for mistakes.
LGTM. @tishun WDYT? |
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.
Awesome work, thanks @atakavci !
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.
LGTM
Redis CE 8.2 supports new operations often required with BITOP command;
DIFF(X, Y1, Y2, …)
members of X that are not members of any of Y1, Y2 ,…
X ∧ ¬(Y1 ∨ Y2 ∨ …)
DIFF1(X, Y1, Y2, …)
members of one or more of Y1, Y2 ,… that are not members of X
¬X ∧ (Y1 ∨ Y2 ∨ …)
ANDOR(X, Y1, Y2, …)
members of X that are also members of one or more of Y1, Y2 ,…
X ∧ (Y1 ∨ Y2 ∨ …)
ONE(X1, X2, …) -
members of exactly one of X1, X2, …
For two bitmaps this is equivalent to XOR(X1, X2) (AKA symmetric difference., X1 ⊕ X2). However, for more than two bitmaps, XOR has little practical use.
In general this is COUNT(X1, X2, …) == 1
See more details here.