-
Notifications
You must be signed in to change notification settings - Fork 500
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(tdigest): add TDIGEST.MAX/MIN command #2811
base: unstable
Are you sure you want to change the base?
Conversation
fa1c04c
to
d4d2c8f
Compare
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.
PR Overview
This PR adds tests for the new TDIGEST.MAX and TDIGEST.MIN commands to validate their behavior, including error handling and correct value computation.
- Introduces the error message constant errValueDoesNotExist for cases where a tdigest exists but contains no data.
- Adds subtests for both TDIGEST.MAX and TDIGEST.MIN covering invalid arguments, empty digests, and digests with one or multiple values.
Reviewed Changes
File | Description |
---|---|
tests/gocase/unit/type/tdigest/tdigest_test.go | Added tests to cover TDIGEST.MAX and TDIGEST.MIN functionality |
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
tests/gocase/unit/type/tdigest/tdigest_test.go:217
- [nitpick] Consider reinitializing the tdigest or using a fresh key when transitioning from testing a single value to multiple values. This ensures that previous state does not affect the aggregation and makes each test case more isolated.
require.NoError(t, rdb.Do(ctx, "TDIGEST.CREATE", key, "compression", "100").Err())
tests/gocase/unit/type/tdigest/tdigest_test.go:212
- [nitpick] Consider expanding the invalid argument tests by including cases with extra arguments for both TDIGEST.MAX and TDIGEST.MIN to further improve test coverage.
require.ErrorContains(t, rdb.Do(ctx, "TDIGEST.MAX").Err(), errMsgWrongNumberArg)
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.
PR Overview
This PR adds tests for the new TDIGEST.MAX and TDIGEST.MIN commands to ensure their correct behavior with various arguments.
- Added a new error constant for missing values.
- Introduced test cases for TDIGEST.MAX and TDIGEST.MIN covering invalid arguments, empty digests, and digests with one or multiple values.
Reviewed Changes
File | Description |
---|---|
tests/gocase/unit/type/tdigest/tdigest_test.go | Added tests for TDIGEST.MAX and TDIGEST.MIN commands and a new error constant |
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
tests/gocase/unit/type/tdigest/tdigest_test.go:39
- [nitpick] Consider renaming 'errValueDoesNotExist' to 'errMsgValueDoesNotExist' for consistency with the other error constants defined in this file.
errValueDoesNotExist = "no value exists for key"
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.
Code general LGTM, but suddenly I realized that TDigest.Add
nan is invalid: https://github.com/RedisBloom/RedisBloom/blob/f68a72e463b84c2298990295c6a3db4719dc5c7a/src/rm_tdigest.c#L187
Would you mind also change that? ( Can be in another pr )
I will fix |
@@ -168,7 +168,71 @@ class CommandTDigestAdd : public Commander { | |||
std::vector<double> values_; | |||
}; | |||
|
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.
By the way would you mind extract an:
struct MinMax {
min, max
};
class CommandTDigestMinMaxImpl {
StatusOr<MinMax> Execute(...)
};
? I just think this could eliminate some code
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!I will pick it
|
This closes #2793.