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: Align go-redis TimeseriesCmdable #422

Merged
merged 22 commits into from
Dec 13, 2023

Conversation

unknowntpo
Copy link
Contributor

This PR implemented adapter for go-redis TimeseriesCmdable.

…SDeleteRule, TSGet, TSInfo, TSInfoWithArgs, TSMAdd, TSQueryIndex, TSRevRange
…any]any

WORKAROUND: manually convert map[string]any to map[any]any to make go-redis test PASS
we don't use (*RedisMessage).ToAny() on map type because it will convert ele
to map[string]any
Because tests in go-redis use both of them.
}
cmds.TsMrangeTotimestamp(_cmd).Filter(filterExpr...)
if options.GroupByLabel != nil {
// FIXME: Wrong API definition: REDUCE
Copy link
Contributor Author

@unknowntpo unknowntpo Dec 12, 2023

Choose a reason for hiding this comment

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

Note that our builder API TsMrevrange is wrong (same as below)

}
cmds.TsMrevrangeTotimestamp(_cmd).Filter(filterExpr...)
if options.GroupByLabel != nil {
// FIXME: Wrong API definition: REDUCE
Copy link
Contributor Author

@unknowntpo unknowntpo Dec 12, 2023

Choose a reason for hiding this comment

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

Note that our builder API TsMrevrange is wrong,

according to the doc, it should be:

cmds.TsMrevrangeFilter(_cmd).Groupby(str(options.GroupByLabel).Reduce(str(options.Reducer))

Not:

cmds.TsMrevrangeFilter(_cmd).Groupby(str(options.GroupByLabel), "REDUCE", str(options.Reducer))

Ref: https://redis.io/commands/ts.mrevrange/

@unknowntpo unknowntpo force-pushed the feat-align-go-redis-timeseries branch from 4a32f6b to 5f22cd6 Compare December 12, 2023 11:16
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 329 lines in your changes are missing coverage. Please review.

Comparison is base (3ed2b3e) 97.03% compared to head (4703b5a) 96.07%.
Report is 29 commits behind head on main.

Files Patch % Lines
rueidiscompat/adapter.go 58.53% 222 Missing and 21 partials ⚠️
rueidiscompat/command.go 34.35% 72 Missing and 14 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #422      +/-   ##
==========================================
- Coverage   97.03%   96.07%   -0.96%     
==========================================
  Files          76       76              
  Lines       31445    32162     +717     
==========================================
+ Hits        30512    30899     +387     
- Misses        788     1083     +295     
- Partials      145      180      +35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
strIntMap := make(map[string]any, len(m))
for k, ele := range m {
var v any = rueidis.Nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This rueidis.Nil is added to make tests pass, should we use rueidis.Nil or let it be nil if ele.IsNil() is true ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think nil is more reasonable.

}
strIntMap := make(map[string]any, len(m))
for k, ele := range m {
var v any = rueidis.Nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think nil is more reasonable.

message.go Outdated
// AsAnyAnyMap converts RedisMessage to map[any]any.
// we don't use (*RedisMessage).ToAny() on map type because it will convert ele
// to map[string]any
func (m *RedisMessage) AsAnyAnyMap() (map[any]any, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

map[any]any is too hard to use. I don't think we should have this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll remove it.

@rueian rueian merged commit 170c52c into redis:main Dec 13, 2023
@unknowntpo unknowntpo deleted the feat-align-go-redis-timeseries branch December 14, 2023 00:47
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.

3 participants