-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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:HSET support multi feild【wip】 #2930
base: unstable
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,11 +388,11 @@ void InitCmdTable(CmdTable* cmd_table) { | |
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameHDel, std::move(hdelptr))); | ||
////HSetCmd | ||
std::unique_ptr<Cmd> hsetptr = | ||
std::make_unique<HSetCmd>(kCmdNameHSet, 4, kCmdFlagsWrite | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsFast); | ||
std::make_unique<HMsetCmd>(kCmdNameHSet, -3, kCmdFlagsWrite | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsFast); | ||
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameHSet, std::move(hsetptr))); | ||
////HGetCmd | ||
std::unique_ptr<Cmd> hgetptr = | ||
std::make_unique<HGetCmd>(kCmdNameHGet, 3, kCmdFlagsRead | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsReadCache |kCmdFlagsFast); | ||
std::make_unique<HMgetCmd>(kCmdNameHGet, -3, kCmdFlagsRead | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsReadCache |kCmdFlagsFast); | ||
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameHGet, std::move(hgetptr))); | ||
Comment on lines
+395
to
396
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the test cases and command definitions, I can now provide a definitive response: Using HMgetCmd for HGET command is incorrect and breaks Redis compatibility The test cases in
The change from Recommend reverting the changes as suggested in the original review: - std::make_unique<HMgetCmd>(kCmdNameHGet, -3, kCmdFlagsRead | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsReadCache |kCmdFlagsFast);
+ std::make_unique<HGetCmd>(kCmdNameHGet, 3, kCmdFlagsRead | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsReadCache |kCmdFlagsFast); 🔗 Analysis chainPotential issue: HGET should not use HMgetCmd. Using
Recommend reverting this change and keeping HGET as a single field operation: - std::make_unique<HMgetCmd>(kCmdNameHGet, -3, kCmdFlagsRead | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsReadCache |kCmdFlagsFast);
+ std::make_unique<HGetCmd>(kCmdNameHGet, 3, kCmdFlagsRead | kCmdFlagsHash | kCmdFlagsUpdateCache | kCmdFlagsDoThroughDB | kCmdFlagsReadCache |kCmdFlagsFast); Let's verify the Redis command specifications for HGET: Let me gather more specific information about the HGET implementation. The previous search didn't yield much information, so I'm looking for:
This will help us confirm if using HMgetCmd for HGET is indeed problematic or if there's a valid reason for this change. Let me check the test files to understand the expected behavior of HGET. I want to verify:
This will help us make a definitive conclusion about whether using HMgetCmd for HGET is correct or not. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for HGET command usage patterns
rg -A 5 "HGET.*\("
Length of output: 2648 Script: #!/bin/bash
# Search for HGetCmd and HMgetCmd class definitions and implementations
ast-grep --pattern 'class HGetCmd {
$$$
}'
ast-grep --pattern 'class HMgetCmd {
$$$
}'
# Look for HGET command tests or examples
rg -l "HGET" include/pika_command.h src/pika_command.cc tests/
Length of output: 201 Script: #!/bin/bash
# Check test cases for HGET command behavior
cat tests/unit/type/hash.tcl
# Look for HGET command implementation in source files
rg -A 10 "class HGetCmd|class HMgetCmd" src/
# Check command flags and definitions
rg "kCmdNameHGet|kCmdNameHMGet" include/
Length of output: 16706 |
||
////HGetallCmd | ||
std::unique_ptr<Cmd> hgetallptr = | ||
|
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.
🛠️ Refactor suggestion
Consider renaming
HMsetCmd
toHSetCmd
for clarity and consistency.The
HSET
command is now associated withHMsetCmd
, which may cause confusion sinceHMsetCmd
typically corresponds to theHMSET
command. To maintain clarity and align with command naming conventions, consider renamingHMsetCmd
back toHSetCmd
or updating the class name to reflect its association withHSET
.