github-actions[bot] commented on code in PR #38985: URL: https://github.com/apache/doris/pull/38985#discussion_r1705832162
########## be/src/vec/columns/column_vector.cpp: ########## @@ -236,7 +236,8 @@ void ColumnVector<T>::get_permutation(bool reverse, size_t limit, int nan_direct if (s == 0) return; - if (limit >= s) limit = 0; + // std::partial_sort need limit << s can get performance benefit + if (limit > (s / 8.0)) limit = 0; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (limit > (s / 8.0)) { limit = 0; } ``` ########## be/src/vec/columns/column_decimal.h: ########## @@ -269,14 +269,22 @@ class ColumnDecimal final : public COWHelper<IColumn, ColumnDecimal<T>> { for (U i = 0; i < s; ++i) res[i] = i; auto sort_end = res.end(); - if (limit && limit < s) sort_end = res.begin() + limit; - - if (reverse) - std::partial_sort(res.begin(), sort_end, res.end(), - [this](size_t a, size_t b) { return data[a] > data[b]; }); - else - std::partial_sort(res.begin(), sort_end, res.end(), - [this](size_t a, size_t b) { return data[a] < data[b]; }); + if (limit && limit < s / 8.0) { + sort_end = res.begin() + limit; + if (reverse) + std::partial_sort(res.begin(), sort_end, res.end(), + [this](size_t a, size_t b) { return data[a] > data[b]; }); + else + std::partial_sort(res.begin(), sort_end, res.end(), + [this](size_t a, size_t b) { return data[a] < data[b]; }); + } else { + if (reverse) Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (reverse) { ``` be/src/vec/columns/column_decimal.h:283: ```diff - else + } else ``` ########## be/src/vec/columns/column_decimal.h: ########## @@ -269,14 +269,22 @@ for (U i = 0; i < s; ++i) res[i] = i; auto sort_end = res.end(); - if (limit && limit < s) sort_end = res.begin() + limit; - - if (reverse) - std::partial_sort(res.begin(), sort_end, res.end(), - [this](size_t a, size_t b) { return data[a] > data[b]; }); - else - std::partial_sort(res.begin(), sort_end, res.end(), - [this](size_t a, size_t b) { return data[a] < data[b]; }); + if (limit && limit < s / 8.0) { + sort_end = res.begin() + limit; + if (reverse) + std::partial_sort(res.begin(), sort_end, res.end(), + [this](size_t a, size_t b) { return data[a] > data[b]; }); + else + std::partial_sort(res.begin(), sort_end, res.end(), + [this](size_t a, size_t b) { return data[a] < data[b]; }); + } else { + if (reverse) + pdqsort(res.begin(), res.end(), + [this](size_t a, size_t b) { return data[a] > data[b]; }); + else Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion else { ``` be/src/vec/columns/column_decimal.h:285: ```diff - [this](size_t a, size_t b) { return data[a] < data[b]; }); + [this](size_t a, size_t b) { return data[a] < data[b]; }); + } ``` ########## be/src/vec/columns/column_string.cpp: ########## @@ -457,9 +457,8 @@ void ColumnStr<T>::get_permutation(bool reverse, size_t limit, int /*nan_directi res[i] = i; } - if (limit >= s) { - limit = 0; - } + // std::partial_sort need limit << s can get performance benefit + if (limit > (s / 8.0)) limit = 0; Review Comment: warning: statement should be inside braces [readability-braces-around-statements] ```suggestion if (limit > (s / 8.0)) { limit = 0; } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org