github-actions[bot] commented on code in PR #16562: URL: https://github.com/apache/doris/pull/16562#discussion_r1101140301
########## be/src/vec/data_types/data_type_quantilestate.h: ########## @@ -0,0 +1,85 @@ +// 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. + +#pragma once +#include "util/quantile_state.h" +#include "vec/columns/column.h" +#include "vec/columns/column_complex.h" +#include "vec/core/types.h" +#include "vec/data_types/data_type.h" +namespace doris::vectorized { +template<typename T> +class DataTypeQuantileState : public IDataType { +public: + DataTypeQuantileState() = default; + ~DataTypeQuantileState() override = default; + using ColumnType = ColumnQuantileState<T>; + using FieldType = QuantileState<T>; + + std::string do_get_name() const override { return get_family_name(); } + const char* get_family_name() const override { return "QuantileState"; } + + TypeIndex get_type_id() const override { return TypeIndex::QuantileState; } + int64_t get_uncompressed_serialized_bytes(const IColumn& column, + int be_exec_version) const override; + char* serialize(const IColumn& column, char* buf, int be_exec_version) const override; + const char* deserialize(const char* buf, IColumn* column, int be_exec_version) const override; + + MutableColumnPtr create_column() const override; + + bool get_is_parametric() const override { return false; } + bool have_subtypes() const override { return false; } + bool should_align_right_in_pretty_formats() const override { return false; } + bool text_can_contain_only_valid_utf8() const override { return true; } + bool is_comparable() const override { return false; } + bool is_value_represented_by_number() const override { return false; } + bool is_value_represented_by_integer() const override { return false; } + bool is_value_represented_by_unsigned_integer() const override { return false; } + // TODO: + bool is_value_unambiguously_represented_in_contiguous_memory_region() const override { + return true; + } + bool have_maximum_size_of_value() const override { return false; } + + bool can_be_used_as_version() const override { return false; } + + bool can_be_inside_nullable() const override { return true; } + + bool equals(const IDataType& rhs) const override { return typeid(rhs) == typeid(*this); } + + bool is_categorial() const override { return is_value_represented_by_integer(); } + + bool can_be_inside_low_cardinality() const override { return false; } + + std::string to_string(const IColumn& column, size_t row_num) const override { + return "QuantileState()"; + } + void to_string(const IColumn& column, size_t row_num, BufferWritable& ostr) const override; + + [[noreturn]] virtual Field get_default() const override { Review Comment: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override] ```suggestion [[noreturn]] Field get_default() const override { ``` ########## be/test/vec/core/column_complex_test.cpp: ########## @@ -83,7 +84,42 @@ class ColumnBitmapTest : public testing::Test { DataTypeBitMap _bitmap_type; }; -TEST_F(ColumnBitmapTest, SerializeAndDeserialize) { +class ColumnQuantileStateTest : public testing::Test { +public: + virtual void SetUp() override {} Review Comment: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override] ```suggestion void SetUp() override {} ``` ########## be/test/vec/core/column_complex_test.cpp: ########## @@ -106,4 +142,31 @@ check_serialize_and_deserialize(column); } +TEST_F(ColumnQuantileStateTest, ColumnQuantileStateReadWrite) { + auto column = _quantile_state_type.create_column(); Review Comment: warning: '_quantile_state_type' is a private member of 'doris::vectorized::ColumnQuantileStateTest' [clang-diagnostic-error] ```cpp auto column = _quantile_state_type.create_column(); ^ ``` **be/test/vec/core/column_complex_test.cpp:118:** declared private here ```cpp DataTypeQuantileStateDouble _quantile_state_type; ^ ``` ########## be/test/vec/core/column_complex_test.cpp: ########## @@ -83,7 +84,42 @@ DataTypeBitMap _bitmap_type; }; -TEST_F(ColumnBitmapTest, SerializeAndDeserialize) { +class ColumnQuantileStateTest : public testing::Test { +public: + virtual void SetUp() override {} + virtual void TearDown() override {} + + void check_bitmap_column(const IColumn& l, const IColumn& r) { + ASSERT_EQ(l.size(), r.size()); + const auto& l_col = assert_cast<const ColumnQuantileStateDouble&>(l); + const auto& r_col = assert_cast<const ColumnQuantileStateDouble&>(r); + for (size_t i = 0; i < l_col.size(); ++i) { + auto& l_value = const_cast<QuantileStateDouble&>(l_col.get_element(i)); + auto& r_value = const_cast<QuantileStateDouble&>(r_col.get_element(i)); + ASSERT_EQ(l_value.get_serialized_size(), r_value.get_serialized_size()); + } + } + + void check_serialize_and_deserialize(MutableColumnPtr& col) { + auto column = assert_cast<ColumnQuantileStateDouble*>(col.get()); + auto size = _quantile_state_type.get_uncompressed_serialized_bytes( + *column, BeExecVersionManager::get_newest_version()); + std::unique_ptr<char[]> buf = std::make_unique<char[]>(size); + auto result = _quantile_state_type.serialize(*column, buf.get(), + BeExecVersionManager::get_newest_version()); + ASSERT_EQ(result, buf.get() + size); + + auto column2 = _quantile_state_type.create_column(); + _quantile_state_type.deserialize(buf.get(), column2.get(), + BeExecVersionManager::get_newest_version()); + check_bitmap_column(*column, *column2.get()); + } + +private: + DataTypeQuantileStateDouble _quantile_state_type; +}; + +TEST_F(ColumnBitmapTest, ColumnBitmapReadWrite) { auto column = _bitmap_type.create_column(); Review Comment: warning: '_bitmap_type' is a private member of 'doris::vectorized::ColumnBitmapTest' [clang-diagnostic-error] ```cpp auto column = _bitmap_type.create_column(); ^ ``` **be/test/vec/core/column_complex_test.cpp:83:** declared private here ```cpp DataTypeBitMap _bitmap_type; ^ ``` ########## be/test/vec/core/column_complex_test.cpp: ########## @@ -83,7 +84,42 @@ DataTypeBitMap _bitmap_type; }; -TEST_F(ColumnBitmapTest, SerializeAndDeserialize) { +class ColumnQuantileStateTest : public testing::Test { +public: + virtual void SetUp() override {} + virtual void TearDown() override {} Review Comment: warning: 'virtual' is redundant since the function is already declared 'override' [modernize-use-override] ```suggestion void TearDown() override {} ``` -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org