Skip to content

Commit

Permalink
remove datetime_value and move vecdatetime_value to doris namespace (a…
Browse files Browse the repository at this point in the history
…pache#25695)

remove datetime_value and move vecdatetime_value to doris namespace
  • Loading branch information
BiteTheDDDDt authored Oct 20, 2023
1 parent 3ffc6f0 commit 642c149
Show file tree
Hide file tree
Showing 59 changed files with 256 additions and 420 deletions.
28 changes: 11 additions & 17 deletions be/src/exec/es/es_scroll_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Status get_int_value(const rapidjson::Value& col, PrimitiveType type, void* slot
template <typename T, typename RT>
Status get_date_value_int(const rapidjson::Value& col, PrimitiveType type, bool is_date_str,
RT* slot, const cctz::time_zone& time_zone) {
constexpr bool is_datetime_v1 = std::is_same_v<T, vectorized::VecDateTimeValue>;
constexpr bool is_datetime_v1 = std::is_same_v<T, VecDateTimeValue>;
T dt_val;
if (is_date_str) {
const std::string str_date = col.GetString();
Expand Down Expand Up @@ -656,18 +656,16 @@ Status ScrollParser::fill_columns(const TupleDescriptor* tuple_desc,

case TYPE_DATE:
case TYPE_DATETIME:
RETURN_IF_ERROR((fill_date_int<vectorized::VecDateTimeValue, int64_t>(
col, type, pure_doc_value, col_ptr, time_zone)));
RETURN_IF_ERROR((fill_date_int<VecDateTimeValue, int64_t>(col, type, pure_doc_value,
col_ptr, time_zone)));
break;
case TYPE_DATEV2:
RETURN_IF_ERROR(
(fill_date_int<vectorized::DateV2Value<vectorized::DateV2ValueType>, uint32_t>(
col, type, pure_doc_value, col_ptr, time_zone)));
RETURN_IF_ERROR((fill_date_int<DateV2Value<DateV2ValueType>, uint32_t>(
col, type, pure_doc_value, col_ptr, time_zone)));
break;
case TYPE_DATETIMEV2: {
RETURN_IF_ERROR(
(fill_date_int<vectorized::DateV2Value<vectorized::DateTimeV2ValueType>,
uint64_t>(col, type, pure_doc_value, col_ptr, time_zone)));
RETURN_IF_ERROR((fill_date_int<DateV2Value<DateTimeV2ValueType>, uint64_t>(
col, type, pure_doc_value, col_ptr, time_zone)));
break;
}
case TYPE_ARRAY: {
Expand Down Expand Up @@ -773,19 +771,15 @@ Status ScrollParser::fill_columns(const TupleDescriptor* tuple_desc,
// No need to support date and datetime types.
case TYPE_DATEV2: {
uint32_t data;
RETURN_IF_ERROR(
(get_date_int<vectorized::DateV2Value<vectorized::DateV2ValueType>,
uint32_t>(sub_col, sub_type, pure_doc_value, &data,
time_zone)));
RETURN_IF_ERROR((get_date_int<DateV2Value<DateV2ValueType>, uint32_t>(
sub_col, sub_type, pure_doc_value, &data, time_zone)));
array.push_back(data);
break;
}
case TYPE_DATETIMEV2: {
uint64_t data;
RETURN_IF_ERROR(
(get_date_int<vectorized::DateV2Value<vectorized::DateTimeV2ValueType>,
uint64_t>(sub_col, sub_type, pure_doc_value, &data,
time_zone)));
RETURN_IF_ERROR((get_date_int<DateV2Value<DateTimeV2ValueType>, uint64_t>(
sub_col, sub_type, pure_doc_value, &data, time_zone)));
array.push_back(data);
break;
}
Expand Down
6 changes: 2 additions & 4 deletions be/src/exec/olap_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "exec/olap_utils.h"
#include "olap/olap_common.h"
#include "olap/olap_tuple.h"
#include "runtime/datetime_value.h"
#include "runtime/define_primitive_type.h"
#include "runtime/primitive_type.h"
#include "runtime/type_limit.h"
Expand All @@ -60,9 +59,8 @@ std::string cast_to_string(T value, int scale) {
} else if constexpr (primitive_type == TYPE_LARGEINT) {
return vectorized::int128_to_string(value);
} else if constexpr (primitive_type == TYPE_DATETIMEV2) {
doris::vectorized::DateV2Value<doris::vectorized::DateTimeV2ValueType> datetimev2_val =
static_cast<doris::vectorized::DateV2Value<doris::vectorized::DateTimeV2ValueType>>(
value);
DateV2Value<DateTimeV2ValueType> datetimev2_val =
static_cast<DateV2Value<DateTimeV2ValueType>>(value);
char buf[30];
datetimev2_val.to_string(buf);
std::stringstream ss;
Expand Down
1 change: 0 additions & 1 deletion be/src/exec/olap_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "common/logging.h"
#include "olap/olap_tuple.h"
#include "runtime/datetime_value.h"
#include "runtime/primitive_type.h"

namespace doris {
Expand Down
6 changes: 3 additions & 3 deletions be/src/exec/schema_scanner/schema_tables_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Status SchemaTablesScanner::_fill_block_impl(vectorized::Block* block) {
{ static_cast<void>(fill_dest_column_for_range(block, 13, null_datas)); }
// creation_time
{
vectorized::VecDateTimeValue srcs[table_num];
VecDateTimeValue srcs[table_num];
for (int i = 0; i < table_num; ++i) {
const TTableStatus& tbl_status = _table_result.tables[i];
if (tbl_status.__isset.create_time) {
Expand All @@ -274,7 +274,7 @@ Status SchemaTablesScanner::_fill_block_impl(vectorized::Block* block) {
}
// update_time
{
vectorized::VecDateTimeValue srcs[table_num];
VecDateTimeValue srcs[table_num];
for (int i = 0; i < table_num; ++i) {
const TTableStatus& tbl_status = _table_result.tables[i];
if (tbl_status.__isset.update_time) {
Expand All @@ -293,7 +293,7 @@ Status SchemaTablesScanner::_fill_block_impl(vectorized::Block* block) {
}
// check_time
{
vectorized::VecDateTimeValue srcs[table_num];
VecDateTimeValue srcs[table_num];
for (int i = 0; i < table_num; ++i) {
const TTableStatus& tbl_status = _table_result.tables[i];
if (tbl_status.__isset.last_check_time) {
Expand Down
17 changes: 6 additions & 11 deletions be/src/exec/table_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ Status TableConnector::convert_column_data(const vectorized::ColumnPtr& column_p
fmt::format_to(_insert_stmt_buffer, "{}", *reinterpret_cast<const double*>(item));
break;
case TYPE_DATE: {
vectorized::VecDateTimeValue value =
binary_cast<int64_t, doris::vectorized::VecDateTimeValue>(*(int64_t*)item);
VecDateTimeValue value = binary_cast<int64_t, doris::VecDateTimeValue>(*(int64_t*)item);

char buf[64];
char* pos = value.to_string(buf);
Expand All @@ -167,8 +166,7 @@ Status TableConnector::convert_column_data(const vectorized::ColumnPtr& column_p
break;
}
case TYPE_DATETIME: {
vectorized::VecDateTimeValue value =
binary_cast<int64_t, doris::vectorized::VecDateTimeValue>(*(int64_t*)item);
VecDateTimeValue value = binary_cast<int64_t, doris::VecDateTimeValue>(*(int64_t*)item);

char buf[64];
char* pos = value.to_string(buf);
Expand All @@ -177,9 +175,8 @@ Status TableConnector::convert_column_data(const vectorized::ColumnPtr& column_p
break;
}
case TYPE_DATEV2: {
vectorized::DateV2Value<vectorized::DateV2ValueType> value =
binary_cast<uint32_t, doris::vectorized::DateV2Value<vectorized::DateV2ValueType>>(
*(int32_t*)item);
DateV2Value<DateV2ValueType> value =
binary_cast<uint32_t, DateV2Value<DateV2ValueType>>(*(int32_t*)item);

char buf[64];
char* pos = value.to_string(buf);
Expand All @@ -188,10 +185,8 @@ Status TableConnector::convert_column_data(const vectorized::ColumnPtr& column_p
break;
}
case TYPE_DATETIMEV2: {
vectorized::DateV2Value<vectorized::DateTimeV2ValueType> value =
binary_cast<uint64_t,
doris::vectorized::DateV2Value<vectorized::DateTimeV2ValueType>>(
*(int64_t*)item);
DateV2Value<DateTimeV2ValueType> value =
binary_cast<uint64_t, DateV2Value<DateTimeV2ValueType>>(*(int64_t*)item);

char buf[64];
char* pos = value.to_string(buf, type.scale);
Expand Down
6 changes: 3 additions & 3 deletions be/src/exec/tablet_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ Status VOlapTablePartitionParam::_create_partition_key(const TExprNode& t_expr,
switch (t_expr.node_type) {
case TExprNodeType::DATE_LITERAL: {
if (TypeDescriptor::from_thrift(t_expr.type).is_date_v2_type()) {
vectorized::DateV2Value<doris::vectorized::DateV2ValueType> dt;
DateV2Value<DateV2ValueType> dt;
if (!dt.from_date_str(t_expr.date_literal.value.c_str(),
t_expr.date_literal.value.size())) {
std::stringstream ss;
Expand All @@ -498,7 +498,7 @@ Status VOlapTablePartitionParam::_create_partition_key(const TExprNode& t_expr,
}
column->insert_data(reinterpret_cast<const char*>(&dt), 0);
} else if (TypeDescriptor::from_thrift(t_expr.type).is_datetime_v2_type()) {
vectorized::DateV2Value<doris::vectorized::DateTimeV2ValueType> dt;
DateV2Value<DateTimeV2ValueType> dt;
if (!dt.from_date_str(t_expr.date_literal.value.c_str(),
t_expr.date_literal.value.size())) {
std::stringstream ss;
Expand All @@ -507,7 +507,7 @@ Status VOlapTablePartitionParam::_create_partition_key(const TExprNode& t_expr,
}
column->insert_data(reinterpret_cast<const char*>(&dt), 0);
} else {
vectorized::VecDateTimeValue dt;
VecDateTimeValue dt;
if (!dt.from_date_str(t_expr.date_literal.value.c_str(),
t_expr.date_literal.value.size())) {
std::stringstream ss;
Expand Down
8 changes: 4 additions & 4 deletions be/src/exec/text_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool TextConverter::_write_data(const TypeDescriptor& type_desc,
break;
}
case TYPE_DATE: {
vectorized::VecDateTimeValue ts_slot;
VecDateTimeValue ts_slot;
if (!ts_slot.from_date_str(data, len)) {
parse_result = StringParser::PARSE_FAILURE;
break;
Expand All @@ -205,7 +205,7 @@ bool TextConverter::_write_data(const TypeDescriptor& type_desc,
break;
}
case TYPE_DATEV2: {
vectorized::DateV2Value<vectorized::DateV2ValueType> ts_slot;
DateV2Value<DateV2ValueType> ts_slot;
if (!ts_slot.from_date_str(data, len)) {
parse_result = StringParser::PARSE_FAILURE;
break;
Expand All @@ -217,7 +217,7 @@ bool TextConverter::_write_data(const TypeDescriptor& type_desc,
break;
}
case TYPE_DATETIME: {
vectorized::VecDateTimeValue ts_slot;
VecDateTimeValue ts_slot;
if (!ts_slot.from_date_str(data, len)) {
parse_result = StringParser::PARSE_FAILURE;
break;
Expand All @@ -229,7 +229,7 @@ bool TextConverter::_write_data(const TypeDescriptor& type_desc,
break;
}
case TYPE_DATETIMEV2: {
vectorized::DateV2Value<vectorized::DateTimeV2ValueType> ts_slot;
DateV2Value<DateTimeV2ValueType> ts_slot;
if (!ts_slot.from_date_str(data, len)) {
parse_result = StringParser::PARSE_FAILURE;
break;
Expand Down
12 changes: 6 additions & 6 deletions be/src/exprs/bloom_filter_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,26 +416,26 @@ struct FixedStringFindOp : public StringFindOp {
}
};

struct DateTimeFindOp : public CommonFindOp<vectorized::VecDateTimeValue> {
struct DateTimeFindOp : public CommonFindOp<VecDateTimeValue> {
bool find_olap_engine(const BloomFilterAdaptor& bloom_filter, const void* data) const {
vectorized::VecDateTimeValue value;
VecDateTimeValue value;
value.from_olap_datetime(*reinterpret_cast<const uint64_t*>(data));
return bloom_filter.test(Slice((char*)&value, sizeof(vectorized::VecDateTimeValue)));
return bloom_filter.test(Slice((char*)&value, sizeof(VecDateTimeValue)));
}
};

// avoid violating C/C++ aliasing rules.
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101684

struct DateFindOp : public CommonFindOp<vectorized::VecDateTimeValue> {
struct DateFindOp : public CommonFindOp<VecDateTimeValue> {
bool find_olap_engine(const BloomFilterAdaptor& bloom_filter, const void* data) const {
uint24_t date = *static_cast<const uint24_t*>(data);
uint64_t value = uint32_t(date);

vectorized::VecDateTimeValue date_value;
VecDateTimeValue date_value;
date_value.from_olap_date(value);

return bloom_filter.test(Slice((char*)&date_value, sizeof(vectorized::VecDateTimeValue)));
return bloom_filter.test(Slice((char*)&date_value, sizeof(VecDateTimeValue)));
}
};

Expand Down
33 changes: 15 additions & 18 deletions be/src/exprs/runtime_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ class RuntimePredicateWrapper {
batch_assign(in_filter, [](std::shared_ptr<HybridSetBase>& set, PColumnValue& column,
ObjectPool* pool) {
auto& string_val_ref = column.stringval();
vectorized::VecDateTimeValue datetime_val;
VecDateTimeValue datetime_val;
datetime_val.from_date_str(string_val_ref.c_str(), string_val_ref.length());
set->insert(&datetime_val);
});
Expand Down Expand Up @@ -888,8 +888,8 @@ class RuntimePredicateWrapper {
case TYPE_DATE: {
auto& min_val_ref = minmax_filter->min_val().stringval();
auto& max_val_ref = minmax_filter->max_val().stringval();
vectorized::VecDateTimeValue min_val;
vectorized::VecDateTimeValue max_val;
VecDateTimeValue min_val;
VecDateTimeValue max_val;
min_val.from_date_str(min_val_ref.c_str(), min_val_ref.length());
max_val.from_date_str(max_val_ref.c_str(), max_val_ref.length());
return _context.minmax_func->assign(&min_val, &max_val);
Expand Down Expand Up @@ -1529,31 +1529,28 @@ void IRuntimeFilter::to_protobuf(PInFilter* filter) {
return;
}
case TYPE_DATEV2: {
batch_copy<vectorized::DateV2Value<vectorized::DateV2ValueType>>(
filter, it,
[](PColumnValue* column,
const vectorized::DateV2Value<vectorized::DateV2ValueType>* value) {
batch_copy<DateV2Value<DateV2ValueType>>(
filter, it, [](PColumnValue* column, const DateV2Value<DateV2ValueType>* value) {
column->set_intval(*reinterpret_cast<const int32_t*>(value));
});
return;
}
case TYPE_DATETIMEV2: {
batch_copy<vectorized::DateV2Value<vectorized::DateTimeV2ValueType>>(
batch_copy<DateV2Value<DateTimeV2ValueType>>(
filter, it,
[](PColumnValue* column,
const vectorized::DateV2Value<vectorized::DateTimeV2ValueType>* value) {
[](PColumnValue* column, const DateV2Value<DateTimeV2ValueType>* value) {
column->set_longval(*reinterpret_cast<const int64_t*>(value));
});
return;
}
case TYPE_DATE:
case TYPE_DATETIME: {
batch_copy<vectorized::VecDateTimeValue>(
filter, it, [](PColumnValue* column, const vectorized::VecDateTimeValue* value) {
char convert_buffer[30];
value->to_string(convert_buffer);
column->set_stringval(convert_buffer);
});
batch_copy<VecDateTimeValue>(filter, it,
[](PColumnValue* column, const VecDateTimeValue* value) {
char convert_buffer[30];
value->to_string(convert_buffer);
column->set_stringval(convert_buffer);
});
return;
}
case TYPE_DECIMALV2: {
Expand Down Expand Up @@ -1659,9 +1656,9 @@ void IRuntimeFilter::to_protobuf(PMinMaxFilter* filter) {
case TYPE_DATE:
case TYPE_DATETIME: {
char convert_buffer[30];
reinterpret_cast<const vectorized::VecDateTimeValue*>(min_data)->to_string(convert_buffer);
reinterpret_cast<const VecDateTimeValue*>(min_data)->to_string(convert_buffer);
filter->mutable_min_val()->set_stringval(convert_buffer);
reinterpret_cast<const vectorized::VecDateTimeValue*>(max_data)->to_string(convert_buffer);
reinterpret_cast<const VecDateTimeValue*>(max_data)->to_string(convert_buffer);
filter->mutable_max_val()->set_stringval(convert_buffer);
return;
}
Expand Down
1 change: 0 additions & 1 deletion be/src/exprs/runtime_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <vector>

#include "common/status.h"
#include "runtime/datetime_value.h"
#include "runtime/decimalv2_value.h"
#include "runtime/define_primitive_type.h"
#include "runtime/large_int_value.h"
Expand Down
6 changes: 2 additions & 4 deletions be/src/olap/in_list_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,15 @@ class InListPredicateBase : public ColumnPredicate {
} else if constexpr (Type == TYPE_DATE) {
HybridSetBase::IteratorBase* iter = hybrid_set->begin();
while (iter->has_next()) {
const vectorized::VecDateTimeValue* value =
(const vectorized::VecDateTimeValue*)(iter->get_value());
const VecDateTimeValue* value = (const VecDateTimeValue*)(iter->get_value());
uint64_t date = value->to_olap_date();
_values->insert(&date);
iter->next();
}
} else if constexpr (Type == TYPE_DATETIME) {
HybridSetBase::IteratorBase* iter = hybrid_set->begin();
while (iter->has_next()) {
const vectorized::VecDateTimeValue* value =
(const vectorized::VecDateTimeValue*)(iter->get_value());
const VecDateTimeValue* value = (const VecDateTimeValue*)(iter->get_value());
uint64_t date_time = value->to_olap_datetime();
_values->insert(&date_time);
iter->next();
Expand Down
8 changes: 4 additions & 4 deletions be/src/olap/rowset/segment_v2/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,11 +1377,11 @@ void DefaultValueColumnIterator::insert_default_data(const TypeInfo* type_info,
sizeof(FieldTypeTraits<FieldType::OLAP_FIELD_TYPE_DATE>::CppType)); //uint24_t
std::string str = FieldTypeTraits<FieldType::OLAP_FIELD_TYPE_DATE>::to_string(mem_value);

vectorized::VecDateTimeValue value;
VecDateTimeValue value;
value.from_date_str(str.c_str(), str.length());
value.cast_to_date();

int64 = binary_cast<vectorized::VecDateTimeValue, vectorized::Int64>(value);
int64 = binary_cast<VecDateTimeValue, vectorized::Int64>(value);
dst->insert_many_data(data_ptr, data_len, n);
break;
}
Expand All @@ -1395,11 +1395,11 @@ void DefaultValueColumnIterator::insert_default_data(const TypeInfo* type_info,
std::string str =
FieldTypeTraits<FieldType::OLAP_FIELD_TYPE_DATETIME>::to_string(mem_value);

vectorized::VecDateTimeValue value;
VecDateTimeValue value;
value.from_date_str(str.c_str(), str.length());
value.to_datetime();

int64 = binary_cast<vectorized::VecDateTimeValue, vectorized::Int64>(value);
int64 = binary_cast<VecDateTimeValue, vectorized::Int64>(value);
dst->insert_many_data(data_ptr, data_len, n);
break;
}
Expand Down
Loading

0 comments on commit 642c149

Please sign in to comment.