|
34 | 34 | #include "gandiva/replace_holder.h" |
35 | 35 | #include "gandiva/rlike_holder.h" |
36 | 36 | #include "gandiva/extract_holder.h" |
| 37 | +#include "gandiva/parse_url_holder.h" |
37 | 38 | #include "gandiva/to_date_holder.h" |
38 | 39 | #include "gandiva/translate_holder.h" |
39 | 40 | #include "gandiva/substr_index_holder.h" |
@@ -125,6 +126,48 @@ const char* gdv_fn_regexp_extract_utf8_utf8_int32( |
125 | 126 | return (*holder)(context, data, data_len, idx, out_length); |
126 | 127 | } |
127 | 128 |
|
| 129 | +const char* gdv_fn_parse_url_utf8_utf8( |
| 130 | + int64_t ptr, int64_t holder_ptr, const char* data, int32_t data_len, bool in1_valid, |
| 131 | + const char* part, int32_t part_len, bool in2_valid, bool* out_valid, int32_t* out_length) { |
| 132 | + if (!in1_valid || !in2_valid) { |
| 133 | + *out_valid = false; |
| 134 | + *out_length = 0; |
| 135 | + return reinterpret_cast<const char*>(""); |
| 136 | + } |
| 137 | + gandiva::ExecutionContext* context = reinterpret_cast<gandiva::ExecutionContext*>(ptr); |
| 138 | + gandiva::ParseUrlHolder* holder = reinterpret_cast<gandiva::ParseUrlHolder*>(holder_ptr); |
| 139 | + auto res = (*holder)(context, data, data_len, part, part_len, out_length); |
| 140 | + if (res == nullptr) { |
| 141 | + *out_valid = false; |
| 142 | + *out_length = 0; |
| 143 | + return reinterpret_cast<const char*>(""); |
| 144 | + } |
| 145 | + *out_valid = true; |
| 146 | + return res; |
| 147 | +} |
| 148 | + |
| 149 | +const char* gdv_fn_parse_url_utf8_utf8_utf8( |
| 150 | + int64_t ptr, int64_t holder_ptr, const char* data, int32_t data_len, bool in1_valid, |
| 151 | + const char* part, int32_t part_len, bool in2_valid, |
| 152 | + const char* pattern, int32_t pattern_len, bool in3_valid, |
| 153 | + bool* out_valid, int32_t* out_length) { |
| 154 | + if (!in1_valid || !in2_valid || !in3_valid) { |
| 155 | + *out_valid = false; |
| 156 | + *out_length = 0; |
| 157 | + return reinterpret_cast<const char*>(""); |
| 158 | + } |
| 159 | + gandiva::ExecutionContext* context = reinterpret_cast<gandiva::ExecutionContext*>(ptr); |
| 160 | + gandiva::ParseUrlHolder* holder = reinterpret_cast<gandiva::ParseUrlHolder*>(holder_ptr); |
| 161 | + auto res = (*holder)(context, data, data_len, part, part_len, pattern, pattern_len, out_length); |
| 162 | + if (res == nullptr) { |
| 163 | + *out_valid = false; |
| 164 | + *out_length = 0; |
| 165 | + return reinterpret_cast<const char*>(""); |
| 166 | + } |
| 167 | + *out_valid = true; |
| 168 | + return res; |
| 169 | +} |
| 170 | + |
128 | 171 | double gdv_fn_random(int64_t ptr) { |
129 | 172 | gandiva::RandomGeneratorHolder* holder = |
130 | 173 | reinterpret_cast<gandiva::RandomGeneratorHolder*>(ptr); |
@@ -749,6 +792,41 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const { |
749 | 792 | "gdv_fn_regexp_extract_utf8_utf8_int32", types->i8_ptr_type() /*return_type*/, args, |
750 | 793 | reinterpret_cast<void*>(gdv_fn_regexp_extract_utf8_utf8_int32)); |
751 | 794 |
|
| 795 | + // gdv_fn_parse_url_utf8_utf8 |
| 796 | + args = {types->i64_type(), // int64_t ptr |
| 797 | + types->i64_type(), // int64_t holder_ptr |
| 798 | + types->i8_ptr_type(), // const char* data |
| 799 | + types->i32_type(), // int data_len |
| 800 | + types->i1_type(), // bool in1_validity |
| 801 | + types->i8_ptr_type(), // const char* part |
| 802 | + types->i32_type(), // int part_len |
| 803 | + types->i1_type(), // bool in2_validity |
| 804 | + types->ptr_type(types->i8_type()), // bool* out_valid |
| 805 | + types->i32_ptr_type()}; // int32_t* out_length |
| 806 | + |
| 807 | + engine->AddGlobalMappingForFunc( |
| 808 | + "gdv_fn_parse_url_utf8_utf8", types->i8_ptr_type() /*return_type*/, args, |
| 809 | + reinterpret_cast<void*>(gdv_fn_parse_url_utf8_utf8)); |
| 810 | + |
| 811 | + // gdv_fn_parse_url_utf8_utf8_utf8 |
| 812 | + args = {types->i64_type(), // int64_t ptr |
| 813 | + types->i64_type(), // int64_t holder_ptr |
| 814 | + types->i8_ptr_type(), // const char* data |
| 815 | + types->i32_type(), // int data_len |
| 816 | + types->i1_type(), // bool in1_validity |
| 817 | + types->i8_ptr_type(), // const char* part |
| 818 | + types->i32_type(), // int part_len |
| 819 | + types->i1_type(), // bool in2_validity |
| 820 | + types->i8_ptr_type(), // const char* pattern |
| 821 | + types->i32_type(), // int pattern_len |
| 822 | + types->i1_type(), // bool in3_validity |
| 823 | + types->ptr_type(types->i8_type()), // bool* out_valid |
| 824 | + types->i32_ptr_type()}; // int32_t* out_length |
| 825 | + |
| 826 | + engine->AddGlobalMappingForFunc( |
| 827 | + "gdv_fn_parse_url_utf8_utf8_utf8", types->i8_ptr_type() /*return_type*/, args, |
| 828 | + reinterpret_cast<void*>(gdv_fn_parse_url_utf8_utf8_utf8)); |
| 829 | + |
752 | 830 | // gdv_fn_to_date_utf8_utf8 |
753 | 831 | args = {types->i64_type(), // int64_t execution_context |
754 | 832 | types->i64_type(), // int64_t holder_ptr |
|
0 commit comments