-
Notifications
You must be signed in to change notification settings - Fork 575
feat(bitop): Support DIFF, DIFF1, ANDOR, and ONE for command BITOP #3134
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
Could you format the code via See https://kvrocks.apache.org/community/contributing for more information. |
@xuzifu666 The CI is now using the version clang-format 14, which behaves differently from clang-format > 14 in some ways. |
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 pull request adds support for four new bitwise operations (DIFF, DIFF1, ANDOR, and ONE) to the BITOP command in KvRocks. The implementation includes the core bitwise logic for these operations and corresponding test coverage.
Key changes:
- Added new BitOpFlags enum values for the four new operations
- Implemented optimized 64-bit processing logic for the new operations in the bitmap module
- Added command parsing support for the new operation names
- Updated go-redis dependency to support the new operations in tests
Reviewed Changes
Copilot reviewed 10 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/types/redis_bitmap.h | Added new enum values for DIFF, DIFF1, ANDOR, and ONE operations |
src/types/redis_bitmap.cc | Implemented core bitwise logic for new operations with optimized processing |
src/commands/cmd_bit.cc | Added command parsing support for new operation names |
tests/gocase/unit/type/bitmap/bitmap_test.go | Added test coverage for the new bitwise operations |
tests/gocase/go.mod | Updated go-redis dependency from v9.9.0 to v9.12.0 |
src/search/value.h | Code formatting change (line break adjustment) |
src/search/interval.h | Code formatting change (line break adjustment) |
src/config/config.cc | Code formatting change (line break adjustment) |
src/common/string_util.h | Code formatting change (line break adjustment) |
src/commands/commander.cc | Code formatting change (line break adjustment) |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Thansk for reminder and help, I had changed the clang-format version and code format seems OK now. @git-hulk @PragmaTwice |
Set2SetBit(t, rdb, ctx, "b", []byte("\x01\x02\xff")) | ||
Set2SetBit(t, rdb, ctx, "c", []byte("\x01\x02\xff")) | ||
require.NoError(t, rdb.BitOpDiff(ctx, "res1", "a", "b", "c").Err()) | ||
require.NoError(t, rdb.BitOpDiff1(ctx, "res2", "a", "b", "c").Err()) |
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.
For the diff1
, the result bits should be set in one or more of b
or c
, but not in a
. So the result should be \x00\x00\x00
? because a, b, c are the same.
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.
Yes, it should be 0 according to the definition. I transplanted it completely according to the implementation of Redis. I will check the original logic again.
|
Co-authored-by: Copilot <[email protected]>
lp[i] = reinterpret_cast<const uint64_t *>(fragments[i].data()); | ||
} | ||
memcpy(frag_res.get(), fragments[0].data(), frag_minlen); | ||
if (op_flag != kBitOpDiff && op_flag != kBitOpDiff1 && op_flag != kBitOpAndOr) { |
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.
I implemented this based on the Redis solution: redis/redis#13898
However, the results are different. I've been looking for the cause but haven't found it yet. I'm not sure if I've overlooked something.
issue: #3132