Skip to content

Commit

Permalink
Updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
xxlaykxx committed Jul 9, 2024
1 parent a4e4b43 commit f76ca98
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
59 changes: 44 additions & 15 deletions cpp/src/gandiva/array_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ bool array_contains_template(const Type* entry_buf,
template <typename Type>
char* array_to_string_template(const Type* entry_buf,
int32_t entry_len, const int32_t* entry_validity, bool combined_row_validity,
const char* delimiter) {
const char* delimiter, gdv_int32 delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, gdv_int32* out_len) {
bool first_element = true;

const int32_t* entry_validityAdjusted = entry_validity - entry_len;
Expand All @@ -140,8 +141,8 @@ char* array_to_string_template(const Type* entry_buf,

first_element = false;
}

char* result_char = new char[result.length() + 1];
*valid_row = true;
char* result_char = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, *out_len));
std::strcpy(result_char, result.c_str());
return result_char;
}
Expand Down Expand Up @@ -242,30 +243,34 @@ double* array_float64_remove(int64_t context_ptr, const double* 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) {
const char* delimiter, int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, int32_t* out_len) {
return array_to_string_template<int32_t>(entry_buf, entry_len, entry_validity,
combined_row_validity, delimiter);
combined_row_validity, delimiter, delimiter_len, loop_var, validity_index_var, valid_row, out_len);
}

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) {
const char* delimiter, int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, id_t* out_len) {
return array_to_string_template<int64_t>(entry_buf, entry_len, entry_validity,
combined_row_validity, delimiter);
combined_row_validity, delimiter, delimiter_len, loop_var, validity_index_var, valid_row, out_len);
}

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) {
const char* delimiter,int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, int32_t** out_len) {
return array_to_string_template<float>(entry_buf, entry_len, entry_validity,
combined_row_validity, delimiter);
combined_row_validity, delimiter, delimiter_len, loop_var, validity_index_var, valid_row, out_len);
}

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) {
const char* delimiter, int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, int32_t* out_len) {
return array_to_string_template<double>(entry_buf, entry_len, entry_validity,
combined_row_validity, delimiter);
combined_row_validity, delimiter, delimiter_len, loop_var, validity_index_var, valid_row, out_len);
}
}

Expand Down Expand Up @@ -420,7 +425,13 @@ arrow::Status ExportedArrayFunctions::AddMappings(Engine* engine) const {
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
types->i8_ptr_type(),
types->i32_ptr_type() //delimiter length
types->i1_type(), // bool validity --Needed?
types->i64_type(), //in loop var --Needed?
types->i64_type(), //in validity_index_var index into the valdity vector for the current row.
types->i1_ptr_type() //output validity for the row
types->i32_ptr_type(), // output length //value to for delimiter
};
engine->AddGlobalMappingForFunc("array_int32_to_string",
types->i32_ptr_type(), args,
Expand All @@ -431,7 +442,13 @@ arrow::Status ExportedArrayFunctions::AddMappings(Engine* engine) const {
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
types->i8_ptr_type(), //value to for delimiter
types->i32_ptr_type(), //delimiter length
types->i1_type(), // bool validity --Needed?
types->i64_type(), //in loop var --Needed?
types->i64_type(), //in validity_index_var index into the valdity vector for the current row.
types->i1_ptr_type() //output validity for the row
types->i32_ptr_type(), // output length
};

engine->AddGlobalMappingForFunc("array_int64_to_string",
Expand All @@ -443,7 +460,13 @@ arrow::Status ExportedArrayFunctions::AddMappings(Engine* engine) const {
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
types->i8_ptr_type(), //value to for delimiter
types->i32_ptr_type(), //delimiter length
types->i1_type(), // bool validity --Needed?
types->i64_type(), //in loop var --Needed?
types->i64_type(), //in validity_index_var index into the valdity vector for the current row.
types->i1_ptr_type() //output validity for the row
types->i32_ptr_type(), // output length
};

engine->AddGlobalMappingForFunc("array_float32_to_string",
Expand All @@ -455,7 +478,13 @@ arrow::Status ExportedArrayFunctions::AddMappings(Engine* engine) const {
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
types->i8_ptr_type(), //value to for delimiter
types->i32_ptr_type(), //delimiter length
types->i1_type(), // bool validity --Needed?
types->i64_type(), //in loop var --Needed?
types->i64_type(), //in validity_index_var index into the valdity vector for the current row.
types->i1_ptr_type() //output validity for the row
types->i32_ptr_type(), // output length
};

engine->AddGlobalMappingForFunc("array_float64_to_string",
Expand Down
12 changes: 8 additions & 4 deletions cpp/src/gandiva/array_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,21 @@ 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);
const char* delimiter, int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, id_t* out_len);
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);
const char* delimiter, int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, id_t* out_len);
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);
const char* delimiter, int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, id_t* out_len);
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);
const char* delimiter, int32_t delimiter_len, int64_t loop_var, int64_t validity_index_var,
bool* valid_row, id_t* out_len);
}

0 comments on commit f76ca98

Please sign in to comment.