-
Notifications
You must be signed in to change notification settings - Fork 562
feat: add deleterange command and test #2839
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
base: unstable
Are you sure you want to change the base?
Conversation
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.
Seems that this command is implemented as scan and MDel?
I'm not sure should deleterange
supports prefix delete ( which could implemented with the help of rocksdb::DeleteRange
) or a scan and delete script like this? @git-hulk @PragmaTwice @ShooterIT
From my side, I think the prefix deletion could be a part of this command and we should use And for the |
may be we need two commands,deletepattern and deleterange,the range delete.Handling special operations for range deletion in regular expressions is overly challenging. Additionally, the 'type' is decoded from iter->value(), and I don't quite understand why it requires scanning metadata when the entire implementation seems to be just a combination of scan + mdel. |
For example, we have 1,000,000 strings and 100 hash keys with random key ranges. And we might need to scan the entire database if we would like to delete keys by the hash type. And yes, it makes sense to use SCAN + DEL if we could limit the maximum count on each delete. But perhaps it would be better to use |
I don't think SCAN is necessary if we have a good semantics and syntax of this command, e.g. for |
Yes, this would work if we don't support the |
We usually have |
@torwig We could simply use |
@git-hulk @PragmaTwice @ShooterIT Now, deleterange is a command with a clear semantic for range deletion. This command can be used in two ways: 1.deleterange begin_key end_key, which deletes key-value pairs in the range [begin_key, end_key). |
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 for typos, can we check crate-ci/typos#316 (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.
What about a "deleteprefix" command?
Current impl looks ok to me, however it supports two kind of cmd:
deleterange begin-key end-key
deleterange prefix
The (1) deletes [begin-key, end-key)
, which may need re-delete end-key. The second just delete prefix. I think using same command is ok but maybe it's not a good idea for an dangerous operation like this
@@ -111,6 +111,7 @@ class Database { | |||
[[nodiscard]] rocksdb::Status Expire(engine::Context &ctx, const Slice &user_key, uint64_t timestamp); | |||
[[nodiscard]] rocksdb::Status Del(engine::Context &ctx, const Slice &user_key); | |||
[[nodiscard]] rocksdb::Status MDel(engine::Context &ctx, const std::vector<Slice> &keys, uint64_t *deleted_cnt); | |||
[[nodiscard]] rocksdb::Status DeleteRange(engine::Context &ctx, const Slice &start, const Slice &end); |
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.
[[nodiscard]] rocksdb::Status DeleteRange(engine::Context &ctx, const Slice &start, const Slice &end); | |
[[nodiscard]] rocksdb::Status DeleteRange(engine::Context &ctx, Slice start, Slice end); |
if (args[1].find('*') != args[1].size() - 1) { | ||
return {Status::RedisParseErr, errInvalidSyntax}; | ||
} | ||
args_[1] = args[1].substr(0, args[1].size() - 1); |
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.
So this is a regex rule?
GH-2628
Added DELETERANGE command to delete keys by pattern,use like scan.The command format translates to English as: DELETERANGE cursor [MATCH pattern] [COUNT count] [TYPE type].The default parameters align with the SCAN command.