HappenLee commented on a change in pull request #8678:
URL: https://github.com/apache/incubator-doris/pull/8678#discussion_r839352328
##########
File path: be/src/vec/functions/function_java_udf.h
##########
@@ -76,27 +76,37 @@ class JavaFunctionCall : public IFunctionBase {
jmethodID executor_evaluate_id_;
jmethodID executor_close_id_;
+ struct IntermediateState {
+ size_t buffer_size;
+ size_t row_idx;
+ };
+
struct JniContext {
JavaFunctionCall* parent = nullptr;
jobject executor = nullptr;
int64_t input_values_buffer_ptr;
int64_t input_nulls_buffer_ptr;
- int64_t input_byte_offsets_ptr;
+ int64_t input_offsets_ptrs;
int64_t output_value_buffer;
int64_t output_null_value;
+ int64_t output_offsets_ptr;
int64_t batch_size_ptr;
+ // intermediate_state includes two parts: reserved / used buffer size
and rows
+ IntermediateState* output_intermediate_state_ptr;
Review comment:
Pay attention to indentation
##########
File path: be/src/vec/functions/function_java_udf.h
##########
@@ -111,17 +121,25 @@ class JavaFunctionCall : public IFunctionBase {
env->DeleteGlobalRef(executor);
delete[] ((int64*) input_values_buffer_ptr);
delete[] ((int64*) input_nulls_buffer_ptr);
- delete[] ((int64*) input_byte_offsets_ptr);
+ delete[] ((int64*) input_offsets_ptrs);
free((int64*) output_value_buffer);
free((int64*) output_null_value);
+ free((int32_t*) output_offsets_ptr);
free((int32*) batch_size_ptr);
+ free(output_intermediate_state_ptr);
}
/// These functions are cross-compiled to IR and used by codegen.
static void SetInputNullsBufferElement(
JniContext* jni_ctx, int index, uint8_t value);
static uint8_t* GetInputValuesBufferAtOffset(JniContext* jni_ctx, int
offset);
};
+
+ static const int32_t INITIAL_RESERVED_BUFFER_SIZE = 1024;
Review comment:
constexpr
##########
File path: be/src/vec/functions/function_java_udf.h
##########
@@ -111,17 +121,25 @@ class JavaFunctionCall : public IFunctionBase {
env->DeleteGlobalRef(executor);
delete[] ((int64*) input_values_buffer_ptr);
delete[] ((int64*) input_nulls_buffer_ptr);
- delete[] ((int64*) input_byte_offsets_ptr);
+ delete[] ((int64*) input_offsets_ptrs);
free((int64*) output_value_buffer);
free((int64*) output_null_value);
+ free((int32_t*) output_offsets_ptr);
free((int32*) batch_size_ptr);
+ free(output_intermediate_state_ptr);
}
/// These functions are cross-compiled to IR and used by codegen.
static void SetInputNullsBufferElement(
JniContext* jni_ctx, int index, uint8_t value);
static uint8_t* GetInputValuesBufferAtOffset(JniContext* jni_ctx, int
offset);
};
+
+ static const int32_t INITIAL_RESERVED_BUFFER_SIZE = 1024;
+ // TODO: we need a heuristic strategy to increase buffer size for
variable-size output.
+ static inline int32_t IncreaseReservedBufferSize(int n) {
Review comment:
constexpr
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]