Skip to content

Commit 089d5c7

Browse files
committed
[Refactor](exec) Remove the unless code in BE
1 parent dc6e5fb commit 089d5c7

File tree

3 files changed

+0
-178
lines changed

3 files changed

+0
-178
lines changed

be/src/util/counts.h

-108
Original file line numberDiff line numberDiff line change
@@ -30,114 +30,6 @@
3030

3131
namespace doris {
3232

33-
class OldCounts {
34-
public:
35-
OldCounts() = default;
36-
37-
inline void merge(const OldCounts* other) {
38-
if (other == nullptr || other->_counts.empty()) {
39-
return;
40-
}
41-
42-
for (auto& cell : other->_counts) {
43-
increment(cell.first, cell.second);
44-
}
45-
}
46-
47-
void increment(int64_t key, uint32_t i) {
48-
auto item = _counts.find(key);
49-
if (item != _counts.end()) {
50-
item->second += i;
51-
} else {
52-
_counts.emplace(std::make_pair(key, i));
53-
}
54-
}
55-
56-
uint32_t serialized_size() const {
57-
return sizeof(uint32_t) + sizeof(int64_t) * _counts.size() +
58-
sizeof(uint32_t) * _counts.size();
59-
}
60-
61-
void serialize(uint8_t* writer) const {
62-
uint32_t size = _counts.size();
63-
memcpy(writer, &size, sizeof(uint32_t));
64-
writer += sizeof(uint32_t);
65-
for (auto& cell : _counts) {
66-
memcpy(writer, &cell.first, sizeof(int64_t));
67-
writer += sizeof(int64_t);
68-
memcpy(writer, &cell.second, sizeof(uint32_t));
69-
writer += sizeof(uint32_t);
70-
}
71-
}
72-
73-
void unserialize(const uint8_t* type_reader) {
74-
uint32_t size;
75-
memcpy(&size, type_reader, sizeof(uint32_t));
76-
type_reader += sizeof(uint32_t);
77-
for (uint32_t i = 0; i < size; ++i) {
78-
int64_t key;
79-
uint32_t count;
80-
memcpy(&key, type_reader, sizeof(int64_t));
81-
type_reader += sizeof(int64_t);
82-
memcpy(&count, type_reader, sizeof(uint32_t));
83-
type_reader += sizeof(uint32_t);
84-
_counts.emplace(std::make_pair(key, count));
85-
}
86-
}
87-
88-
double get_percentile(std::vector<std::pair<int64_t, uint32_t>>& counts,
89-
double position) const {
90-
long lower = long(std::floor(position));
91-
long higher = long(std::ceil(position));
92-
93-
auto iter = counts.begin();
94-
for (; iter != counts.end() && iter->second < lower + 1; ++iter)
95-
;
96-
97-
int64_t lower_key = iter->first;
98-
if (higher == lower) {
99-
return lower_key;
100-
}
101-
102-
if (iter->second < higher + 1) {
103-
iter++;
104-
}
105-
106-
int64_t higher_key = iter->first;
107-
if (lower_key == higher_key) {
108-
return lower_key;
109-
}
110-
111-
return (higher - position) * lower_key + (position - lower) * higher_key;
112-
}
113-
114-
double terminate(double quantile) const {
115-
if (_counts.empty()) {
116-
// Although set null here, but the value is 0.0 and the call method just
117-
// get val in aggregate_function_percentile_approx.h
118-
return 0.0;
119-
}
120-
121-
std::vector<std::pair<int64_t, uint32_t>> elems(_counts.begin(), _counts.end());
122-
sort(elems.begin(), elems.end(),
123-
[](const std::pair<int64_t, uint32_t> l, const std::pair<int64_t, uint32_t> r) {
124-
return l.first < r.first;
125-
});
126-
127-
long total = 0;
128-
for (auto& cell : elems) {
129-
total += cell.second;
130-
cell.second = total;
131-
}
132-
133-
long max_position = total - 1;
134-
double position = max_position * quantile;
135-
return get_percentile(elems, position);
136-
}
137-
138-
private:
139-
std::unordered_map<int64_t, uint32_t> _counts;
140-
};
14133
template <typename Ty>
14234
class Counts {
14335
public:

be/src/util/type_traits.h

-40
This file was deleted.

be/src/vec/functions/date_time_transforms.h

-30
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "runtime/runtime_state.h"
2525
#include "udf/udf.h"
2626
#include "util/binary_cast.hpp"
27-
#include "util/type_traits.h"
2827
#include "vec/columns/column_nullable.h"
2928
#include "vec/columns/column_string.h"
3029
#include "vec/columns/column_vector.h"
@@ -340,35 +339,6 @@ struct TransformerToStringOneArgument {
340339
}
341340
};
342341

343-
template <typename Transform>
344-
struct TransformerToStringTwoArgument {
345-
static void vector_constant(FunctionContext* context,
346-
const PaddedPODArray<typename Transform::FromType>& ts,
347-
const StringRef& format, ColumnString::Chars& res_data,
348-
ColumnString::Offsets& res_offsets,
349-
PaddedPODArray<UInt8>& null_map) {
350-
auto len = ts.size();
351-
res_offsets.resize(len);
352-
res_data.reserve(len * format.size + len);
353-
null_map.resize_fill(len, false);
354-
355-
size_t offset = 0;
356-
for (int i = 0; i < len; ++i) {
357-
const auto& t = ts[i];
358-
size_t new_offset;
359-
bool is_null;
360-
if constexpr (is_specialization_of_v<Transform, FromUnixTimeImpl>) {
361-
std::tie(new_offset, is_null) = Transform::execute(
362-
t, format, res_data, offset, context->state()->timezone_obj());
363-
} else {
364-
std::tie(new_offset, is_null) = Transform::execute(t, format, res_data, offset);
365-
}
366-
res_offsets[i] = cast_set<UInt32>(new_offset);
367-
null_map[i] = is_null;
368-
}
369-
}
370-
};
371-
372342
template <typename FromType, typename ToType, typename Transform>
373343
struct Transformer {
374344
static void vector(const PaddedPODArray<FromType>& vec_from, PaddedPODArray<ToType>& vec_to,

0 commit comments

Comments
 (0)