Skip to content
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

feat: add unit field to bitcount #538

Merged
merged 6 commits into from May 18, 2024

Conversation

SoulPancake
Copy link
Contributor

@SoulPancake
Copy link
Contributor Author

@rueian
Do we need to also do it for
func (c CacheCompat) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd
for this to work?

@rueian
Copy link
Collaborator

rueian commented Apr 27, 2024

CacheCompat) BitCount(ctx context.Context, ke

Yes, we should support the Unit there too.

resp = c.client.Do(ctx, c.client.B().Bitcount().Key(key).Build())
} else {
resp = c.client.Do(ctx, c.client.B().Bitcount().Key(key).Start(bitCount.Start).End(bitCount.End).Build())
resp := c.client.Do(ctx, c.client.B().Bitcount().Key(key).Bit().Build()) // Default to BIT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @SoulPancake,

We can't use .Bit() as default because it is only supported on Redis >= 7. We should keep the original behavior.

switch bitCount.Unit {
case BitCountIndexByte:
resp = c.client.Do(ctx, builder.Byte().Build()) // Handling for BYTE
case BitCountIndexBit, "": // Default to BIT if not specified
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. we can't use .Bit() as default in the case of "".

@rueian
Copy link
Collaborator

rueian commented May 11, 2024

Hi @SoulPancake, would you like to continue on this?

@SoulPancake
Copy link
Contributor Author

yes give me some time I will address it tonight @rueian

@SoulPancake
Copy link
Contributor Author

@rueian I was thinking whether I should continue here or on valkey-go
You can suggest

@rueian
Copy link
Collaborator

rueian commented May 16, 2024

Hi @SoulPancake,

Here is ok. I will sync commits between them.

@SoulPancake
Copy link
Contributor Author

Will that make me a contributor there too? As I would like to be so @rueian

@rueian
Copy link
Collaborator

rueian commented May 16, 2024

Will that make me a contributor there too? As I would like to be so @rueian

Yes of course

@SoulPancake SoulPancake force-pushed the ab/feature/add-unit-field-bitcount branch from 6c7e253 to 7b1c162 Compare May 16, 2024 16:48
@SoulPancake
Copy link
Contributor Author

I have some doubts
The command slice looks alright to me
image

But still I am getting an ERR syntax error for this
However, it works fine for BIT

@rueian

@SoulPancake
Copy link
Contributor Author

Further, In the container that I am using, I am able to get the response too
image

@@ -1959,6 +1959,7 @@ type SetArgs struct {

type BitCount struct {
Start, End int64
Unit *string // Stores BIT or BYTE
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @SoulPancake,

Could we keep using string instead of *string? We'd like to make the interface as close to go-redis'.

@rueian
Copy link
Collaborator

rueian commented May 17, 2024

I have some doubts The command slice looks alright to me image

But still I am getting an ERR syntax error for this However, it works fine for BIT

@rueian

Do you mean here? The RESP2 test suite is tested against Redis 5.
image

You need to wrap your new tests in a if block:

		if resp3 {
			bitCount = adapter.BitCount(ctx, "key", &BitCount{
				Start: 1,
				End:   1,
				Unit:  "BYTE",
			})
			Expect(bitCount.Err()).NotTo(HaveOccurred())
			Expect(bitCount.Val()).To(Equal(int64(6)))	
		}

@SoulPancake
Copy link
Contributor Author

Please review @rueian :)

@rueian rueian merged commit 819cc5e into redis:main May 18, 2024
12 checks passed
@rueian
Copy link
Collaborator

rueian commented May 18, 2024

LGTM. Thanks @SoulPancake!

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.

None yet

2 participants