feat(bitmap): support DIFF, DIFF1, ANDOR, ONE for BITOP command (with CI lint fix) - #3571
Closed
jihuayu wants to merge 3 commits into
Closed
feat(bitmap): support DIFF, DIFF1, ANDOR, ONE for BITOP command (with CI lint fix)#3571jihuayu wants to merge 3 commits into
jihuayu wants to merge 3 commits into
Conversation
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>
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.
Summary
This PR supersedes #3471 by carrying the same
BITOPextension and fixing thegolangci-lintfailures that block theLint and check codeCI job.BITOPextensionsAdd four new bitwise operations:
DIFF–X & ~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)ANDOR–X & (Y1 | Y2 | ...)(bits set in the first key and in at least one subsequent key)ONE– bits set in exactly one of the source keysDIFF,DIFF1, andANDORare validated to require at least two source keys, matching Redis semantics. When the first key is missing,DIFFandANDORreturn a zero-filled string of the computed length, whileDIFF1falls back toOR(all Y) & ~0.Files changed
src/types/redis_bitmap.{h,cc}– add enum values and byte-level implementationsrc/commands/cmd_bit.cc– parsediff/diff1/andor/oneand enforce minimum argument countstests/gocase/unit/type/bitmap/bitmap_test.go– addBITOPtests andSimulateBitOphelper; fixgolangci-lintwarnings:staticcheckQF1003: use a taggedswitchon the operation typeprealloc: preallocate theBITOPargument slice with capacity3 + len(veckeys)CI
./x.py check formatpasses./x.py check golangci-lintnow reports 0 issuesLink to Devin session: https://app.devin.ai/sessions/2de5e7194cae40e3a4b5c401006cd8a1
Requested by: @jihuayu