diff --git a/be/src/vec/aggregate_functions/aggregate_function_sequence_match.h b/be/src/vec/aggregate_functions/aggregate_function_sequence_match.h index 6bfe8558750649..7e2e54b879e849 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_sequence_match.h +++ b/be/src/vec/aggregate_functions/aggregate_function_sequence_match.h @@ -123,7 +123,8 @@ struct AggregateFunctionSequenceMatchData final { void merge(const AggregateFunctionSequenceMatchData& other) { if (other.events_list.empty()) return; - events_list.insert(std::begin(other.events_list), std::end(other.events_list)); + events_list.insert(std::end(events_list), std::begin(other.events_list), + std::end(other.events_list)); sorted = false; conditions_met |= other.conditions_met; } @@ -570,7 +571,7 @@ struct AggregateFunctionSequenceMatchData final { public: bool sorted = true; - PODArrayWithStackMemory events_list; + std::vector events_list; // sequenceMatch conditions met at least once in events_list std::bitset conditions_met; // sequenceMatch conditions met at least once in the pattern diff --git a/be/src/vec/aggregate_functions/aggregate_function_window_funnel.h b/be/src/vec/aggregate_functions/aggregate_function_window_funnel.h index 7dbef1a17fb3ea..d01803a080333b 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_window_funnel.h +++ b/be/src/vec/aggregate_functions/aggregate_function_window_funnel.h @@ -160,7 +160,6 @@ struct WindowFunnelState { template int _match_event_list(size_t& start_row, size_t row_count) const { int matched_count = 0; - DateValueType start_timestamp; DateValueType end_timestamp; if (window < 0) { diff --git a/be/src/vec/common/pod_array.h b/be/src/vec/common/pod_array.h index 3ac657de2d5097..85ed92bcf16b95 100644 --- a/be/src/vec/common/pod_array.h +++ b/be/src/vec/common/pod_array.h @@ -408,6 +408,11 @@ class PODArray : public PODArrayBase; + static_assert(std::is_trivially_destructible_v, + "PODArray can only be used with POD types or types with trivial destructor"); + static_assert(std::is_trivially_copyable_v, + "PODArray can only be used with POD types or types with trivial copy"); + T* t_start() { return reinterpret_cast(this->c_start); } T* t_end() { return reinterpret_cast(this->c_end); } diff --git a/be/src/vec/core/types.h b/be/src/vec/core/types.h index ef3c838ed6e8b5..f87fcf6549eea5 100644 --- a/be/src/vec/core/types.h +++ b/be/src/vec/core/types.h @@ -481,6 +481,12 @@ using Decimal64 = Decimal; using Decimal128V2 = Decimal; using Decimal256 = Decimal; +static_assert(std::is_trivial_v, "Decimal32 must be trivial"); +static_assert(std::is_trivial_v, "Decimal64 must be trivial"); +static_assert(std::is_trivial_v, "Decimal128V2 must be trivial"); +static_assert(std::is_trivial_v, "Decimal128V3 must be trivial"); +static_assert(std::is_trivial_v, "Decimal256 must be trivial"); + inline bool operator<(const Decimal256& x, const Decimal256& y) { return x.value < y.value; } diff --git a/be/src/vec/runtime/timestamptz_value.cpp b/be/src/vec/runtime/timestamptz_value.cpp index 90d7d288a46f02..0d69cd8c1971c9 100644 --- a/be/src/vec/runtime/timestamptz_value.cpp +++ b/be/src/vec/runtime/timestamptz_value.cpp @@ -101,8 +101,6 @@ bool TimestampTzValue::from_datetime(const DateV2Value& ori auto utc_cs = cctz::convert(local_tp, cctz::utc_time_zone()); - DateV2Value utc_dt; - return _utc_dt.check_range_and_set_time((uint16_t)utc_cs.year(), (uint8_t)utc_cs.month(), (uint8_t)utc_cs.day(), (uint8_t)utc_cs.hour(), (uint8_t)utc_cs.minute(), (uint8_t)utc_cs.second(), diff --git a/be/src/vec/runtime/vdatetime_value.h b/be/src/vec/runtime/vdatetime_value.h index b8fe4067fd3c83..30a70926e39197 100644 --- a/be/src/vec/runtime/vdatetime_value.h +++ b/be/src/vec/runtime/vdatetime_value.h @@ -811,6 +811,10 @@ class VecDateTimeValue { // Now this type is a temp solution with little changes _year(year) {} }; +static_assert(std::is_trivially_destructible_v, + "VecDateTimeValue must be trivial destructible"); +static_assert(std::is_trivially_copyable_v, + "VecDateTimeValue must be trivial copyable"); inline const VecDateTimeValue VecDateTimeValue::FIRST_DAY(false, TYPE_DATETIME, 0, 0, 0, 1, 1, 1); inline const VecDateTimeValue VecDateTimeValue::DEFAULT_VALUE(false, TYPE_DATETIME, 0, 0, 0, 1970, 1, 1); @@ -1472,6 +1476,15 @@ class DateV2Value { : date_v2_value_(year, month, day, hour, minute, second, microsecond) {} }; +static_assert(std::is_trivially_destructible_v>, + "DateV2Value must be trivial destructible"); +static_assert(std::is_trivially_destructible_v>, + "DateV2Value must be trivial destructible"); +static_assert(std::is_trivially_copyable_v>, + "DateV2Value must be trivial copyable"); +static_assert(std::is_trivially_copyable_v>, + "DateV2Value must be trivial copyable"); + template inline const DateV2Value DateV2Value::FIRST_DAY = DateV2Value(0001, 1, 1, 0, 0, 0, 0); template diff --git a/be/test/vec/columns/pod_array_type_test.cpp b/be/test/vec/columns/pod_array_type_test.cpp new file mode 100644 index 00000000000000..638b0775e4ddf3 --- /dev/null +++ b/be/test/vec/columns/pod_array_type_test.cpp @@ -0,0 +1,66 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include + +#include "runtime/decimalv2_value.h" +#include "runtime/primitive_type.h" +#include "testutil/column_helper.h" +#include "vec/columns/column.h" +#include "vec/columns/column_array.h" +#include "vec/columns/column_const.h" +#include "vec/data_types/data_type_number.h" +#include "vec/functions/function.h" +#include "vec/runtime/vdatetime_value.h" + +namespace doris::vectorized { + +template +void test_for_type() { + PaddedPODArray arr; + for (int i = 0; i < 100; ++i) { + arr.push_back(T {}); + } + arr.resize(1000); + for (int i = 0; i < 100; ++i) { + EXPECT_EQ(T {}, arr[i]); + } +} + +TEST(PodArrayTypeTest, test) { + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type>(); + test_for_type>(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); + test_for_type(); +} + +} // namespace doris::vectorized \ No newline at end of file