-
Notifications
You must be signed in to change notification settings - Fork 487
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
feat(hash): add support of hash expiration commands #2717
base: unstable
Are you sure you want to change the base?
Conversation
@ltagliamonte-dd Hi. Did you set this config |
Hello @jjz921024 thanks for getting back to me, yes I did test all hash commands having
|
@jjz921024 the CI seems to pass removing the check in GetMetadata and fixing GetTime. |
@jjz921024 @ltagliamonte-dd Thanks for your great efforts. I took my first pass in a new PR and generally look in good shape from my perspective. Two nit points can be improved:
if (metadata.Type() == kRedisHash) {
HashMetadata hash_metadata(false);
s = hash_metadata.Decode(rocksdb::Slice(pin_values[i].data(), pin_values[i].size()));
if (!s.ok()) continue;
redis::Hash hash_db(storage_, namespace_);
if (hash_db.ExistValidField(ctx, slice_keys[i], hash_metadata)) { |
@ltagliamonte-dd Hi, I create a PR #1 in your kvrocks fork repo. There are some polish about this feature for your reference. The purpose of this this commit aac63cc is to avoid unnecessary field expiration checks when executing the hset/hmset command, which comes from #2402 (comment) @PragmaTwice suggestion. The purpose of this this commit 7306231 is make |
Hello @jjz921024 thank you for the help on getting this through the finish line. Discussing this check with @PragmaTwice and @git-hulk on zulipchat we decided to move the check up in the call stack and perform it only when required. As the CI on this PR is showing (and my verification) it looks like there is no need for expiration check in GetMetadata, I would love to hear from you if i'm missing something and why the check is required. Please join us on zulipchat so we can discuss this in a more interactive way. by removing the check in GetMetadata commit aac63cc is not needed thank you for commit 7306231 i will be importing it. |
@git-hulk I gave a look at your suggestion to remove duplicated code, it looks like duplicated but if you look closely they are all slightly different checks... we may be able to refactor with something like this:
so we pass an handleFunction into the refactored function |
@PragmaTwice @mapleFU @torwig @caipengbo To see if you guys can have a look at this PR. It generally looks good to me. It'd be nice to push this feature forward to avoid pending too long time. |
I'll take a look at this weekend if no other things happen : ) cc @mapleFU PTAL. Also now we need to solve git conflicts before reviewing and merging. cc @ltagliamonte-dd |
@PragmaTwice can you please re-trigger the CI it looks like a flaky test |
src/types/redis_hash.cc
Outdated
rocksdb::Status Hash::encodeExpireToValue(std::string *value, uint64_t expire) { | ||
std::string buf; | ||
PutFixed64(&buf, expire); | ||
buf.append(*value); | ||
value->assign(buf.data(), buf.size()); | ||
return rocksdb::Status::OK(); | ||
} |
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.
rocksdb::Status Hash::encodeExpireToValue(std::string *value, uint64_t expire) { | |
std::string buf; | |
PutFixed64(&buf, expire); | |
buf.append(*value); | |
value->assign(buf.data(), buf.size()); | |
return rocksdb::Status::OK(); | |
} | |
rocksdb::Status Hash::encodeExpireAndValue(std::string_view value, uint64_t expire, std::string *out) { | |
PutFixed64(out, expire); | |
out->append(value); | |
return rocksdb::Status::OK(); | |
} |
Also for all places that uses this function.
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.
@PragmaTwice I have trouble understanding the suggestion.. would be this correct:
rocksdb::Status Hash::encodeExpireAndValue(std::string value, uint64_t expire, std::string *enc_value) {
PutFixed64(enc_value, expire);
enc_value->append(value);
return rocksdb::Status::OK();
}
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 think string_view
should 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.
@PragmaTwice please let me know how 3a726e1 looks, happy to address further if needed.
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.
@PragmaTwice string_view comment addressed via b10d710
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.
Ahh I revisited it and I think it can be std::string Hash::encodeExpireAndValue(std::string_view value, uint64_t expire)
.
The returned status here seems useless.
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.
std::string Hash::encodeExpireAndValue(std::string_view value, uint64_t expire) {
std::string out;
PutFixed64(&out, expire);
out.append(value);
return out;
}
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.
thanks addressed via 9bbc8d9
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.
Yes, we need to take care of this after introducing the hash expiration feature. But we can try to improve this before formally releasing it. |
Quality Gate passedIssues Measures |
based on #2402
@jjz921024 I verified all hash cmds and they seem to work without the additional check in GetMetadata do you happen to remember if there was a specific use case you added it there?