-
Notifications
You must be signed in to change notification settings - Fork 592
Add the support of the LCS command #2116
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
Conversation
jihuayu
left a comment
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.
Thank you @JoverZhang, wonderful algorithm.
I think it's not good to put so much logic in the commander.
Would it be better to move the specific logic to redis::String? @git-hulk
mapleFU
left a comment
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.
I didn't review the logic for response, just some few comments
|
Can someone confirm whether this logic is correct? I am also unable to determine it. |
mapleFU
left a comment
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.
General LGTM. Just some few nits
@jihuayu Actually I think this impl works(Since it's code it's similiar with Redis' impl). However, I think the most important thing is prevent malicious user from using lcs to attack the system, or lcs making the server crash...
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.
As mentioned by @jihuayu, the implementation of the algorithm should be put into redis_string.cc instead of cmd_string.cc.
Understood, I have moved the algorithm to |
mapleFU
left a comment
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.
General LGTM
src/types/redis_string.h
Outdated
|
|
||
| struct StringLCSIdxResult { | ||
| // Matched ranges. | ||
| std::list<StringLCSMatchedRange> matches; |
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.
Though I don't think performance of LCS it's important, I think deque or vector ( using vector without pop_front) would be better here.
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.
Yeah, deque or vector is better here.
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.
Thank. I have modified this to use the vector.
Initially, I hadn't used the vector because I was concerned that a very large vector would significantly increase memory usage when building the output at the end.
However, I forgot that dp actually frees up more memory space at the end of string_db.LCS().
mapleFU
left a comment
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
|
|
Thank you for your contribution! |
|
Hi @JoverZhang, can you add this command to our docs? |
Okay, I added it. |


Close #1955