Skip to content

feat(bitmap): support DIFF, DIFF1, ANDOR, ONE for BITOP command (with CI lint fix) - #3572

Closed
jihuayu wants to merge 3 commits into
unstablefrom
fix-bitop-ci-lint
Closed

feat(bitmap): support DIFF, DIFF1, ANDOR, ONE for BITOP command (with CI lint fix)#3572
jihuayu wants to merge 3 commits into
unstablefrom
fix-bitop-ci-lint

Conversation

@jihuayu

@jihuayu jihuayu commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

This PR supersedes #3471 by carrying the same BITOP extension and fixing the golangci-lint failures that block the Lint and check code CI job.

BITOP extensions

Add four new bitwise operations:

  • DIFFX & ~Y1 & ~Y2 ... (bits set in the first key but not in any subsequent key)
  • DIFF1(Y1 | Y2 | ...) & ~X (bits set in any subsequent key but not in the first key)
  • ANDORX & (Y1 | Y2 | ...) (bits set in the first key and in at least one subsequent key)
  • ONE – bits set in exactly one of the source keys

DIFF, DIFF1, and ANDOR are validated to require at least two source keys, matching Redis semantics. When the first key is missing, DIFF and ANDOR return a zero-filled string of the computed length, while DIFF1 falls back to OR(all Y) & ~0.

Files changed

  • src/types/redis_bitmap.{h,cc} – add enum values and byte-level implementation
  • src/commands/cmd_bit.cc – parse diff/diff1/andor/one and enforce minimum argument counts
  • tests/gocase/unit/type/bitmap/bitmap_test.go – add BITOP tests and SimulateBitOp helper; fix golangci-lint warnings:
    • staticcheck QF1003: use a tagged switch on the operation type
    • prealloc: preallocate the BITOP argument slice with capacity 3 + len(veckeys)

CI

  • ./x.py check format passes
  • ./x.py check golangci-lint now reports 0 issues

Link to Devin session: https://app.devin.ai/sessions/2de5e7194cae40e3a4b5c401006cd8a1
Requested by: @jihuayu

nkroker and others added 3 commits August 3, 2026 03:07
Implements Redis 8.2+ bitwise operations:
- DIFF: bits set in X but not in any Y
- DIFF1: bits set in any Y but not in X
- ANDOR: bits set in X and at least one Y
- ONE: bits set in exactly one key

Closes #3132

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d key count validation

- DIFF/DIFF1/ANDOR now correctly treat missing X as zero (Redis semantics)
- DIFF/DIFF1/ANDOR now require at least two source keys
- Fix clang-format violations
- Add edge case tests documenting Redis semantics for missing keys

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: huayu ji <jihuayu123@gmail.com>
@jihuayu jihuayu self-assigned this Aug 3, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@jihuayu jihuayu closed this Aug 3, 2026
@PragmaTwice
PragmaTwice deleted the fix-bitop-ci-lint branch August 21, 2026 15:12
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.

2 participants