cambyzju commented on code in PR #10781:
URL: https://github.com/apache/doris/pull/10781#discussion_r918707587


##########
be/src/vec/functions/array/function_array_set.h:
##########
@@ -0,0 +1,258 @@
+// 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 "vec/columns/column_array.h"
+#include "vec/columns/column_string.h"
+#include "vec/common/hash_table/hash_set.h"
+#include "vec/data_types/data_type_array.h"
+#include "vec/data_types/data_type_number.h"
+#include "vec/functions/array/function_array_utils.h"
+#include "vec/functions/function.h"
+#include "vec/functions/function_helpers.h"
+
+namespace doris::vectorized {
+
+enum class SetOperation { UNION, EXCEPT, INTERSECT };
+
+template <typename ColumnType>
+struct UnionAction;
+
+template <typename ColumnType>
+struct ExceptAction;
+
+template <typename ColumnType>
+struct IntersectAction;
+
+template <typename ColumnType, SetOperation operation>
+struct ActionImpl;
+
+template <typename ColumnType>
+struct ActionImpl<ColumnType, SetOperation::UNION> {
+    using Action = UnionAction<ColumnType>;
+    static constexpr auto apply_left_first = true;
+};
+
+template <typename ColumnType>
+struct ActionImpl<ColumnType, SetOperation::EXCEPT> {
+    using Action = ExceptAction<ColumnType>;
+    static constexpr auto apply_left_first = false;
+};
+
+template <typename ColumnType>
+struct ActionImpl<ColumnType, SetOperation::INTERSECT> {
+    using Action = IntersectAction<ColumnType>;
+    static constexpr auto apply_left_first = false;
+};
+
+template <SetOperation operation, typename ColumnType>
+struct OpenSetImpl {
+    using Action = typename ActionImpl<ColumnType, operation>::Action;
+    Action action;
+    void apply_left(const ColumnArrayExecutionData& src, size_t off, size_t 
len,
+                    ColumnArrayMutableData& dst, size_t* count) {
+        const auto& src_data = assert_cast<const 
ColumnType&>(*src.nested_col).get_data();
+        auto& dst_data = assert_cast<ColumnType&>(*dst.nested_col).get_data();
+        for (size_t i = off; i < off + len; ++i) {
+            if (src.nested_nullmap_data && src.nested_nullmap_data[i]) {
+                if (action.apply_null_left()) {
+                    dst_data.push_back(typename ColumnType::value_type());
+                    dst.nested_nullmap_data->push_back(1);
+                    ++(*count);
+                }
+            } else  {
+                if (action.apply_left(&src_data[i])) {
+                    dst_data.push_back(src_data[i]);
+                    if (dst.nested_nullmap_data) {
+                        dst.nested_nullmap_data->push_back(0);
+                    }
+                    ++(*count);
+                }
+            }
+        }
+    }
+
+    void apply_right(const ColumnArrayExecutionData& src, size_t off, size_t 
len,

Review Comment:
   apply_left and apply_right look like the same



-- 
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

Reply via email to