Skip to content

Commit

Permalink
Fix bugs in sha2 functions with kResultNullIfNull set (apache#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE authored Sep 1, 2022
1 parent e8a1b8f commit 7180b1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cpp/src/gandiva/function_registry_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ typedef std::unordered_map<const FunctionSignature*, const NativeFunction*, KeyH
//
// The function name includes the base name & input type name. gdv_fn_sha1_float64
#define HASH_SHA1_NULL_IF_NULL(NAME, ALIASES, TYPE) \
NativeFunction(#NAME, std::vector<std::string> ALIASES, DataTypeVector{TYPE()}, \
utf8(), kResultNullIfNull, ARROW_STRINGIFY(gdv_fn_sha1_##TYPE), \
NativeFunction(#NAME, std::vector<std::string> ALIASES, DataTypeVector{TYPE()}, \
utf8(), kResultNullIfNull, ARROW_STRINGIFY(gdv_fn_sha1_##TYPE), \
NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors)

// HashSHA2 functions that :
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/gandiva/gdv_function_stubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,
#define SHA2_HASH_FUNCTION_BUF(TYPE) \
GANDIVA_EXPORT \
const char* gdv_fn_sha2_##TYPE##_int32(int64_t context, gdv_##TYPE value, \
int32_t value_length, bool value_validity, \
int32_t bits_length, bool bits_len_validity, \
int32_t value_length, \
int32_t bits_length, \
int32_t* out_length) { \
return gandiva::gdv_sha2_hash(context, value, value_length, bits_length, out_length); \
}

#define SHA256_HASH_FUNCTION(TYPE) \
GANDIVA_EXPORT \
const char* gdv_fn_sha256_##TYPE(int64_t context, gdv_##TYPE value, bool validity, \
const char* gdv_fn_sha256_##TYPE(int64_t context, gdv_##TYPE value, \
int32_t* out_length) { \
auto value_as_long = gandiva::gdv_double_to_long((double)value); \
const char* result = gandiva::gdv_sha256_hash(context, &value_as_long, \
Expand All @@ -348,7 +348,7 @@ int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,
#define SHA256_HASH_FUNCTION_BUF(TYPE) \
GANDIVA_EXPORT \
const char* gdv_fn_sha256_##TYPE(int64_t context, gdv_##TYPE value, \
int32_t value_length, bool value_validity, \
int32_t value_length, \
int32_t* out_length) { \
return gandiva::gdv_sha256_hash(context, value, value_length, out_length); \
}
Expand Down Expand Up @@ -980,7 +980,7 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
args = {
types->i64_type(), // context
types->i8_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_md5_int8", types->i8_ptr_type() /*return_type*/,
args, reinterpret_cast<void*>(gdv_fn_md5_int8));
Expand Down

0 comments on commit 7180b1c

Please sign in to comment.