You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "zhangstar333 (via GitHub)" <gi...@apache.org> on 2023/06/30 09:34:11 UTC

[GitHub] [doris] zhangstar333 opened a new pull request, #21388: [refactor](udf) refactor java-udf execute method by using for loop

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

   ## Proposed changes
    refactor java-udf execute method by using for loop,
   and compared to the previous execution method, there is approximately a 20% performance improvement.
   
   Issue Number: close #xxx
   
   <!--Describe your changes.-->
   
   ## 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] github-actions[bot] commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1617118359

   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


[GitHub] [doris] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1621102951

   run p0 feut


-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1617114565

   run buildall


-- 
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 #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1621123649

   PR approved by at least one committer and no changes requested.


-- 
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] Gabriel39 commented on a diff in pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "Gabriel39 (via GitHub)" <gi...@apache.org>.
Gabriel39 commented on code in PR #21388:
URL: https://github.com/apache/doris/pull/21388#discussion_r1251436125


##########
be/src/vec/functions/function_java_udf.cpp:
##########
@@ -130,189 +141,177 @@ Status JavaFunctionCall::execute(FunctionContext* context, Block& block,
             context->get_function_state(FunctionContext::THREAD_LOCAL));
     JniEnv* jni_env =
             reinterpret_cast<JniEnv*>(context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
-    int arg_idx = 0;
-    ColumnPtr data_cols[arguments.size()];
-    ColumnPtr null_cols[arguments.size()];
-    for (size_t col_idx : arguments) {
-        ColumnWithTypeAndName& column = block.get_by_position(col_idx);
+    int arg_size = arguments.size();
+    ColumnPtr data_cols[arg_size];
+    ColumnPtr null_cols[arg_size];
+    jclass obj_class = env->FindClass("[Ljava/lang/Object;");
+    jclass arraylist_class = env->FindClass("Ljava/util/ArrayList;");
+    jobjectArray arg_objects = env->NewObjectArray(arg_size, obj_class, nullptr);
+    int64_t nullmap_address = 0;
+    for (size_t arg_idx = 0; arg_idx < arg_size; ++arg_idx) {
+        bool arg_column_nullable = false;
+        // get argument column and type
+        ColumnWithTypeAndName& column = block.get_by_position(arguments[arg_idx]);
+        auto column_type = column.type;
         data_cols[arg_idx] = column.column->convert_to_full_column_if_const();
-        if (!_argument_types[arg_idx]->equals(*column.type)) {
+
+        // check type
+        if (_argument_types[arg_idx]->equals(*column_type) == false) {

Review Comment:
   Use DCHECK



-- 
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] zhangstar333 commented on a diff in pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on code in PR #21388:
URL: https://github.com/apache/doris/pull/21388#discussion_r1251728240


##########
be/src/vec/functions/function_java_udf.cpp:
##########
@@ -130,189 +141,177 @@ Status JavaFunctionCall::execute(FunctionContext* context, Block& block,
             context->get_function_state(FunctionContext::THREAD_LOCAL));
     JniEnv* jni_env =
             reinterpret_cast<JniEnv*>(context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
-    int arg_idx = 0;
-    ColumnPtr data_cols[arguments.size()];
-    ColumnPtr null_cols[arguments.size()];
-    for (size_t col_idx : arguments) {
-        ColumnWithTypeAndName& column = block.get_by_position(col_idx);
+    int arg_size = arguments.size();
+    ColumnPtr data_cols[arg_size];
+    ColumnPtr null_cols[arg_size];
+    jclass obj_class = env->FindClass("[Ljava/lang/Object;");
+    jclass arraylist_class = env->FindClass("Ljava/util/ArrayList;");
+    jobjectArray arg_objects = env->NewObjectArray(arg_size, obj_class, nullptr);
+    int64_t nullmap_address = 0;
+    for (size_t arg_idx = 0; arg_idx < arg_size; ++arg_idx) {
+        bool arg_column_nullable = false;
+        // get argument column and type
+        ColumnWithTypeAndName& column = block.get_by_position(arguments[arg_idx]);
+        auto column_type = column.type;
         data_cols[arg_idx] = column.column->convert_to_full_column_if_const();
-        if (!_argument_types[arg_idx]->equals(*column.type)) {
+
+        // check type
+        if (_argument_types[arg_idx]->equals(*column_type) == false) {
             return Status::InvalidArgument(strings::Substitute(
                     "$0-th input column's type $1 does not equal to required type $2", arg_idx,
-                    column.type->get_name(), _argument_types[arg_idx]->get_name()));
+                    column_type->get_name(), _argument_types[arg_idx]->get_name()));
         }
+
+        // get argument null map and nested column
         if (auto* nullable = check_and_get_column<const ColumnNullable>(*data_cols[arg_idx])) {
+            arg_column_nullable = true;
+            column_type = remove_nullable(column_type);
             null_cols[arg_idx] = nullable->get_null_map_column_ptr();
-            jni_ctx->input_nulls_buffer_ptr.get()[arg_idx] = reinterpret_cast<int64_t>(
+            data_cols[arg_idx] = nullable->get_nested_column_ptr();
+            nullmap_address = reinterpret_cast<int64_t>(
                     check_and_get_column<ColumnVector<UInt8>>(null_cols[arg_idx])
                             ->get_data()
                             .data());
-            data_cols[arg_idx] = nullable->get_nested_column_ptr();
-        } else {
-            jni_ctx->input_nulls_buffer_ptr.get()[arg_idx] = -1;
         }
 
-        if (data_cols[arg_idx]->is_column_string()) {
+        // convert argument column data into java type
+        jobjectArray arr_obj = nullptr;
+        if (data_cols[arg_idx]->is_numeric() || data_cols[arg_idx]->is_column_decimal()) {
+            arr_obj = (jobjectArray)env->CallNonvirtualObjectMethod(
+                    jni_ctx->executor, jni_env->executor_cl,
+                    jni_env->executor_convert_basic_argument_id, arg_idx, arg_column_nullable,
+                    num_rows, nullmap_address,
+                    reinterpret_cast<int64_t>(data_cols[arg_idx]->get_raw_data().data), 0);
+        } else if (data_cols[arg_idx]->is_column_string()) {
             const ColumnString* str_col =
                     assert_cast<const ColumnString*>(data_cols[arg_idx].get());
-            jni_ctx->input_values_buffer_ptr.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(str_col->get_chars().data());
-            jni_ctx->input_offsets_ptrs.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(str_col->get_offsets().data());
-        } else if (data_cols[arg_idx]->is_numeric() || data_cols[arg_idx]->is_column_decimal()) {
-            jni_ctx->input_values_buffer_ptr.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(data_cols[arg_idx]->get_raw_data().data);
+            arr_obj = (jobjectArray)env->CallNonvirtualObjectMethod(
+                    jni_ctx->executor, jni_env->executor_cl,
+                    jni_env->executor_convert_basic_argument_id, arg_idx, arg_column_nullable,
+                    num_rows, nullmap_address,
+                    reinterpret_cast<int64_t>(str_col->get_chars().data()),
+                    reinterpret_cast<int64_t>(str_col->get_offsets().data()));
         } else if (data_cols[arg_idx]->is_column_array()) {
             const ColumnArray* array_col =
                     assert_cast<const ColumnArray*>(data_cols[arg_idx].get());
-            jni_ctx->input_offsets_ptrs.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(array_col->get_offsets_column().get_raw_data().data);
             const ColumnNullable& array_nested_nullable =
                     assert_cast<const ColumnNullable&>(array_col->get_data());
             auto data_column_null_map = array_nested_nullable.get_null_map_column_ptr();
             auto data_column = array_nested_nullable.get_nested_column_ptr();
-            jni_ctx->input_array_nulls_buffer_ptr.get()[arg_idx] = reinterpret_cast<int64_t>(
+            auto offset_address =
+                    reinterpret_cast<int64_t>(array_col->get_offsets_column().get_raw_data().data);
+            auto nested_nullmap_address = reinterpret_cast<int64_t>(
                     check_and_get_column<ColumnVector<UInt8>>(data_column_null_map)
                             ->get_data()
                             .data());
-
-            //need pass FE, nullamp and offset, chars
+            int64_t nested_data_address = 0, nested_offset_address = 0;
+            // array type need pass address: [nullmap_address], offset_address, nested_nullmap_address, nested_data_address/nested_char_address,nested_offset_address
             if (data_column->is_column_string()) {

Review Comment:
   seems could use macro, but it will reduce the readability of the code and maybe not be worth it.



-- 
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 #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1619847182

   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


[GitHub] [doris] github-actions[bot] commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1621487219

   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


[GitHub] [doris] HappenLee commented on a diff in pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "HappenLee (via GitHub)" <gi...@apache.org>.
HappenLee commented on code in PR #21388:
URL: https://github.com/apache/doris/pull/21388#discussion_r1251437490


##########
fe/be-java-extensions/java-udf/src/main/java/org/apache/doris/udf/UdfExecutor.java:
##########
@@ -107,6 +111,407 @@ public void evaluate() throws UdfRuntimeException {
         }
     }
 
+    public Object[] convertBasicArguments(int argIdx, boolean isNullable, int numRows, long nullMapAddr,
+            long columnAddr, long strOffsetAddr) {
+        switch (argTypes[argIdx]) {
+            case BOOLEAN:
+                return UdfConvert.convertBooleanArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case TINYINT:
+                return UdfConvert.convertTinyIntArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case SMALLINT:
+                return UdfConvert.convertSmallIntArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case INT:
+                return UdfConvert.convertIntArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case BIGINT:
+                return UdfConvert.convertBigIntArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case LARGEINT:
+                return UdfConvert.convertLargeIntArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case FLOAT:
+                return UdfConvert.convertFloatArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case DOUBLE:
+                return UdfConvert.convertDoubleArg(isNullable, numRows, nullMapAddr, columnAddr);
+            case CHAR:
+            case VARCHAR:
+            case STRING:
+                return UdfConvert.convertStringArg(isNullable, numRows, nullMapAddr, columnAddr, strOffsetAddr);
+            case DATE: // udaf maybe argClass[i + argClassOffset] need add +1
+                return UdfConvert.convertDateArg(argClass[argIdx], isNullable, numRows, nullMapAddr, columnAddr);
+            case DATETIME:
+                return UdfConvert.convertDateTimeArg(argClass[argIdx], isNullable, numRows, nullMapAddr, columnAddr);
+            case DATEV2:
+                return UdfConvert.convertDateV2Arg(argClass[argIdx], isNullable, numRows, nullMapAddr, columnAddr);
+            case DATETIMEV2:
+                return UdfConvert.convertDateTimeV2Arg(argClass[argIdx], isNullable, numRows, nullMapAddr, columnAddr);
+            case DECIMALV2:
+            case DECIMAL128:
+                return UdfConvert.convertDecimalArg(argTypes[argIdx].getScale(), 16L, isNullable, numRows, nullMapAddr,
+                        columnAddr);
+            case DECIMAL32:
+                return UdfConvert.convertDecimalArg(argTypes[argIdx].getScale(), 4L, isNullable, numRows, nullMapAddr,
+                        columnAddr);
+            case DECIMAL64:
+                return UdfConvert.convertDecimalArg(argTypes[argIdx].getScale(), 8L, isNullable, numRows, nullMapAddr,
+                        columnAddr);
+            default:
+                Preconditions.checkState(false, "Not support type: " + argTypes[argIdx].toString());
+                LOG.info("Not support type: " + argTypes[argIdx].toString());
+                break;
+        }
+        return null;
+    }
+
+
+    public Object[] convertArrayArguments(int argIdx, boolean isNullable, int numRows, long nullMapAddr,
+            long offsetsAddr, long nestedNullMapAddr, long dataAddr, long strOffsetAddr) {
+        Object[] argument = (Object[]) Array.newInstance(ArrayList.class, numRows);
+        for (int row = 0; row < numRows; ++row) {
+            long offsetStart = UdfUtils.UNSAFE.getLong(null, offsetsAddr + 8L * (row - 1));
+            long offsetEnd = UdfUtils.UNSAFE.getLong(null, offsetsAddr + 8L * (row));
+            int currentRowNum = (int) (offsetEnd - offsetStart);
+            switch (argTypes[argIdx].getItemType().getPrimitiveType()) {
+                case BOOLEAN: {
+                    UdfConvert
+                            .convertArrayBooleanArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                                    nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case TINYINT: {
+                    UdfConvert
+                            .convertArrayTinyIntArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                                    nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case SMALLINT: {
+                    UdfConvert
+                            .convertArraySmallIntArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                                    nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case INT: {
+                    UdfConvert.convertArrayIntArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case BIGINT: {
+                    UdfConvert.convertArrayBigIntArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case LARGEINT: {
+                    UdfConvert
+                            .convertArrayLargeIntArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                                    nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case FLOAT: {
+                    UdfConvert.convertArrayFloatArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case DOUBLE: {
+                    UdfConvert.convertArrayDoubleArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case CHAR:
+                case VARCHAR:
+                case STRING: {
+                    UdfConvert.convertArrayStringArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                            nestedNullMapAddr, dataAddr, strOffsetAddr);
+                    break;
+                }
+                case DATE: {
+                    UdfConvert.convertArrayDateArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case DATETIME: {
+                    UdfConvert
+                            .convertArrayDateTimeArg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                                    nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case DATEV2: {
+                    UdfConvert.convertArrayDateV2Arg(argument, row, currentRowNum, offsetStart, isNullable, nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case DATETIMEV2: {
+                    UdfConvert.convertArrayDateTimeV2Arg(argument, row, currentRowNum, offsetStart, isNullable,
+                            nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case DECIMALV2:
+                case DECIMAL128: {
+                    UdfConvert.convertArrayDecimalArg(argTypes[argIdx].getScale(), 16L, argument, row, currentRowNum,
+                            offsetStart, isNullable,
+                            nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case DECIMAL32: {
+                    UdfConvert.convertArrayDecimalArg(argTypes[argIdx].getScale(), 4L, argument, row, currentRowNum,
+                            offsetStart, isNullable,
+                            nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                case DECIMAL64: {
+                    UdfConvert.convertArrayDecimalArg(argTypes[argIdx].getScale(), 8L, argument, row, currentRowNum,
+                            offsetStart, isNullable,
+                            nullMapAddr,
+                            nestedNullMapAddr, dataAddr);
+                    break;
+                }
+                default: {
+                    Preconditions.checkState(false, "Not support type " + argTypes[argIdx].toString());
+                    LOG.info("Not support: " + argTypes[argIdx]);
+                    break;
+                }
+            }
+        }
+        return argument;
+    }
+
+    /**
+     * Evaluates the UDF with 'args' as the input to the UDF.
+     */
+    public Object[] evaluate(int numRows, Object[] column) throws UdfRuntimeException {
+        try {
+            Object[] result = (Object[]) Array.newInstance(method.getReturnType(), numRows);
+            Object[][] inputs = (Object[][]) column;
+            Object[] parameters = new Object[inputs.length];
+            for (int i = 0; i < numRows; ++i) {
+                for (int j = 0; j < column.length; ++j) {
+                    parameters[j] = inputs[j][i];
+                }
+                result[i] = method.invoke(udf, parameters);
+            }
+            return result;
+        } catch (Exception e) {
+            LOG.info("evaluate2 Exception" + e.toString());

Review Comment:
   evaluate2 ?



-- 
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 #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1620952572

   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


[GitHub] [doris] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1622912319

   run buildall


-- 
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 #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1618197310

   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


[GitHub] [doris] HappenLee commented on a diff in pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "HappenLee (via GitHub)" <gi...@apache.org>.
HappenLee commented on code in PR #21388:
URL: https://github.com/apache/doris/pull/21388#discussion_r1251447716


##########
fe/be-java-extensions/java-udf/src/main/java/org/apache/doris/udf/UdfConvert.java:
##########
@@ -0,0 +1,1762 @@
+// 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.
+
+package org.apache.doris.udf;
+
+import org.apache.doris.common.jni.utils.JNINativeMethod;
+import org.apache.doris.common.jni.utils.OffHeap;
+import org.apache.doris.common.jni.utils.UdfUtils;
+
+import com.google.common.base.Preconditions;
+import org.apache.log4j.Logger;
+
+import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
+import java.nio.charset.StandardCharsets;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class UdfConvert {
+    private static final Logger LOG = Logger.getLogger(UdfConvert.class);
+
+    public static Object[] convertBooleanArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        Boolean[] argument = new Boolean[numRows];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    argument[i] = UdfUtils.UNSAFE.getBoolean(null, columnAddr + i);
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                argument[i] = UdfUtils.UNSAFE.getBoolean(null, columnAddr + i);
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertTinyIntArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        Byte[] argument = new Byte[numRows];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    argument[i] = UdfUtils.UNSAFE.getByte(null, columnAddr + i);
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                argument[i] = UdfUtils.UNSAFE.getByte(null, columnAddr + i);
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertSmallIntArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        Short[] argument = new Short[numRows];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    argument[i] = UdfUtils.UNSAFE.getShort(null, columnAddr + (i * 2L));
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                argument[i] = UdfUtils.UNSAFE.getShort(null, columnAddr + (i * 2L));
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertIntArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        Integer[] argument = new Integer[numRows];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    argument[i] = UdfUtils.UNSAFE.getInt(null, columnAddr + (i * 4L));
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                argument[i] = UdfUtils.UNSAFE.getInt(null, columnAddr + (i * 4L));
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertBigIntArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        Long[] argument = new Long[numRows];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    argument[i] = UdfUtils.UNSAFE.getLong(null, columnAddr + (i * 8L));
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                argument[i] = UdfUtils.UNSAFE.getLong(null, columnAddr + (i * 8L));
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertFloatArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        Float[] argument = new Float[numRows];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    argument[i] = UdfUtils.UNSAFE.getFloat(null, columnAddr + (i * 4L));
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                argument[i] = UdfUtils.UNSAFE.getFloat(null, columnAddr + (i * 4L));
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertDoubleArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        Double[] argument = new Double[numRows];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    argument[i] = UdfUtils.UNSAFE.getDouble(null, columnAddr + (i * 8L));
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                argument[i] = UdfUtils.UNSAFE.getDouble(null, columnAddr + (i * 8L));
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertDateArg(Class argTypeClass, boolean isNullable, int numRows, long nullMapAddr,
+            long columnAddr) {
+        Object[] argument = (Object[]) Array.newInstance(argTypeClass, numRows);
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    long value = UdfUtils.UNSAFE.getLong(null, columnAddr + (i * 8L));
+                    argument[i] = UdfUtils.convertDateToJavaDate(value, argTypeClass);
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                long value = UdfUtils.UNSAFE.getLong(null, columnAddr + (i * 8L));
+                argument[i] = UdfUtils.convertDateToJavaDate(value, argTypeClass);
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertDateTimeArg(Class argTypeClass, boolean isNullable, int numRows, long nullMapAddr,
+            long columnAddr) {
+        Object[] argument = (Object[]) Array.newInstance(argTypeClass, numRows);
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    long value = UdfUtils.UNSAFE.getLong(null, columnAddr + (i * 8L));
+                    argument[i] = UdfUtils
+                            .convertDateTimeToJavaDateTime(value, argTypeClass);
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                long value = UdfUtils.UNSAFE.getLong(null, columnAddr + (i * 8L));
+                argument[i] = UdfUtils.convertDateTimeToJavaDateTime(value, argTypeClass);
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertDateV2Arg(Class argTypeClass, boolean isNullable, int numRows, long nullMapAddr,
+            long columnAddr) {
+        Object[] argument = (Object[]) Array.newInstance(argTypeClass, numRows);
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    int value = UdfUtils.UNSAFE.getInt(null, columnAddr + (i * 4L));
+                    argument[i] = UdfUtils.convertDateV2ToJavaDate(value, argTypeClass);
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                int value = UdfUtils.UNSAFE.getInt(null, columnAddr + (i * 4L));
+                argument[i] = UdfUtils.convertDateV2ToJavaDate(value, argTypeClass);
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertDateTimeV2Arg(Class argTypeClass, boolean isNullable, int numRows, long nullMapAddr,
+            long columnAddr) {
+        Object[] argument = (Object[]) Array.newInstance(argTypeClass, numRows);
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(null, nullMapAddr + i) == 0) {
+                    long value = UdfUtils.UNSAFE.getLong(columnAddr + (i * 8L));
+                    argument[i] = UdfUtils
+                            .convertDateTimeV2ToJavaDateTime(value, argTypeClass);
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                long value = UdfUtils.UNSAFE.getLong(null, columnAddr + (i * 8L));
+                argument[i] = UdfUtils
+                        .convertDateTimeV2ToJavaDateTime(value, argTypeClass);
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertLargeIntArg(boolean isNullable, int numRows, long nullMapAddr, long columnAddr) {
+        BigInteger[] argument = new BigInteger[numRows];
+        byte[] bytes = new byte[16];
+        if (isNullable) {
+            for (int i = 0; i < numRows; ++i) {
+                if (UdfUtils.UNSAFE.getByte(nullMapAddr + i) == 0) {
+                    UdfUtils.copyMemory(null, columnAddr + (i * 16L), bytes, UdfUtils.BYTE_ARRAY_OFFSET, 16);
+                    argument[i] = new BigInteger(UdfUtils.convertByteOrder(bytes));
+                } // else is the current row is null
+            }
+        } else {
+            for (int i = 0; i < numRows; ++i) {
+                UdfUtils.copyMemory(null, columnAddr + (i * 16L), bytes, UdfUtils.BYTE_ARRAY_OFFSET, 16);
+                argument[i] = new BigInteger(UdfUtils.convertByteOrder(bytes));
+            }
+        }
+        return argument;
+    }
+
+    public static Object[] convertDecimalArg(int scale, long typeLen, boolean isNullable, int numRows, long nullMapAddr,
+            long columnAddr) {
+        BigDecimal[] argument = new BigDecimal[numRows];
+        byte[] bytes = new byte[(int) typeLen];
+        LOG.info("convertDecimalArg: " + scale + " " + typeLen + " " + isNullable + " " + numRows + " " + nullMapAddr

Review Comment:
   delete the info log



-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1619842980

   run buildall


-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1618190666

   run buildall


-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1621052357

   run feut


-- 
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 #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1622916979

   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


[GitHub] [doris] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1621478165

   run buildall


-- 
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] Gabriel39 commented on a diff in pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "Gabriel39 (via GitHub)" <gi...@apache.org>.
Gabriel39 commented on code in PR #21388:
URL: https://github.com/apache/doris/pull/21388#discussion_r1251442214


##########
be/src/vec/functions/function_java_udf.cpp:
##########
@@ -130,189 +141,177 @@ Status JavaFunctionCall::execute(FunctionContext* context, Block& block,
             context->get_function_state(FunctionContext::THREAD_LOCAL));
     JniEnv* jni_env =
             reinterpret_cast<JniEnv*>(context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
-    int arg_idx = 0;
-    ColumnPtr data_cols[arguments.size()];
-    ColumnPtr null_cols[arguments.size()];
-    for (size_t col_idx : arguments) {
-        ColumnWithTypeAndName& column = block.get_by_position(col_idx);
+    int arg_size = arguments.size();
+    ColumnPtr data_cols[arg_size];
+    ColumnPtr null_cols[arg_size];
+    jclass obj_class = env->FindClass("[Ljava/lang/Object;");
+    jclass arraylist_class = env->FindClass("Ljava/util/ArrayList;");
+    jobjectArray arg_objects = env->NewObjectArray(arg_size, obj_class, nullptr);
+    int64_t nullmap_address = 0;
+    for (size_t arg_idx = 0; arg_idx < arg_size; ++arg_idx) {
+        bool arg_column_nullable = false;
+        // get argument column and type
+        ColumnWithTypeAndName& column = block.get_by_position(arguments[arg_idx]);
+        auto column_type = column.type;
         data_cols[arg_idx] = column.column->convert_to_full_column_if_const();
-        if (!_argument_types[arg_idx]->equals(*column.type)) {
+
+        // check type
+        if (_argument_types[arg_idx]->equals(*column_type) == false) {
             return Status::InvalidArgument(strings::Substitute(
                     "$0-th input column's type $1 does not equal to required type $2", arg_idx,
-                    column.type->get_name(), _argument_types[arg_idx]->get_name()));
+                    column_type->get_name(), _argument_types[arg_idx]->get_name()));
         }
+
+        // get argument null map and nested column
         if (auto* nullable = check_and_get_column<const ColumnNullable>(*data_cols[arg_idx])) {
+            arg_column_nullable = true;
+            column_type = remove_nullable(column_type);
             null_cols[arg_idx] = nullable->get_null_map_column_ptr();
-            jni_ctx->input_nulls_buffer_ptr.get()[arg_idx] = reinterpret_cast<int64_t>(
+            data_cols[arg_idx] = nullable->get_nested_column_ptr();
+            nullmap_address = reinterpret_cast<int64_t>(
                     check_and_get_column<ColumnVector<UInt8>>(null_cols[arg_idx])
                             ->get_data()
                             .data());
-            data_cols[arg_idx] = nullable->get_nested_column_ptr();
-        } else {
-            jni_ctx->input_nulls_buffer_ptr.get()[arg_idx] = -1;
         }
 
-        if (data_cols[arg_idx]->is_column_string()) {
+        // convert argument column data into java type
+        jobjectArray arr_obj = nullptr;
+        if (data_cols[arg_idx]->is_numeric() || data_cols[arg_idx]->is_column_decimal()) {
+            arr_obj = (jobjectArray)env->CallNonvirtualObjectMethod(
+                    jni_ctx->executor, jni_env->executor_cl,
+                    jni_env->executor_convert_basic_argument_id, arg_idx, arg_column_nullable,
+                    num_rows, nullmap_address,
+                    reinterpret_cast<int64_t>(data_cols[arg_idx]->get_raw_data().data), 0);
+        } else if (data_cols[arg_idx]->is_column_string()) {
             const ColumnString* str_col =
                     assert_cast<const ColumnString*>(data_cols[arg_idx].get());
-            jni_ctx->input_values_buffer_ptr.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(str_col->get_chars().data());
-            jni_ctx->input_offsets_ptrs.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(str_col->get_offsets().data());
-        } else if (data_cols[arg_idx]->is_numeric() || data_cols[arg_idx]->is_column_decimal()) {
-            jni_ctx->input_values_buffer_ptr.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(data_cols[arg_idx]->get_raw_data().data);
+            arr_obj = (jobjectArray)env->CallNonvirtualObjectMethod(
+                    jni_ctx->executor, jni_env->executor_cl,
+                    jni_env->executor_convert_basic_argument_id, arg_idx, arg_column_nullable,
+                    num_rows, nullmap_address,
+                    reinterpret_cast<int64_t>(str_col->get_chars().data()),
+                    reinterpret_cast<int64_t>(str_col->get_offsets().data()));
         } else if (data_cols[arg_idx]->is_column_array()) {
             const ColumnArray* array_col =
                     assert_cast<const ColumnArray*>(data_cols[arg_idx].get());
-            jni_ctx->input_offsets_ptrs.get()[arg_idx] =
-                    reinterpret_cast<int64_t>(array_col->get_offsets_column().get_raw_data().data);
             const ColumnNullable& array_nested_nullable =
                     assert_cast<const ColumnNullable&>(array_col->get_data());
             auto data_column_null_map = array_nested_nullable.get_null_map_column_ptr();
             auto data_column = array_nested_nullable.get_nested_column_ptr();
-            jni_ctx->input_array_nulls_buffer_ptr.get()[arg_idx] = reinterpret_cast<int64_t>(
+            auto offset_address =
+                    reinterpret_cast<int64_t>(array_col->get_offsets_column().get_raw_data().data);
+            auto nested_nullmap_address = reinterpret_cast<int64_t>(
                     check_and_get_column<ColumnVector<UInt8>>(data_column_null_map)
                             ->get_data()
                             .data());
-
-            //need pass FE, nullamp and offset, chars
+            int64_t nested_data_address = 0, nested_offset_address = 0;
+            // array type need pass address: [nullmap_address], offset_address, nested_nullmap_address, nested_data_address/nested_char_address,nested_offset_address
             if (data_column->is_column_string()) {

Review Comment:
   Could we use Macro to collapse this pass above?



-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1619933017

   run feut


-- 
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 #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1621123692

   PR approved by anyone and no changes requested.


-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1620949273

   run buildall


-- 
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 #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1617707963

   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


[GitHub] [doris] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1622814396

   run p0


-- 
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] HappenLee merged pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "HappenLee (via GitHub)" <gi...@apache.org>.
HappenLee merged PR #21388:
URL: https://github.com/apache/doris/pull/21388


-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1620911806

   run feut


-- 
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] zhangstar333 commented on a diff in pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on code in PR #21388:
URL: https://github.com/apache/doris/pull/21388#discussion_r1251725297


##########
be/src/vec/functions/function_java_udf.cpp:
##########
@@ -130,189 +141,177 @@ Status JavaFunctionCall::execute(FunctionContext* context, Block& block,
             context->get_function_state(FunctionContext::THREAD_LOCAL));
     JniEnv* jni_env =
             reinterpret_cast<JniEnv*>(context->get_function_state(FunctionContext::FRAGMENT_LOCAL));
-    int arg_idx = 0;
-    ColumnPtr data_cols[arguments.size()];
-    ColumnPtr null_cols[arguments.size()];
-    for (size_t col_idx : arguments) {
-        ColumnWithTypeAndName& column = block.get_by_position(col_idx);
+    int arg_size = arguments.size();
+    ColumnPtr data_cols[arg_size];
+    ColumnPtr null_cols[arg_size];
+    jclass obj_class = env->FindClass("[Ljava/lang/Object;");
+    jclass arraylist_class = env->FindClass("Ljava/util/ArrayList;");
+    jobjectArray arg_objects = env->NewObjectArray(arg_size, obj_class, nullptr);
+    int64_t nullmap_address = 0;
+    for (size_t arg_idx = 0; arg_idx < arg_size; ++arg_idx) {
+        bool arg_column_nullable = false;
+        // get argument column and type
+        ColumnWithTypeAndName& column = block.get_by_position(arguments[arg_idx]);
+        auto column_type = column.type;
         data_cols[arg_idx] = column.column->convert_to_full_column_if_const();
-        if (!_argument_types[arg_idx]->equals(*column.type)) {
+
+        // check type
+        if (_argument_types[arg_idx]->equals(*column_type) == false) {

Review Comment:
   use check maybe cause BE coredump, this could return Invalid Argument status



-- 
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] zhangstar333 commented on pull request #21388: [refactor](udf) refactor java-udf execute method by using for loop

Posted by "zhangstar333 (via GitHub)" <gi...@apache.org>.
zhangstar333 commented on PR #21388:
URL: https://github.com/apache/doris/pull/21388#issuecomment-1617699748

   run buildall


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