-
Notifications
You must be signed in to change notification settings - Fork 973
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
fix: Lcs response parse #2970
fix: Lcs response parse #2970
Conversation
* Handle parsing `len` and `matches` in any order;
287d2c5
to
e106644
Compare
Hey @jabolina , do you mind extending the |
@tishun, I've extended the class but didn't push yet. Which server version does the CI run with? So I can check the tests. Depending on the version, the tests covering LCS aren't running anymore I've expanded the unit test, too. It should make the issue more clear. The idea is, with the payload (I added padding to make it easier to read):
Results in the response:
If the order of keys changes,
The result is:
Which is not correct anymore. IIUC, the spec does not make assumptions about the order of elements in the map. It could receive the keys in any order. However, I believe Redis always returns in the same order, first It might be tricky (or impossible) to reproduce this change in the order of objects in the integration tests. However, the unit test should cover it. |
The pipeline uses latest Redis CE right now, which you can run locally if you execute make start If successful the command will deploy all the required servers and then you can run any of the integration tests. |
Oh, I see, I understand now - this is not an actual issue, but more of a guard in case the server starts to return results in another manner. In this case you are unlikely to be able to force the server to return the results in another manner, so an integration test is not necessary. Let me spend some more time thinking on this. TBH the StringMatchResultOutput class seems extremely fragile as a whole right now |
@tishun, yes. I'll push what I have in a second commit. |
* Add more unit tests to handle the different cases; * Add integration tests when the `LCS` command is available; * Update the StringMatchResultOutput to avoid keeping track of withIdx parameter. This allows the use in the command factory.
I added a second commit to the PR. It re-works some of the StringMatchResultOutput a little and registers into the OutputRegistry. This change removes the boolean in the constructor and makes it possible to use the StringMatchResultOutput as a valid return type in the CommandFactory. Now, not much of my liking. I added some integration tests when the server has the |
Oh oh oh I got the whole picture now. Okay, so let's reset the conversation, apologies for my lag. To state the obvious :
IMHO we should approach this in another way than your suggestion. The biggest problem is that we can't really use LCS right now. I've created #2987 to address the missing command. We could obviously send the LCS using the Custom commands (similar to how you've done it in the integration test) but this is not optimal in terms of connections. Also IMHO we should not spend time future proofing the STRALGO since it is already removed. Instead we should implement the new command and - if we are to reuse the BTW to test against an older version you could modify the |
Yeah, right on point 🎯 This approach in steps makes more sense. We can close this PR and handle the issues in increments. If any of the changes make sense to be pulled, the git history remains. Please, let me know if any help is needed. Let me try running the tests. Edit: The tests work fine because they don't operate over keys! The whole point is that STRALGO operates over the user's input. Even though the tests weren't running, they were fine! |
I think the code you added makes sense until we have LCS implemented. When we implement the LCS command we can revise the code again if we want/need to.
Thanks for checking that. It would be good to know we are not regressing anything already working. |
Originally, the LCS response parsing depended on the order of the returned map. The
len
field updates when adding the values to thematches
values. Just a simple fix to verify first which key was read in the#set(ByteBuffer)
method.