-
Notifications
You must be signed in to change notification settings - Fork 493
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(tdigest): add tdigest algorithm and storage encoding implementations #2741
feat(tdigest): add tdigest algorithm and storage encoding implementations #2741
Conversation
Hi Team, Sorry for delaying this feature's implementation. I kept the commit log since we will squash merging. Please give me some suggestions and help take a review. There are still many parts need to be improved, and I will be very happy to try my best for any improvement. 😊 Best Regards, |
26d8348
to
f0f2f3d
Compare
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/storage/redis_metadata.h
Outdated
uint64_t total_observations = 0; | ||
uint64_t merge_times = 0; |
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.
We can add a comment for that one
src/types/redis_tdigest.cc
Outdated
return iter_ != centroids_.cend(); | ||
} | ||
bool Prev() { | ||
if (Valid()) { |
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.
assume it's at end, what's it expected behavior 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.
Hi @mapleFU ,
At the beginning of tdigest centroids iteration, we have confirmed the value must be inside the range of (min_, max_)
.
So, if iteration reaches the cend()
, it means that the precheck logic doesn't cover all cases or the centroids may be corrupted.
Best Regards,
Edward
src/types/redis_tdigest.cc
Outdated
if (status.ok()) { | ||
return {}; | ||
} | ||
|
||
if (!status.IsNotFound()) { | ||
return status; | ||
} |
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.
Can we merge these two lines together?
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.
Hi @mapleFU ,
Thanks for your suggestion! 😊
We need to return both status and the existence of same tdigest before creation.
I have refactored the std::optional
with an explicit flag exists
with docstring.
Best Regards,
Edward
Hi @mapleFU , Sorry to interrupt you again. 😊 Have a nice day! Best Regards, |
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. We can first move on and add a go unittests
} | ||
return iter_ != centroids_.cend(); | ||
} | ||
bool Prev() { |
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.
Can you add a comment to explain the Prev()
requires to be valid? This function call is ok to be but a bit weird. Since if the iter is the cend()
, for std::vector
, it's not "Valid" but it prev is valid?
I've read the caller in tdigest.cc, this interface is ok since it prevent to call Prev()
if !Valid()
, but this requires some 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.
Hi @mapleFU ,
Thanks for your suggestion! 😊
I have added comment for this function.
Best Regards,
Edward
src/types/redis_tdigest.cc
Outdated
|
||
namespace redis { | ||
|
||
// It should be replaced by a iteration of the rocksdb iterator |
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.
Can you add a todo and create an issue for this?
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.
src/types/redis_tdigest.cc
Outdated
InternalKey ikey(key, storage_->IsSlotIdEncoded()); | ||
auto subkey = ikey.GetSubKey(); | ||
auto type_flg = static_cast<uint8_t>(SegmentType::kGuardFlag); | ||
GetFixed8(&subkey, &type_flg); |
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.
Have we checked the return value of Get{}
api 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.
Hi @mapleFU , Thanks very much for your warm help and patience! 😊 Best Regards, |
Let's merge first and then add lots of go tests |
|
Thank you for your contribution! |
Issue
Proposal
Proposed Changes
create
,add
andquantile
.create
,add
andquantile
.TODO List
DummyCentroids
to an iteration way for efficiency.