github-actions[bot] commented on code in PR #24504:
URL: https://github.com/apache/doris/pull/24504#discussion_r1451671410


##########
be/src/vec/functions/function_wasm.cpp:
##########
@@ -0,0 +1,199 @@
+// 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 "vec/functions/function_wasm.h"
+
+#include <brpc/controller.h>
+#include <fmt/format.h>
+
+#include <algorithm>
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "gutil/strings/substitute.h"
+#include "runtime/exec_env.h"
+#include "runtime/user_function_cache.h"
+#include "vec/columns/column.h"
+#include "vec/data_types/data_type.h"
+#include "vec/data_types/serde/data_type_serde.h"
+#include "vec/functions/function.h"
+
+namespace doris::vectorized {
+
+FunctionWasm::FunctionWasm(const TFunction& fn, const DataTypes& 
argument_types,
+                           const DataTypePtr& return_type)
+        : _argument_types(argument_types), _return_type(return_type), _tfn(fn) 
{
+    _is_nullable = false;
+    for (const auto& type : argument_types) {
+        auto argument_type = type;
+        if (type->is_nullable()) {
+            argument_type = remove_nullable(type);
+            _is_nullable = true;
+        }
+        _not_nullable_argument_types.push_back(argument_type);
+    }
+}
+
+Status FunctionWasm::open(FunctionContext* context, 
FunctionContext::FunctionStateScope scope) {
+    if (scope == FunctionContext::FRAGMENT_LOCAL) {
+        string local_location;
+        auto* function_cache = UserFunctionCache::instance();
+        RETURN_IF_ERROR(function_cache->get_watpath(_tfn.id, 
_tfn.hdfs_location, _tfn.checksum,
+                                                    &local_location));
+        //        ExecEnv::GetInstance()->wasm_function_manager();
+        std::shared_ptr<WasmFunctionManager> manager = 
std::make_shared<WasmFunctionManager>();
+        context->set_function_state(FunctionContext::THREAD_LOCAL, manager);
+        std::ifstream watFile;
+        watFile.open(local_location.c_str());
+        std::stringstream strStream;
+        strStream << watFile.rdbuf();
+        const std::string wasm_body = strStream.str();
+        manager->RegisterFunction(_tfn.name.function_name, 
_tfn.scalar_fn.symbol, wasm_body);
+    }
+    return Status::OK();
+}
+
+Status FunctionWasm::execute(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,

Review Comment:
   warning: function 'execute' exceeds recommended size/complexity thresholds 
[readability-function-size]
   ```cpp
   Status FunctionWasm::execute(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
                        ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/functions/function_wasm.cpp:70:** 125 lines including 
whitespace and comments (threshold 80)
   ```cpp
   Status FunctionWasm::execute(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
                        ^
   ```
   
   </details>
   



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