Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions be/src/vec/columns/column_decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include <glog/logging.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'glog/logging.h' file not found [clang-diagnostic-error]

#include <glog/logging.h>
         ^

#include <pdqsort.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
Expand Down Expand Up @@ -269,14 +270,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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
if (reverse)
if (reverse) {

be/src/vec/columns/column_decimal.h:283:

-             else
+             } else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
if (reverse)
if (reverse) {

be/src/vec/columns/column_decimal.h:284:

-             else
+             } else

pdqsort(res.begin(), res.end(),
[this](size_t a, size_t b) { return data[a] > data[b]; });
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
else
else {

be/src/vec/columns/column_decimal.h:285:

-                         [this](size_t a, size_t b) { return data[a] < data[b]; });
+                         [this](size_t a, size_t b) { return data[a] < data[b]; });
+ }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
else
else {

be/src/vec/columns/column_decimal.h:286:

-                         [this](size_t a, size_t b) { return data[a] < data[b]; });
+                         [this](size_t a, size_t b) { return data[a] < data[b]; });
+ }

pdqsort(res.begin(), res.end(),
[this](size_t a, size_t b) { return data[a] < data[b]; });
}
}

void ALWAYS_INLINE decimalv2_do_crc(size_t i, uint32_t& hash) const {
Expand Down
9 changes: 4 additions & 5 deletions be/src/vec/columns/column_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
if (limit > (s / 8.0)) limit = 0;
if (limit > (s / 8.0)) { limit = 0;
}


if (limit) {
if (reverse) {
Expand All @@ -469,9 +468,9 @@ void ColumnStr<T>::get_permutation(bool reverse, size_t limit, int /*nan_directi
}
} else {
if (reverse) {
std::sort(res.begin(), res.end(), less<false>(*this));
pdqsort(res.begin(), res.end(), less<false>(*this));
} else {
std::sort(res.begin(), res.end(), less<true>(*this));
pdqsort(res.begin(), res.end(), less<true>(*this));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/columns/column_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
if (limit > (s / 8.0)) limit = 0;
if (limit > (s / 8.0)) { limit = 0;
}


if (limit) {
for (size_t i = 0; i < s; ++i) res[i] = i;
Expand Down