-
Notifications
You must be signed in to change notification settings - Fork 562
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?
Changes from all commits
0efad57
2c95f35
46755c7
570bd58
512c958
b1e29ca
9ba3ab3
cb3708d
3265ba8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,6 +271,17 @@ func TestBitmap(t *testing.T) { | |
require.EqualValues(t, []string{"\x55\xff\x00\xaa"}, GetBitmap(t, rdb, ctx, "s")) | ||
}) | ||
|
||
t.Run("BITOP DIFF|DIFF1|ANDOR|ONE don't change the string with single input key", func(t *testing.T) { | ||
Set2SetBit(t, rdb, ctx, "a", []byte("\x01\x02\xff")) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. For the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
require.NoError(t, rdb.BitOpAndOr(ctx, "res3", "a", "b", "c").Err()) | ||
require.NoError(t, rdb.BitOpOne(ctx, "res4", "a", "b", "c").Err()) | ||
require.EqualValues(t, []string{"\x00\x00\x00", "\x00\x01\x00", "\x01\x02\xff", "\x00\x00\x00"}, GetBitmap(t, rdb, ctx, "res1", "res2", "res3", "res4")) | ||
}) | ||
|
||
t.Run("BITOP AND|OR|XOR don't change the string with single input key", func(t *testing.T) { | ||
Set2SetBit(t, rdb, ctx, "a", []byte("\x01\x02\xff")) | ||
require.NoError(t, rdb.BitOpAnd(ctx, "res1", "a").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.
The disjunction and common_bits variables are declared outside the loop but should be reset for each byte position. Currently, values from previous iterations will incorrectly influence subsequent calculations for DIFF, DIFF1, ANDOR, and ONE operations.
Copilot uses AI. Check for mistakes.