Johnnathanalmeida commented on a change in pull request #12404:
URL: https://github.com/apache/arrow/pull/12404#discussion_r815973849
##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -1022,6 +1024,73 @@ const char* gdv_mask_first_n_utf8_int32(int64_t context,
const char* data,
return out;
}
+const char* to_hex_binary(int64_t context, const char* text, int32_t text_len,
+ int32_t* out_len) {
+ if (text_len == 0) {
+ *out_len = 0;
+ return "";
+ }
+
+ auto ret =
+ reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, text_len *
2 + 1));
+
+ if (ret == nullptr) {
+ gdv_fn_context_set_error_msg(context, "Could not allocate memory for
output string");
+ *out_len = 0;
+ return "";
+ }
+
+ uint32_t ret_index = 0;
+ uint32_t max_len = static_cast<uint32_t>(text_len) * 2;
+ uint32_t max_char_to_write = 4;
+
+ for (gdv_int32 i = 0; i < text_len; i++) {
+ DCHECK(ret_index >= 0 && ret_index < max_len);
+
+ int32_t ch = static_cast<int32_t>(text[i]) & 0xFF;
+
+ ret_index += snprintf(ret + ret_index, max_char_to_write, "%02X", ch);
+ }
+
+ *out_len = static_cast<int32_t>(ret_index);
+ return ret;
+}
+
+GANDIVA_EXPORT
+const char* gdv_mask_hash_utf8_utf8(int64_t context, const char* data, int32_t
data_len,
+ int32_t* out_len) {
+ if (data_len <= 0) {
+ *out_len = 0;
+ return nullptr;
+ }
+
+ // Gandiva hash the value by sha256 and encoding it into a lower case hex
string in
+ // non FIPS mode. In FIPS enabled mode, it's required to use sha512 for mask
hash.
+ if (FIPS_mode()) {
+ const char* sha_hash = gandiva::gdv_sha512_hash(context, data, data_len,
out_len);
+
+ if (sha_hash == nullptr) {
+ gdv_fn_context_set_error_msg(context,
+ "Could not allocate memory for output
string");
+ *out_len = 0;
+ return "";
+ }
+
+ return gdv_fn_lower_utf8(context, sha_hash, *out_len, out_len);
Review comment:
Apparently it is not mandatory.
I removed the call to the lower function and the tests continued to pass
without errors.
--
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]