-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add support for LCS Command #2480
Conversation
my thoughts: type LCSMatch struct {
Matches []LCSMatchedPosition
Len int
}
type LCSMatchedPosition struct {
// or A/B ?
Key1 LCSPosition
Key2 LCSPosition
// only for withMatchLen is true
MatchLen int
}
type LCSPosition struct {
Start int
End int
}
// lcs key1 key2
func LCS(key1, key2 string) *StringCmd {}
// lcs key1 key2 len
func LCSLen(key1, key2 string) *IntCmd {}
// lcs key1 key2 idx minmatchlen minMatchLen withmatchlen
// or *LCSMatchCmd
func LCSIdx(key1, key2 string, minMatchLen int, withMatchLen bool) *LCSCmd {}
//--------------
// OR
type LCSQuery struct {
Key1 string
Key2 string
Len bool
Idx bool
MinMatchLen int
WithMatchLen bool
}
func LCS(key1, key2 string, len, idx bool, minMatchLen int, withMatchLen bool) *LCSCmd {}
func LCS(q *LCSQuery) *LCSCmd{} 😀😀😀😀 comments are welcome~ |
exp: type LCSMatch struct {
MatchString string
Matches []LCSMatchedPosition
Len int64
}
type LCSMatchedPosition struct {
// or A/B ?
Key1 LCSPosition
Key2 LCSPosition
// only for withMatchLen is true
MatchLen int
}
type LCSPosition struct {
Start int
End int
}
type LCSCmd struct {
baseCmd
// 1: match string
// 2: match len
// 3: match idx LCSMatch
readType uint8
val *LCSMatch
}
func (cmd *LCSCmd) readReply(rd *proto.Reader) (err error) {
lcs := &LCSMatch{}
switch cmd.readType {
case 1:
// match string
lcs.MatchString, err = rd.ReadString()
case 2:
// match len
if lcs.Len, err = rd.ReadInt(); err != nil {
return err
}
case 3:
// read LCSMatch
if err = rd.ReadFixedMapLen(2); err != nil {
return err
}
key, err := rd.ReadString()
if err != nil {
return err
}
// we should not depend on the order of the map.
switch key {
case "matches":
n, err := rd.ReadArrayLen()
if err != nil && err != Nil {
return err
}
for i := 0; i < n; i++ {
// read LCSMatchedPosition
// miss..
}
case "len":
if lcs.Len, err = rd.ReadInt(); err != nil {
return err
}
}
}
cmd.val = lcs
return nil
}
type LCSQuery struct {
Key1 string
Key2 string
Len bool
Idx bool
MinMatchLen int
WithMatchLen bool
}
func LCS(ctx context.Context, q *LCSQuery) *LCSCmd {
// ...miss
return &LCSCmd{}
}
// call
lcs, err := rdb.LCS(ctx, &LCSQuery{
//...
}).Result()
lcs.MatchString()
lcs.Len()
lcs.Matches[0].Key1.Start |
any thoughts on my example? |
Thanks for your example! |
Hi @monkey92t |
I don't quite understand what you mean. What does this have to do with MarshalBinary? |
@monkey92t As I'm getting the error for the same on the test |
No, that's not it. I will make some modifications to the PR later. |
Signed-off-by: monkey92t <golang@88.com>
Thanks @monkey92t :) I was overcomplicating it |
@monkey92t As this looks good , we can merge it right? |
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.
LGTM
@monkey92t The build failure seems unrelated |
We use redis-server/sentinel/cluster to perform tests, and sometimes encounter failures due to network errors. |
@monkey92t Had a general question, how were you able to run the build actions again without pushing a new commit? |
You need to manually build or rebuild the projects that you have permissions for in Github Actions. |
Fixes #2403