HappenLee commented on code in PR #33595:
URL: https://github.com/apache/doris/pull/33595#discussion_r1568391805


##########
be/src/vec/exprs/table_function/udf_table_function.h:
##########
@@ -0,0 +1,110 @@
+// 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 <stddef.h>
+#include <stdint.h>
+
+#include <string_view>
+#include <vector>
+
+#include "common/status.h"
+#include "jni.h"
+#include "util/jni-util.h"
+#include "vec/columns/column.h"
+#include "vec/common/string_ref.h"
+#include "vec/data_types/data_type.h"
+#include "vec/exprs/table_function/table_function.h"
+#include "vec/functions/array/function_array_utils.h"
+namespace doris {
+namespace vectorized {
+class Block;
+class ColumnString;
+} // namespace vectorized
+} // namespace doris
+
+namespace doris::vectorized {
+
+class UDFTableFunction final : public TableFunction {
+    ENABLE_FACTORY_CREATOR(UDFTableFunction);
+
+public:
+    UDFTableFunction(const TFunction& t_fn);
+    ~UDFTableFunction() override = default;
+
+    Status open() override;
+    Status process_init(Block* block, RuntimeState* state) override;
+    void process_row(size_t row_idx) override;
+    void process_close() override;
+    void get_value(MutableColumnPtr& column) override;
+    Status close() override {
+        if (_jni_ctx) {
+            RETURN_IF_ERROR(_jni_ctx->close());
+        }
+        return TableFunction::close();
+    }
+
+private:
+    struct JniContext {
+        // Do not save parent directly, because parent is in VExpr, but jni 
context is in FunctionContext
+        // The deconstruct sequence is not determined, it will core.
+        // JniContext's lifecycle should same with function context, not 
related with expr
+        jclass executor_cl;
+        jmethodID executor_ctor_id;
+        jmethodID executor_evaluate_id;
+        jmethodID executor_close_id;
+        jobject executor = nullptr;
+        bool is_closed = false;
+        bool open_successes = false;
+
+        JniContext() = default;
+
+        Status close() {
+            if (!open_successes) {
+                LOG_WARNING("maybe open failed, need check the reason");

Review Comment:
   LOG the function name



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