You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/12/07 08:17:59 UTC

[GitHub] [doris] weizhengte opened a new pull request, #14885: [feature-wip](Nereids) add aggregate function histogram and collect histogram statistics

weizhengte opened a new pull request, #14885:
URL: https://github.com/apache/doris/pull/14885

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] hello-stephen commented on pull request #14885: [feature-wip](Nereids) add aggregate function histogram and collect histogram statistics

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #14885:
URL: https://github.com/apache/doris/pull/14885#issuecomment-1340788706

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 35.25 seconds
    load time: 450 seconds
    storage size: 17123356956 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221207105815_clickbench_pr_59291.html


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] weizhengte closed pull request #14885: [feature-wip](Nereids) add aggregate function histogram and collect histogram statistics

Posted by GitBox <gi...@apache.org>.
weizhengte closed pull request #14885: [feature-wip](Nereids) add aggregate function histogram and collect histogram statistics
URL: https://github.com/apache/doris/pull/14885


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on a diff in pull request #14885: [feature-wip](Nereids) add aggregate function histogram and collect histogram statistics

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on code in PR #14885:
URL: https://github.com/apache/doris/pull/14885#discussion_r1041894336


##########
be/test/vec/aggregate_functions/agg_histogram_test.cpp:
##########
@@ -0,0 +1,144 @@
+// 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 <gtest/gtest.h>
+
+#include "common/logging.h"
+#include "gtest/gtest.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "vec/aggregate_functions/aggregate_function_histogram.h"
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/columns/column_vector.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "vec/data_types/data_type_decimal.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_string.h"
+
+namespace doris::vectorized {
+
+void register_aggregate_function_histogram(AggregateFunctionSimpleFactory& factory);
+
+class VAggHistogramTest : public testing::Test {
+public:
+    void SetUp() {

Review Comment:
   warning: annotate this function with 'override' or (rarely) 'final' [modernize-use-override]
   
   ```suggestion
       void SetUp() override {
   ```
   



##########
be/test/vec/aggregate_functions/agg_histogram_test.cpp:
##########
@@ -0,0 +1,144 @@
+// 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 <gtest/gtest.h>
+
+#include "common/logging.h"
+#include "gtest/gtest.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "vec/aggregate_functions/aggregate_function_histogram.h"
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/columns/column_vector.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "vec/data_types/data_type_decimal.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_string.h"
+
+namespace doris::vectorized {
+
+void register_aggregate_function_histogram(AggregateFunctionSimpleFactory& factory);
+
+class VAggHistogramTest : public testing::Test {
+public:
+    void SetUp() {
+        AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        register_aggregate_function_histogram(factory);
+    }
+
+    void TearDown() {}

Review Comment:
   warning: annotate this function with 'override' or (rarely) 'final' [modernize-use-override]
   
   ```suggestion
       void TearDown() override {}
   ```
   



##########
be/test/vec/aggregate_functions/agg_histogram_test.cpp:
##########
@@ -0,0 +1,144 @@
+// 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 <gtest/gtest.h>
+
+#include "common/logging.h"
+#include "gtest/gtest.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "vec/aggregate_functions/aggregate_function_histogram.h"
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/columns/column_vector.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "vec/data_types/data_type_decimal.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_string.h"
+
+namespace doris::vectorized {
+
+void register_aggregate_function_histogram(AggregateFunctionSimpleFactory& factory);
+
+class VAggHistogramTest : public testing::Test {
+public:
+    void SetUp() {
+        AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        register_aggregate_function_histogram(factory);
+    }
+
+    void TearDown() {}
+    
+    template <typename DataType>
+    void agg_histogram_add_elements(AggregateFunctionPtr agg_function, AggregateDataPtr place,
+                                  size_t input_nums) {
+        using FieldType = typename DataType::FieldType;
+        auto type = std::make_shared<DataType>();
+        auto input_col = type->create_column();
+        for (size_t i = 0; i < input_nums; ++i) {
+            if constexpr (std::is_same_v<DataType, DataTypeString>) {
+                auto item = std::string("item") + std::to_string(i);
+                input_col->insert_data(item.c_str(), item.size());
+            } else {
+                auto item = FieldType(i);
+                input_col->insert_data(reinterpret_cast<const char*>(&item), 0);
+            }
+        }
+        EXPECT_EQ(input_col->size(), input_nums);
+
+        const IColumn* column[1] = {input_col.get()};
+        for (int i = 0; i < input_col->size(); i++) {
+            agg_function->add(place, column, i, &_agg_arena_pool);
+        }
+    }
+
+    template <typename DataType>
+    void test_agg_histogram(const std::string& fn_name, size_t input_nums = 0) {
+        DataTypes data_types = {(DataTypePtr)std::make_shared<DataType>()};
+        LOG(INFO) << "test_agg_histogram for " << fn_name << "(" << data_types[0]->get_name() << ")";
+        Array array;
+        AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        auto agg_function = factory.get(fn_name, data_types, array);
+        EXPECT_NE(agg_function, nullptr);
+
+        std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
+        AggregateDataPtr place = memory.get();
+        agg_function->create(place);
+
+        agg_histogram_add_elements<DataType>(agg_function, place, input_nums);
+
+        ColumnString buf;
+        VectorBufferWriter buf_writer(buf);
+        agg_function->serialize(place, buf_writer);
+        buf_writer.commit();
+        VectorBufferReader buf_reader(buf.get_data_at(0));
+        agg_function->deserialize(place, buf_reader, &_agg_arena_pool);
+
+        std::unique_ptr<char[]> memory2(new char[agg_function->size_of_data()]);
+        AggregateDataPtr place2 = memory2.get();
+        agg_function->create(place2);
+
+        agg_histogram_add_elements<DataType>(agg_function, place2, input_nums);
+
+        agg_function->merge(place, place2, &_agg_arena_pool);
+        auto column_result = ColumnArray::create(data_types[0]->create_column());

Review Comment:
   warning: use of undeclared identifier 'ColumnArray' [clang-diagnostic-error]
   ```cpp
           auto column_result = ColumnArray::create(data_types[0]->create_column());
                                ^
   ```
   



##########
be/test/vec/aggregate_functions/agg_histogram_test.cpp:
##########
@@ -0,0 +1,144 @@
+// 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 <gtest/gtest.h>
+
+#include "common/logging.h"
+#include "gtest/gtest.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "vec/aggregate_functions/aggregate_function_histogram.h"
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/columns/column_vector.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "vec/data_types/data_type_decimal.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_string.h"
+
+namespace doris::vectorized {
+
+void register_aggregate_function_histogram(AggregateFunctionSimpleFactory& factory);
+
+class VAggHistogramTest : public testing::Test {
+public:
+    void SetUp() {
+        AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        register_aggregate_function_histogram(factory);
+    }
+
+    void TearDown() {}
+    
+    template <typename DataType>
+    void agg_histogram_add_elements(AggregateFunctionPtr agg_function, AggregateDataPtr place,
+                                  size_t input_nums) {
+        using FieldType = typename DataType::FieldType;
+        auto type = std::make_shared<DataType>();
+        auto input_col = type->create_column();
+        for (size_t i = 0; i < input_nums; ++i) {
+            if constexpr (std::is_same_v<DataType, DataTypeString>) {
+                auto item = std::string("item") + std::to_string(i);
+                input_col->insert_data(item.c_str(), item.size());
+            } else {
+                auto item = FieldType(i);
+                input_col->insert_data(reinterpret_cast<const char*>(&item), 0);
+            }
+        }
+        EXPECT_EQ(input_col->size(), input_nums);
+
+        const IColumn* column[1] = {input_col.get()};
+        for (int i = 0; i < input_col->size(); i++) {
+            agg_function->add(place, column, i, &_agg_arena_pool);
+        }
+    }
+
+    template <typename DataType>
+    void test_agg_histogram(const std::string& fn_name, size_t input_nums = 0) {
+        DataTypes data_types = {(DataTypePtr)std::make_shared<DataType>()};
+        LOG(INFO) << "test_agg_histogram for " << fn_name << "(" << data_types[0]->get_name() << ")";
+        Array array;
+        AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        auto agg_function = factory.get(fn_name, data_types, array);
+        EXPECT_NE(agg_function, nullptr);
+
+        std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
+        AggregateDataPtr place = memory.get();
+        agg_function->create(place);
+
+        agg_histogram_add_elements<DataType>(agg_function, place, input_nums);
+
+        ColumnString buf;

Review Comment:
   warning: calling a private constructor of class 'doris::vectorized::ColumnString' [clang-diagnostic-error]
   ```cpp
           ColumnString buf;
                        ^
   ```
   **be/src/vec/columns/column_string.h:65:** declared private here
   ```cpp
       ColumnString() = default;
       ^
   ```
   



##########
be/test/vec/aggregate_functions/agg_histogram_test.cpp:
##########
@@ -0,0 +1,144 @@
+// 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 <gtest/gtest.h>
+
+#include "common/logging.h"
+#include "gtest/gtest.h"
+#include "vec/aggregate_functions/aggregate_function.h"
+#include "vec/aggregate_functions/aggregate_function_histogram.h"
+#include "vec/aggregate_functions/aggregate_function_simple_factory.h"
+#include "vec/columns/column_vector.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/data_type_date.h"
+#include "vec/data_types/data_type_date_time.h"
+#include "vec/data_types/data_type_decimal.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/data_types/data_type_string.h"
+
+namespace doris::vectorized {
+
+void register_aggregate_function_histogram(AggregateFunctionSimpleFactory& factory);
+
+class VAggHistogramTest : public testing::Test {
+public:
+    void SetUp() {
+        AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        register_aggregate_function_histogram(factory);
+    }
+
+    void TearDown() {}
+    
+    template <typename DataType>
+    void agg_histogram_add_elements(AggregateFunctionPtr agg_function, AggregateDataPtr place,
+                                  size_t input_nums) {
+        using FieldType = typename DataType::FieldType;
+        auto type = std::make_shared<DataType>();
+        auto input_col = type->create_column();
+        for (size_t i = 0; i < input_nums; ++i) {
+            if constexpr (std::is_same_v<DataType, DataTypeString>) {
+                auto item = std::string("item") + std::to_string(i);
+                input_col->insert_data(item.c_str(), item.size());
+            } else {
+                auto item = FieldType(i);
+                input_col->insert_data(reinterpret_cast<const char*>(&item), 0);
+            }
+        }
+        EXPECT_EQ(input_col->size(), input_nums);
+
+        const IColumn* column[1] = {input_col.get()};
+        for (int i = 0; i < input_col->size(); i++) {
+            agg_function->add(place, column, i, &_agg_arena_pool);
+        }
+    }
+
+    template <typename DataType>
+    void test_agg_histogram(const std::string& fn_name, size_t input_nums = 0) {
+        DataTypes data_types = {(DataTypePtr)std::make_shared<DataType>()};
+        LOG(INFO) << "test_agg_histogram for " << fn_name << "(" << data_types[0]->get_name() << ")";
+        Array array;
+        AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance();
+        auto agg_function = factory.get(fn_name, data_types, array);
+        EXPECT_NE(agg_function, nullptr);
+
+        std::unique_ptr<char[]> memory(new char[agg_function->size_of_data()]);
+        AggregateDataPtr place = memory.get();
+        agg_function->create(place);
+
+        agg_histogram_add_elements<DataType>(agg_function, place, input_nums);
+
+        ColumnString buf;
+        VectorBufferWriter buf_writer(buf);
+        agg_function->serialize(place, buf_writer);
+        buf_writer.commit();
+        VectorBufferReader buf_reader(buf.get_data_at(0));
+        agg_function->deserialize(place, buf_reader, &_agg_arena_pool);
+
+        std::unique_ptr<char[]> memory2(new char[agg_function->size_of_data()]);
+        AggregateDataPtr place2 = memory2.get();
+        agg_function->create(place2);
+
+        agg_histogram_add_elements<DataType>(agg_function, place2, input_nums);
+
+        agg_function->merge(place, place2, &_agg_arena_pool);
+        auto column_result = ColumnArray::create(data_types[0]->create_column());
+        agg_function->insert_result_into(place, *column_result);
+        EXPECT_EQ(column_result->size(), 1);
+        EXPECT_TRUE(column_result->get_offsets()[0] >= 1);
+
+        auto column_result2 = ColumnArray::create(data_types[0]->create_column());

Review Comment:
   warning: use of undeclared identifier 'ColumnArray' [clang-diagnostic-error]
   ```cpp
           auto column_result2 = ColumnArray::create(data_types[0]->create_column());
                                 ^
   ```
   



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #14885: [feature-wip](Nereids) add aggregate function histogram and collect histogram statistics

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14885:
URL: https://github.com/apache/doris/pull/14885#issuecomment-1340831825

   clang-tidy review says "All clean, LGTM! :+1:"


-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org