-
Notifications
You must be signed in to change notification settings - Fork 625
refactor(tdigest): convert the flags for reverse in TDigest::Rank to a compile-time argument #3268
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
Merged
LindaSummer
merged 32 commits into
apache:unstable
from
donghao526:refactor/tdigest-rank
Dec 13, 2025
Merged
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4784442
refactor: make all the flags for reverse as a compile-time argument
donghao526 45281c3
Merge branch 'unstable' into refactor/tdigest-rank
PragmaTwice b421adb
refactor(tdigest): change variable reverse to Reverse
donghao526 1ced14d
Merge branch 'refactor/tdigest-rank' of github.com:donghao526/kvrocks…
donghao526 70ec5b8
refactor(tdigest): update TDigestRank template parameters for clarity
donghao526 c42ed44
refactor(tdigest): update DummyCentroids to use template parameter fo…
donghao526 5d3a885
style: use the init-statement for calling TDigestRank
donghao526 3bb2fe6
refactor(tdigest): simplify iterator handling in DummyCentroids and i…
donghao526 f1c559c
Merge branch 'refactor/tdigest-rank' of github.com:donghao526/kvrocks…
donghao526 7fb6b2f
refactor(tdigest): change get_cbegin_iter and get_cend_iter methods t…
donghao526 0ed408d
refactor(tdigest): rename function names for consistency
donghao526 d5cce3f
Merge branch 'unstable' into refactor/tdigest-rank
PragmaTwice 843af3d
refactor(tdigest): make iterator methods static and improve clarity i…
donghao526 3c935d8
Merge branch 'refactor/tdigest-rank' of github.com:donghao526/kvrocks…
donghao526 48c1f47
Merge branch 'unstable' into refactor/tdigest-rank
donghao526 4bdb79b
refactor(tdigest): rename iterator methods for consistency and clarity
donghao526 b6074af
refactor(tdigest): refactor the GetCbeginIter and GetCendIter to deta…
donghao526 c2894a0
Merge branch 'unstable' into refactor/tdigest-rank
donghao526 7487397
refactor(tdigest): replace template Rank with separate Rank and RevRa…
donghao526 0aaa788
Merge branch 'refactor/tdigest-rank' of github.com:donghao526/kvrocks…
donghao526 be9a404
refactor(tdigest): move Rank and RevRank methods above Quantile for b…
donghao526 8f229ce
refactor(tdigest): remove unused RankImpl template function
donghao526 e73eae4
refactor(tdigest): extract common preparation logic from Rank and Rev…
donghao526 69bf01a
refactor(tdigest): remove unnecessary comment indicating special retu…
donghao526 e1ed70a
refactor(tdigest): fix compile error
donghao526 798a69d
refactor(tdigest): fix clang-format error
donghao526 1c3ae7d
refactor(tdigest): fix error when get rank on an empty tdigest
donghao526 4b37eed
refactor(tdigest): fix some compile error
donghao526 6911242
Merge branch 'unstable' into refactor/tdigest-rank
donghao526 c097f8c
refactor(tdigest): use the init-statement to declare "s" inside the i…
donghao526 f4e5488
Merge branch 'refactor/tdigest-rank' of github.com:donghao526/kvrocks…
donghao526 a06db87
Merge branch 'unstable' into refactor/tdigest-rank
donghao526 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,7 @@ struct DoubleComparator { | |
| }; | ||
|
|
||
| template <typename TD, bool Reverse> | ||
|
PragmaTwice marked this conversation as resolved.
Outdated
|
||
| inline Status TDigestRankImpl(TD&& td, const std::vector<double>& inputs, std::vector<int>& result) { | ||
| inline Status TDigestRank(TD&& td, const std::vector<double>& inputs, std::vector<int>& result) { | ||
| std::map<double, size_t, DoubleComparator> value_to_index; | ||
| for (size_t i = 0; i < inputs.size(); ++i) { | ||
| value_to_index[inputs[i]] = i; | ||
|
|
@@ -266,13 +266,4 @@ inline Status TDigestRankImpl(TD&& td, const std::vector<double>& inputs, std::v | |
| } | ||
| } | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| template <typename TD> | ||
| inline Status TDigestRank(TD&& td, const std::vector<double>& inputs, bool reverse, std::vector<int>& result) { | ||
| if (reverse) { | ||
| return TDigestRankImpl<TD, true>(std::forward<TD>(td), inputs, result); | ||
| } else { | ||
| return TDigestRankImpl<TD, false>(std::forward<TD>(td), inputs, result); | ||
| } | ||
| } | ||
| } | ||
|
Member
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. Add an endline for this file. |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Could we have something like
template <bool Reverse> class Iteratorinstead of virtual functions?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.
Of course, I have refactored the code.