This is an automated email from the ASF dual-hosted git repository.

lihaopeng 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 8d0b7f17e87 [Refactor](exec) remove the unless file and refactor the 
agg code (#38193)
8d0b7f17e87 is described below

commit 8d0b7f17e876d985a8da078ad9f9d3ff380f7a30
Author: HappenLee <[email protected]>
AuthorDate: Wed Jul 24 20:53:02 2024 +0800

    [Refactor](exec) remove the unless file and refactor the agg code (#38193)
    
    1. delete the file:be/src/vec/utils/count_by_enum_helpers.hpp
    2. move code
    to:be/src/vec/aggregate_functions/aggregate_function_count_by_enum.h
---
 .../aggregate_function_count_by_enum.h             | 45 +++++++++++++--
 be/src/vec/utils/count_by_enum_helpers.hpp         | 67 ----------------------
 2 files changed, 41 insertions(+), 71 deletions(-)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_count_by_enum.h 
b/be/src/vec/aggregate_functions/aggregate_function_count_by_enum.h
index 93a5103ef59..5d4a3dde355 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_count_by_enum.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_count_by_enum.h
@@ -14,13 +14,15 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
-// This file is copied from
-// 
https://github.com/ClickHouse/ClickHouse/blob/master/src/AggregateFunctions/AggregateFunctionCount.h
-// and modified by Doris
 
 #pragma once
 
+#include <rapidjson/document.h>
+#include <rapidjson/prettywriter.h>
+#include <rapidjson/stringbuffer.h>
+
 #include <array>
+#include <boost/dynamic_bitset.hpp>
 
 #include "common/logging.h"
 #include "vec/aggregate_functions/aggregate_function.h"
@@ -28,10 +30,45 @@
 #include "vec/common/assert_cast.h"
 #include "vec/data_types/data_type_number.h"
 #include "vec/io/io_helper.h"
-#include "vec/utils/count_by_enum_helpers.hpp"
 
 namespace doris::vectorized {
 
+struct CountByEnumData {
+    std::unordered_map<std::string, uint64_t> cbe;
+    uint64_t not_null = 0;
+    uint64_t null = 0;
+    uint64_t all = 0;
+};
+
+void build_json_from_vec(rapidjson::StringBuffer& buffer,
+                         const std::vector<CountByEnumData>& data_vec) {
+    rapidjson::Document doc;
+    doc.SetArray();
+    rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
+
+    int vec_size_number = data_vec.size();
+    for (int idx = 0; idx < vec_size_number; ++idx) {
+        rapidjson::Value obj(rapidjson::kObjectType);
+
+        rapidjson::Value obj_cbe(rapidjson::kObjectType);
+        std::unordered_map<std::string, uint64_t> unordered_map = 
data_vec[idx].cbe;
+        for (auto it : unordered_map) {
+            rapidjson::Value key_cbe(it.first.c_str(), allocator);
+            rapidjson::Value value_cbe(it.second);
+            obj_cbe.AddMember(key_cbe, value_cbe, allocator);
+        }
+        obj.AddMember("cbe", obj_cbe, allocator);
+        obj.AddMember("notnull", data_vec[idx].not_null, allocator);
+        obj.AddMember("null", data_vec[idx].null, allocator);
+        obj.AddMember("all", data_vec[idx].all, allocator);
+
+        doc.PushBack(obj, allocator);
+    }
+
+    rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
+    doc.Accept(writer);
+}
+
 struct AggregateFunctionCountByEnumData {
     using MapType = std::unordered_map<std::string, uint64_t>;
 
diff --git a/be/src/vec/utils/count_by_enum_helpers.hpp 
b/be/src/vec/utils/count_by_enum_helpers.hpp
deleted file mode 100644
index 20c38b765bc..00000000000
--- a/be/src/vec/utils/count_by_enum_helpers.hpp
+++ /dev/null
@@ -1,67 +0,0 @@
-// 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 <rapidjson/document.h>
-#include <rapidjson/prettywriter.h>
-#include <rapidjson/stringbuffer.h>
-
-#include <boost/dynamic_bitset.hpp>
-
-#include "vec/data_types/data_type_decimal.h"
-#include "vec/io/io_helper.h"
-
-namespace doris::vectorized {
-
-struct CountByEnumData {
-    std::unordered_map<std::string, uint64_t> cbe;
-    uint64_t not_null;
-    uint64_t null;
-    uint64_t all;
-};
-
-void build_json_from_vec(rapidjson::StringBuffer& buffer,
-                         const std::vector<CountByEnumData>& data_vec) {
-    rapidjson::Document doc;
-    doc.SetArray();
-    rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
-
-    int vec_size_number = data_vec.size();
-    for (int idx = 0; idx < vec_size_number; ++idx) {
-        rapidjson::Value obj(rapidjson::kObjectType);
-
-        rapidjson::Value obj_cbe(rapidjson::kObjectType);
-        std::unordered_map<std::string, uint64_t> unordered_map = 
data_vec[idx].cbe;
-        for (auto it : unordered_map) {
-            rapidjson::Value key_cbe(it.first.c_str(), allocator);
-            rapidjson::Value value_cbe(it.second);
-            obj_cbe.AddMember(key_cbe, value_cbe, allocator);
-        }
-        obj.AddMember("cbe", obj_cbe, allocator);
-        obj.AddMember("notnull", data_vec[idx].not_null, allocator);
-        obj.AddMember("null", data_vec[idx].null, allocator);
-        obj.AddMember("all", data_vec[idx].all, allocator);
-
-        doc.PushBack(obj, allocator);
-    }
-
-    rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
-    doc.Accept(writer);
-}
-
-} // namespace  doris::vectorized
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to