BiteTheDDDDt commented on code in PR #26191:
URL: https://github.com/apache/doris/pull/26191#discussion_r1381320218
##########
be/src/vec/columns/predicate_column.h:
##########
@@ -220,29 +201,60 @@ class PredicateColumnType final : public
COWHelper<IColumn, PredicateColumnType<
}
void insert_many_date(const char* data_ptr, size_t num) {
- size_t intput_type_size = sizeof(uint24_t);
- size_t res_type_size = sizeof(uint32_t);
+ constexpr size_t input_type_size =
sizeof(PrimitiveTypeTraits<TYPE_DATE>::StorageFieldType);
+ static_assert(input_type_size == sizeof(uint24_t));
char* input_data_ptr = const_cast<char*>(data_ptr);
- char* res_ptr = (char*)data.get_end_ptr();
- memset(res_ptr, 0, res_type_size * num);
+ auto* res_ptr =
reinterpret_cast<VecDateTimeValue*>(data.get_end_ptr());
for (int i = 0; i < num; i++) {
- memcpy(res_ptr, input_data_ptr, intput_type_size);
- res_ptr += res_type_size;
- input_data_ptr += intput_type_size;
+ uint64_t value = *reinterpret_cast<uint24_t*>(input_data_ptr);
+ res_ptr[i].set_olap_date(value);
+ input_data_ptr += input_type_size;
+ }
+ data.set_end_ptr(res_ptr + num);
+ }
+
+ void insert_many_datetime(const char* data_ptr, size_t num) {
+ constexpr size_t input_type_size =
+ sizeof(PrimitiveTypeTraits<TYPE_DATETIME>::StorageFieldType);
+ static_assert(input_type_size == sizeof(uint64_t));
+ char* input_data_ptr = const_cast<char*>(data_ptr);
+
+ auto* res_ptr =
reinterpret_cast<VecDateTimeValue*>(data.get_end_ptr());
+ for (int i = 0; i < num; i++) {
+
res_ptr[i].from_olap_datetime(*reinterpret_cast<uint64_t*>(input_data_ptr));
+ input_data_ptr += input_type_size;
+ }
+ data.set_end_ptr(res_ptr + num);
+ }
+
+ // The logic is same to ColumnDecimal::insert_many_fix_len_data
+ void insert_many_decimalv2(const char* data_ptr, size_t num) {
+ size_t old_size = data.size();
+ data.resize(old_size + num);
+
+ DecimalV2Value* target = (DecimalV2Value*)(data.data() + old_size);
+ for (int i = 0; i < num; i++) {
+ const char* cur_ptr = data_ptr + sizeof(decimal12_t) * i;
+ int64_t int_value = unaligned_load<int64_t>(cur_ptr);
+ int32_t frac_value = *(int32_t*)(cur_ptr + sizeof(int64_t));
+ target[i].from_olap_decimal(int_value, frac_value);
}
- data.set_end_ptr(res_ptr);
}
void insert_many_fix_len_data(const char* data_ptr, size_t num) override {
- if constexpr (std::is_same_v<T, decimal12_t>) {
Review Comment:
Add a method to convert from StorageFieldType to CppType, and then we can
remove the if else in get_zone_map_value/insert_many_fix_len_data, and all
methods like insert_many_date/insert_many_decimalv2...
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]