Skip to content

Add Support for New BITOP Operations in Redis 8.2 (#4188) #4190

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ggivo
Copy link
Collaborator

@ggivo ggivo commented Jun 27, 2025

This PR adds support for the new BITOP operations introduced in Redis Community Edition 8.2:
DIFF, DIFF1, ANDOR, and ONE.

Changes

  • Added new enum values to BitOP.java for the new operations: DIFF, DIFF1, ANDOR, and ONE
  • Updated tests in BitCommandsTest.java and BitCommandsTestBase.java to verify the new operations

New Operations

  • DIFF(X, Y1, Y2, ...):
    • Members of X that are not members of any of Y1, Y2, ...
    • Equivalent to: X ∧ ¬(Y1 ∨ Y2 ∨ ...)
  • DIFF1(X, Y1, Y2, ...):
    • Members of one or more of Y1, Y2, ...
    • that are not members of X Equivalent to: ¬X ∧ (Y1 ∨ Y2 ∨ ...)
  • ANDOR(X, Y1, Y2, ...):
    • Members of X that are also members of one or more of Y1, Y2, ...
    • Equivalent to: X ∧ (Y1 ∨ Y2 ∨ ...)
  • ONE(X1, X2, ...):
    • Members of exactly one of X1, X2, ...
    • For two bitmaps, this is equivalent to XOR(X1, X2)
    • For more than two bitmaps, this represents elements that appear in exactly one input

Closes #4188

This PR adds support for the new BITOP operations introduced in Redis Community Edition 8.2: DIFF, DIFF1, ANDOR, and ONE.

Changes
  - Added new enum values to BitOP.java for the new operations: DIFF, DIFF1, ANDOR, and ONE
  - Updated tests in BitCommandsTest.java and BitCommandsTestBase.java to verify the new operations

New Operations
  - DIFF(X, Y1, Y2, ...): Members of X that are not members of any of Y1, Y2, ...
    Equivalent to: X ∧ ¬(Y1 ∨ Y2 ∨ ...)
  - DIFF1(X, Y1, Y2, ...): Members of one or more of Y1, Y2, ... that are not members of X
    Equivalent to: ¬X ∧ (Y1 ∨ Y2 ∨ ...)
  - ANDOR(X, Y1, Y2, ...): Members of X that are also members of one or more of Y1, Y2, ...
    Equivalent to: X ∧ (Y1 ∨ Y2 ∨ ...)
  - ONE(X1, X2, ...): Members of exactly one of X1, X2, ...
    For two bitmaps, this is equivalent to XOR(X1, X2)
    For more than two bitmaps, this represents elements that appear in exactly one input

Closes redis#4188
@ggivo ggivo requested review from uglide and atakavci July 1, 2025 11:09
Copy link
Contributor

@uglide uglide left a comment

Choose a reason for hiding this comment

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

Some minor nitpicks in the testcase, otherwise looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for new operations of BITOP command in Redis Community Edition 8.2
2 participants