This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b2c70b51cc [refactor](vectorized) delete row-based AnyVal and
DateTimeVal (#18093)
b2c70b51cc is described below
commit b2c70b51cce5402dc6825b8702036cc514478a7e
Author: Gabriel <[email protected]>
AuthorDate: Sat Mar 25 09:40:04 2023 +0800
[refactor](vectorized) delete row-based AnyVal and DateTimeVal (#18093)
---
be/src/udf/udf.h | 43 -----------------------------
be/src/util/bitmap_intersect.h | 16 ++++-------
be/src/vec/functions/function_timestamp.cpp | 12 +-------
be/src/vec/runtime/vdatetime_value.h | 37 ++++++++-----------------
4 files changed, 18 insertions(+), 90 deletions(-)
diff --git a/be/src/udf/udf.h b/be/src/udf/udf.h
index 3d9303067c..284aac6132 100644
--- a/be/src/udf/udf.h
+++ b/be/src/udf/udf.h
@@ -178,48 +178,5 @@ private:
std::string _string_result;
};
-//----------------------------------------------------------------------------
-//-------------Implementation of the *Val structs ----------------------------
-//----------------------------------------------------------------------------
-struct AnyVal {
- bool is_null;
-
- AnyVal() : is_null(false) {}
-
- AnyVal(bool is_null) : is_null(is_null) {}
-};
-
-// This object has a compatible storage format with boost::ptime.
-struct DateTimeVal : public AnyVal {
- // MySQL packet time
- int64_t packed_time;
- // Indicate which type of this value.
- int type;
-
- // NOTE: Type 3 is TIME_DATETIME in runtime/datetime_value.h
- DateTimeVal() : packed_time(0), type(3) {}
-
- static DateTimeVal null() {
- DateTimeVal result;
- result.is_null = true;
- return result;
- }
-
- bool operator==(const DateTimeVal& other) const {
- if (is_null && other.is_null) {
- return true;
- }
-
- if (is_null || other.is_null) {
- return false;
- }
-
- return packed_time == other.packed_time;
- }
-
- bool operator!=(const DateTimeVal& other) const { return !(*this ==
other); }
-};
-
-using doris::DateTimeVal;
using doris::FunctionContext;
} // namespace doris
diff --git a/be/src/util/bitmap_intersect.h b/be/src/util/bitmap_intersect.h
index b9be93e0f8..72695f331f 100644
--- a/be/src/util/bitmap_intersect.h
+++ b/be/src/util/bitmap_intersect.h
@@ -17,7 +17,6 @@
#pragma once
#include <parallel_hashmap/phmap.h>
-#include "udf/udf.h"
#include "util/bitmap_value.h"
#include "vec/common/string_ref.h"
@@ -57,11 +56,9 @@ public:
template <>
char* Helper::write_to<vectorized::VecDateTimeValue>(const
vectorized::VecDateTimeValue& v,
char* dest) {
- DateTimeVal value;
- v.to_datetime_val(&value);
- *(int64_t*)dest = value.packed_time;
+ *(int64_t*)dest = v.to_int64_datetime_packed();
dest += DATETIME_PACKED_TIME_BYTE_SIZE;
- *(int*)dest = value.type;
+ *(int*)dest = v.type();
dest += DATETIME_TYPE_BYTE_SIZE;
return dest;
}
@@ -118,13 +115,12 @@ int32_t Helper::serialize_size<std::string>(const
std::string& v) {
template <>
void Helper::read_from<vectorized::VecDateTimeValue>(const char** src,
vectorized::VecDateTimeValue* result) {
- DateTimeVal value;
- value.is_null = false;
- value.packed_time = *(int64_t*)(*src);
+ result->from_packed_time(*(int64_t*)(*src));
*src += DATETIME_PACKED_TIME_BYTE_SIZE;
- value.type = *(int*)(*src);
+ if (*(int*)(*src) == TIME_DATE) {
+ result->cast_to_date();
+ }
*src += DATETIME_TYPE_BYTE_SIZE;
- *result = vectorized::VecDateTimeValue::from_datetime_val(value);
}
template <>
diff --git a/be/src/vec/functions/function_timestamp.cpp
b/be/src/vec/functions/function_timestamp.cpp
index af34c6911f..6d033a03ef 100644
--- a/be/src/vec/functions/function_timestamp.cpp
+++ b/be/src/vec/functions/function_timestamp.cpp
@@ -205,15 +205,8 @@ struct MakeDateImpl {
VecDateTimeValue ts_value = VecDateTimeValue();
ts_value.set_time(l, 1, 1, 0, 0, 0);
- DateTimeVal ts_val;
- ts_value.to_datetime_val(&ts_val);
- if (ts_val.is_null) {
- null_map[i] = 1;
- continue;
- }
-
TimeInterval interval(DAY, r - 1, false);
- res_val = VecDateTimeValue::from_datetime_val(ts_val);
+ res_val = ts_value;
if (!res_val.template date_add_interval<DAY>(interval)) {
null_map[i] = 1;
continue;
@@ -364,9 +357,6 @@ private:
null_map[i] = 1;
continue;
}
- DateTimeVal ts_val;
- ts_value.to_datetime_val(&ts_val);
- ts_value = VecDateTimeValue::from_datetime_val(ts_val);
} else {
const auto& cur_data = data_col[i];
auto& ts_value =
*reinterpret_cast<DateValueType*>(&res_data[i]);
diff --git a/be/src/vec/runtime/vdatetime_value.h
b/be/src/vec/runtime/vdatetime_value.h
index dce2334c7a..a0e1739c36 100644
--- a/be/src/vec/runtime/vdatetime_value.h
+++ b/be/src/vec/runtime/vdatetime_value.h
@@ -26,7 +26,6 @@
#include <iostream>
#include "cctz/time_zone.h"
-#include "udf/udf.h"
#include "util/hash_util.hpp"
#include "util/time_lut.h"
#include "util/timezone_utils.h"
@@ -566,11 +565,6 @@ public:
VecDateTimeValue& operator--() { return *this += -1; }
- void to_datetime_val(doris::DateTimeVal* tv) const {
- tv->packed_time = to_int64_datetime_packed();
- tv->type = _type;
- }
-
uint32_t to_date_v2() const {
CHECK(_type == TIME_DATE);
return (year() << 9 | month() << 5 | day());
@@ -583,15 +577,6 @@ public:
((uint64_t)minute() << 26) | ((uint64_t)second() <<
20));
}
- static VecDateTimeValue from_datetime_val(const doris::DateTimeVal& tv) {
- VecDateTimeValue value;
- value.from_packed_time(tv.packed_time);
- if (tv.type == TIME_DATE) {
- value.cast_to_date();
- }
- return value;
- }
-
uint32_t hash(int seed) const { return ::doris::HashUtil::hash(this,
sizeof(*this), seed); }
int day_of_year() const { return daynr() - calc_daynr(_year, 1, 1) + 1; }
@@ -636,9 +621,13 @@ public:
int64_t to_datetime_int64() const;
-private:
- // Used to make sure sizeof VecDateTimeValue
- friend class UnusedClass;
+ // To compatible with MySQL
+ int64_t to_int64_datetime_packed() const {
+ int64_t ymd = ((_year * 13 + _month) << 5) | _day;
+ int64_t hms = (_hour << 12) | (_minute << 6) | _second;
+ int64_t tmp = make_packed_time(((ymd << 17) | hms), 0);
+ return _neg ? -tmp : tmp;
+ }
void from_packed_time(int64_t packed_time) {
int64_t ymdhms = packed_time >> 24;
@@ -657,18 +646,14 @@ private:
_type = TIME_DATETIME;
}
+private:
+ // Used to make sure sizeof VecDateTimeValue
+ friend class UnusedClass;
+
int64_t make_packed_time(int64_t time, int64_t second_part) const {
return (time << 24) + second_part;
}
- // To compatible with MySQL
- int64_t to_int64_datetime_packed() const {
- int64_t ymd = ((_year * 13 + _month) << 5) | _day;
- int64_t hms = (_hour << 12) | (_minute << 6) | _second;
- int64_t tmp = make_packed_time(((ymd << 17) | hms), 0);
- return _neg ? -tmp : tmp;
- }
-
int64_t to_int64_date_packed() const {
int64_t ymd = ((_year * 13 + _month) << 5) | _day;
int64_t tmp = make_packed_time(ymd << 17, 0);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]