Skip to content

Commit

Permalink
updated function
Browse files Browse the repository at this point in the history
  • Loading branch information
xxlaykxx committed Jul 1, 2024
1 parent e315c16 commit 27b0619
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
57 changes: 53 additions & 4 deletions cpp/src/gandiva/array_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,29 +239,29 @@ double* array_float64_remove(int64_t context_ptr, const double* entry_buf,
valid_row, out_len, valid_ptr);
}

bool array_int32_to_string(int64_t context_ptr, const int32_t* entry_buf,
char* array_int32_to_string(int64_t context_ptr, const int32_t* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
int32_t contains_data, bool contains_data_valid,
const char* delimiter) {
return array_to_string_template<int32_t>(entry_buf, entry_len, entry_validity,
combined_row_validity, delimiter);
}

bool array_int64_to_string(int64_t context_ptr, const int64_t* entry_buf,
char* array_int64_to_string(int64_t context_ptr, const int64_t* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
const char* delimiter) {
return array_to_string_template<int64_t>(entry_buf, entry_len, entry_validity,
combined_row_validity, delimiter);
}

bool array_float32_to_string(int64_t context_ptr, const float* entry_buf,
char* array_float32_to_string(int64_t context_ptr, const float* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
const char* delimiter) {
return array_to_string_template<float>(entry_buf, entry_len, entry_validity,
combined_row_validity, delimiter);
}

bool array_float64_to_string(int64_t context_ptr, const double* entry_buf,
char* array_float64_to_string(int64_t context_ptr, const double* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
const char* delimiter) {
return array_to_string_template<double>(entry_buf, entry_len, entry_validity,
Expand Down Expand Up @@ -412,6 +412,55 @@ arrow::Status ExportedArrayFunctions::AddMappings(Engine* engine) const {
engine->AddGlobalMappingForFunc("array_float64_remove",
types->double_ptr_type(), args,
reinterpret_cast<void*>(array_float64_remove));


//Array to string.
args = {types->i64_type(), // int64_t execution_context
types->i32_ptr_type(), // int8_t* input data ptr
types->i32_type(), // int32_t input length
types->i32_ptr_type(), // input validity buffer
types->i1_type(), // bool input row validity
types->i8_ptr_type() //value to for delimiter
};
engine->AddGlobalMappingForFunc("array_int32_to_string",
types->i32_ptr_type(), args,
reinterpret_cast<void*>(array_int32_to_string));

args = {types->i64_type(), // int64_t execution_context
types->i64_ptr_type(), // int8_t* input data ptr
types->i32_type(), // int32_t input length
types->i32_ptr_type(), // input validity buffer
types->i1_type(), // bool input row validity
types->i8_ptr_type() //value to for delimiter
};

engine->AddGlobalMappingForFunc("array_int64_to_string",
types->i64_ptr_type(), args,
reinterpret_cast<void*>(array_int64_to_string));

args = {types->i64_type(), // int64_t execution_context
types->float_ptr_type(), // float* input data ptr
types->i32_type(), // int32_t input length
types->i32_ptr_type(), // input validity buffer
types->i1_type(), // bool input row validity
types->i8_ptr_type() //value to for delimiter
};

engine->AddGlobalMappingForFunc("array_float32_to_string",
types->float_ptr_type(), args,
reinterpret_cast<void*>(array_float32_to_string));

args = {types->i64_type(), // int64_t execution_context
types->double_ptr_type(), // int8_t* input data ptr
types->i32_type(), // int32_t input length
types->i32_ptr_type(), // input validity buffer
types->i1_type(), // bool input row validity
types->i8_ptr_type() //value to for delimiter
};

engine->AddGlobalMappingForFunc("array_float64_to_string",
types->double_ptr_type(), args,
reinterpret_cast<void*>(array_float64_to_string));
return arrow::Status::OK();
}
} // namespace gandiva
18 changes: 17 additions & 1 deletion cpp/src/gandiva/array_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,21 @@ double* array_float64_remove(int64_t context_ptr, const double* entry_buf,
double remove_data, bool entry_validWhat,
int64_t loop_var, int64_t validity_index_var,
bool* valid_row, int32_t* out_len, int32_t** valid_ptr);

GANDIVA_EXPORT
char* array_int32_to_string(int64_t context_ptr, const int32_t* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
int32_t contains_data, bool contains_data_valid,
const char* delimiter);
GANDIVA_EXPORT
char* array_int64_to_string(int64_t context_ptr, const int64_t* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
const char* delimiter);
GANDIVA_EXPORT
char* array_float32_to_string(int64_t context_ptr, const float* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
const char* delimiter);
GANDIVA_EXPORT
char* array_float64_to_string(int64_t context_ptr, const double* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
const char* delimiter);
}

0 comments on commit 27b0619

Please sign in to comment.