-
Notifications
You must be signed in to change notification settings - Fork 62
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
Go: Implement Pfadd, Pfcount and Select commands #2822
Open
niharikabhavaraju
wants to merge
5
commits into
valkey-io:main
Choose a base branch
from
niharikabhavaraju:niharika-hyperlogcmds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+238
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cef0ef6
pfadd, pfcount and select commands
niharikabhavaraju c17a974
fixed lint and added comments
niharikabhavaraju aa9a49e
Merge branch 'main' into niharika-hyperlogcmds
niharikabhavaraju dbb4bc3
fixed code review comments
niharikabhavaraju c6aa01c
Merge branch 'main' into niharika-hyperlogcmds
niharikabhavaraju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
|
||
package api | ||
|
||
// HyperLogLogCommands defines an interface for the "HyperLogLog Commands" group of commands for standalone and cluster | ||
// clients. | ||
// | ||
// [valkey.io]: https://valkey.io/commands/?group=string#hyperloglog | ||
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. Please fix the link and align the doc with #2844 |
||
type HyperLogLogCommands interface { | ||
// PfAdd adds all elements to the HyperLogLog data structure stored at the specified key. | ||
// Creates a new structure if the key does not exist. | ||
// When no elements are provided, and key exists and is a HyperLogLog, then no operation is performed. | ||
// If key does not exist, then the HyperLogLog structure is created. | ||
// | ||
// Parameters: | ||
// key - The key of the HyperLogLog data structure to add elements into. | ||
// elements - An array of members to add to the HyperLogLog stored at key. | ||
// | ||
// Return value: | ||
// If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is | ||
// altered, then returns 1. Otherwise, returns 0. | ||
// | ||
// Example: | ||
// result, err := client.PfAdd("key",[]string{"value1", "value2", "value3"}) | ||
// result.Value(): 1 | ||
// result.IsNil(): false | ||
// | ||
// [valkey.io]: https://valkey.io/commands/pfadd/ | ||
PfAdd(key string, elements []string) (Result[int64], error) | ||
|
||
// Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or | ||
// calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily. | ||
// | ||
// Note: | ||
// In cluster mode, if keys in `keyValueMap` map to different hash slots, the command | ||
// will be split across these slots and executed separately for each. This means the command | ||
// is atomic only at the slot level. If one or more slot-specific requests fail, the entire | ||
// call will return the first encountered error, even though some requests may have succeeded | ||
// while others did not. If this behavior impacts your application logic, consider splitting | ||
// the request into sub-requests per slot to ensure atomicity. | ||
// | ||
// Parameters: | ||
// key - The keys of the HyperLogLog data structures to be analyzed. | ||
// | ||
// Return value: | ||
// The approximated cardinality of given HyperLogLog data structures. | ||
// The cardinality of a key that does not exist is 0. | ||
// | ||
// Example: | ||
// result, err := client.PfCount([]string{"key1","key2"}) | ||
// result.Value(): 5 | ||
// result.IsNil(): false | ||
// | ||
// [valkey.io]: https://valkey.io/commands/pfcount/ | ||
PfCount(keys []string) (Result[int64], error) | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
This must be implemented in standalone client only. Cluster has no databases to switch into, so this command is no-op there.