mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
Change name from sha128 to sha1
This commit is contained in:
1 parent
aa94ffdc84
commit
6238bfc3c2
8 files changed
+134
-125
No files matched your search
@@ -208,15 +208,15 @@ typedef std::unordered_map<const FunctionSignature*, const NativeFunction*, KeyH
|
||||
DataTypeVector{TYPE(), int64()}, int64(), kResultNullNever, \
|
||||
ARROW_STRINGIFY(NAME##WithSeed_##TYPE))
|
||||
|
||||
// HashSHA128 functions that :
|
||||
// HashSHA1 functions that :
|
||||
// - NULL handling is of type NULL_NEVER
|
||||
// - can return errors
|
||||
//
|
||||
// The function name includes the base name & input type name. gdv_fn_sha128_float64
|
||||
#define HASH_SHA128_NULL_NEVER(NAME, ALIASES, TYPE) \
|
||||
// The function name includes the base name & input type name. gdv_fn_sha1_float64
|
||||
#define HASH_SHA1_NULL_NEVER(NAME, ALIASES, TYPE) \
|
||||
NativeFunction(#NAME, std::vector<std::string> ALIASES, \
|
||||
DataTypeVector{TYPE()}, utf8(), kResultNullNever, \
|
||||
ARROW_STRINGIFY(gdv_fn_sha128_##TYPE), \
|
||||
ARROW_STRINGIFY(gdv_fn_sha1_##TYPE), \
|
||||
NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors)
|
||||
|
||||
// HashSHA256 functions that :
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace gandiva {
|
||||
#define HASH64_SEED_SAFE_NULL_NEVER_FN(name, ALIASES) \
|
||||
NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH64_SEED_SAFE_NULL_NEVER, name, ALIASES)
|
||||
|
||||
#define HASH_SHA128_NULL_NEVER_FN(name, ALIASES) \
|
||||
NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH_SHA128_NULL_NEVER, name, ALIASES)
|
||||
#define HASH_SHA1_NULL_NEVER_FN(name, ALIASES) \
|
||||
NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH_SHA1_NULL_NEVER, name, ALIASES)
|
||||
|
||||
#define HASH_SHA256_NULL_NEVER_FN(name, ALIASES) \
|
||||
NUMERIC_BOOL_DATE_VAR_LEN_TYPES(HASH_SHA256_NULL_NEVER, name, ALIASES)
|
||||
@@ -53,7 +53,7 @@ std::vector<NativeFunction> GetHashFunctionRegistry() {
|
||||
HASH64_SEED_SAFE_NULL_NEVER_FN(hash64, {}),
|
||||
HASH64_SEED_SAFE_NULL_NEVER_FN(hash64AsDouble, {}),
|
||||
|
||||
HASH_SHA128_NULL_NEVER_FN(hashSHA128, {}),
|
||||
HASH_SHA1_NULL_NEVER_FN(hashSHA1, {}),
|
||||
|
||||
HASH_SHA256_NULL_NEVER_FN(hashSHA256, {})};
|
||||
|
||||
|
||||
@@ -123,35 +123,35 @@ int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SHA128_HASH_FUNCTION(TYPE) \
|
||||
#define SHA1_HASH_FUNCTION(TYPE) \
|
||||
GANDIVA_EXPORT \
|
||||
const char *gdv_fn_sha128_##TYPE(int64_t context, gdv_##TYPE value, \
|
||||
const char *gdv_fn_sha1_##TYPE(int64_t context, gdv_##TYPE value, \
|
||||
bool validity, int32_t *out_length) { \
|
||||
if (!validity) { \
|
||||
return gandiva::HashUtils::HashUsingSha128(context, NULLPTR, \
|
||||
return gandiva::HashUtils::HashUsingSha1(context, NULLPTR, \
|
||||
0, out_length); \
|
||||
} \
|
||||
auto value_as_long = gandiva::HashUtils::DoubleToLong((double)value); \
|
||||
const char *result = gandiva::HashUtils::HashUsingSha128(context, \
|
||||
&value_as_long, \
|
||||
sizeof(value_as_long), \
|
||||
out_length); \
|
||||
const char *result = gandiva::HashUtils::HashUsingSha1(context, \
|
||||
&value_as_long, \
|
||||
sizeof(value_as_long), \
|
||||
out_length); \
|
||||
\
|
||||
return result; \
|
||||
} \
|
||||
|
||||
#define SHA128_HASH_FUNCTION_BUF(TYPE) \
|
||||
#define SHA1_HASH_FUNCTION_BUF(TYPE) \
|
||||
GANDIVA_EXPORT \
|
||||
const char *gdv_fn_sha128_##TYPE(int64_t context, \
|
||||
const char *gdv_fn_sha1_##TYPE(int64_t context, \
|
||||
gdv_##TYPE value, \
|
||||
int32_t value_length, \
|
||||
bool value_validity, \
|
||||
int32_t *out_length) { \
|
||||
if (!value_validity) { \
|
||||
return gandiva::HashUtils::HashUsingSha128(context, NULLPTR, \
|
||||
return gandiva::HashUtils::HashUsingSha1(context, NULLPTR, \
|
||||
0, out_length); \
|
||||
} \
|
||||
return gandiva::HashUtils::HashUsingSha128(context, value, \
|
||||
return gandiva::HashUtils::HashUsingSha1(context, value, \
|
||||
value_length, out_length); \
|
||||
}
|
||||
|
||||
@@ -215,8 +215,8 @@ int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,
|
||||
SHA_NUMERIC_BOOL_DATE_PARAMS(SHA256_HASH_FUNCTION)
|
||||
SHA_VAR_LEN_PARAMS(SHA256_HASH_FUNCTION_BUF)
|
||||
|
||||
SHA_NUMERIC_BOOL_DATE_PARAMS(SHA128_HASH_FUNCTION)
|
||||
SHA_VAR_LEN_PARAMS(SHA128_HASH_FUNCTION_BUF)
|
||||
SHA_NUMERIC_BOOL_DATE_PARAMS(SHA1_HASH_FUNCTION)
|
||||
SHA_VAR_LEN_PARAMS(SHA1_HASH_FUNCTION_BUF)
|
||||
|
||||
#undef SHA_NUMERIC_BOOL_DATE_PARAMS
|
||||
#undef SHA_VAR_LEN_PARAMS
|
||||
@@ -237,17 +237,17 @@ const char* gdv_fn_sha256_decimal128(int64_t context, int64_t x_high, uint64_t x
|
||||
}
|
||||
|
||||
GANDIVA_EXPORT
|
||||
const char* gdv_fn_sha128_decimal128(int64_t context, int64_t x_high, uint64_t x_low,
|
||||
int32_t x_precision, int32_t x_scale,
|
||||
gdv_boolean x_isvalid, int32_t *out_length) {
|
||||
const char* gdv_fn_sha1_decimal128(int64_t context, int64_t x_high, uint64_t x_low,
|
||||
int32_t x_precision, int32_t x_scale,
|
||||
gdv_boolean x_isvalid, int32_t *out_length) {
|
||||
if (!x_isvalid) {
|
||||
return gandiva::HashUtils::HashUsingSha128(context, NULLPTR,
|
||||
0, out_length);
|
||||
return gandiva::HashUtils::HashUsingSha1(context, NULLPTR,
|
||||
0, out_length);
|
||||
}
|
||||
|
||||
const auto &decimal_128 = gandiva::BasicDecimal128(x_high, x_low);
|
||||
return gandiva::HashUtils::HashUsingSha128(context, decimal_128.ToBytes().data(),
|
||||
16, out_length);
|
||||
return gandiva::HashUtils::HashUsingSha1(context, decimal_128.ToBytes().data(),
|
||||
16, out_length);
|
||||
}
|
||||
|
||||
int32_t gdv_fn_dec_from_string(int64_t context, const char* in, int32_t in_length,
|
||||
@@ -466,172 +466,172 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_castFLOAT8_utf8", types->double_type(), args,
|
||||
reinterpret_cast<void*>(gdv_fn_castFLOAT8_utf8));
|
||||
|
||||
// gdv_fn_sha128_int8
|
||||
// gdv_fn_sha1_int8
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i8_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_int8",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_int8",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_int8));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_int8));
|
||||
|
||||
// gdv_fn_sha128_int16
|
||||
// gdv_fn_sha1_int16
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i16_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_int16",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_int16",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_int16));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_int16));
|
||||
|
||||
// gdv_fn_sha128_int32
|
||||
// gdv_fn_sha1_int32
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i32_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_int32",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_int32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_int32));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_int32));
|
||||
|
||||
// gdv_fn_sha128_int32
|
||||
// gdv_fn_sha1_int32
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i64_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_int64",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_int64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_int64));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_int64));
|
||||
|
||||
// gdv_fn_sha128_uint8
|
||||
// gdv_fn_sha1_uint8
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i8_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_uint8",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_uint8",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_uint8));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_uint8));
|
||||
|
||||
// gdv_fn_sha128_uint16
|
||||
// gdv_fn_sha1_uint16
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i16_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_uint16",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_uint16",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_uint16));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_uint16));
|
||||
|
||||
// gdv_fn_sha128_uint32
|
||||
// gdv_fn_sha1_uint32
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i32_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_uint32",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_uint32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_uint32));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_uint32));
|
||||
|
||||
// gdv_fn_sha128_uint64
|
||||
// gdv_fn_sha1_uint64
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i64_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_uint64",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_uint64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_uint64));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_uint64));
|
||||
|
||||
// gdv_fn_sha128_float32
|
||||
// gdv_fn_sha1_float32
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->float_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_float32",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_float32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_float32));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_float32));
|
||||
|
||||
// gdv_fn_sha128_float64
|
||||
// gdv_fn_sha1_float64
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->double_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_float64",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_float64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_float64));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_float64));
|
||||
|
||||
// gdv_fn_sha128_boolean
|
||||
// gdv_fn_sha1_boolean
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i1_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_boolean",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_boolean",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_boolean));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_boolean));
|
||||
|
||||
// gdv_fn_sha128_date64
|
||||
// gdv_fn_sha1_date64
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i64_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_date64",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_date64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_date64));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_date64));
|
||||
|
||||
// gdv_fn_sha128_date32
|
||||
// gdv_fn_sha1_date32
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i32_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_date32",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_date32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_date32));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_date32));
|
||||
|
||||
// gdv_fn_sha128_time32
|
||||
// gdv_fn_sha1_time32
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i32_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_time32",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_time32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_time32));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_time32));
|
||||
|
||||
// gdv_fn_sha128_timestamp
|
||||
// gdv_fn_sha1_timestamp
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i64_type(), // value
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out_length
|
||||
};
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_timestamp",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_timestamp",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_timestamp));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_timestamp));
|
||||
|
||||
// gdv_fn_hash_sha128_from_utf8
|
||||
// gdv_fn_sha1_from_utf8
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i8_ptr_type(), // const char*
|
||||
@@ -640,11 +640,11 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
|
||||
types->i32_ptr_type() // out
|
||||
};
|
||||
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_utf8",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_utf8",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_utf8));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_utf8));
|
||||
|
||||
// gdv_fn_hash_sha128_from_binary
|
||||
// gdv_fn_sha1_from_binary
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i8_ptr_type(), // const char*
|
||||
@@ -653,9 +653,9 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
|
||||
types->i32_ptr_type() // out
|
||||
};
|
||||
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_binary",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_binary",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_binary));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_binary));
|
||||
|
||||
// gdv_fn_sha256_int8
|
||||
args = {
|
||||
@@ -848,7 +848,7 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha256_binary));
|
||||
|
||||
// gdv_fn_sha128_decimal128
|
||||
// gdv_fn_sha1_decimal128
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i64_type(), // high_bits
|
||||
@@ -859,9 +859,9 @@ void ExportedStubFunctions::AddMappings(Engine* engine) const {
|
||||
types->i32_ptr_type() // out length
|
||||
};
|
||||
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_decimal128",
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha1_decimal128",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_decimal128));
|
||||
reinterpret_cast<void *>(gdv_fn_sha1_decimal128));
|
||||
// gdv_fn_sha256_decimal128
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
|
||||
@@ -71,9 +71,9 @@ const char* gdv_fn_sha256_decimal128(int64_t context, int64_t x_high, uint64_t x
|
||||
int32_t x_precision, int32_t x_scale,
|
||||
gdv_boolean x_isvalid, int32_t *out_length);
|
||||
|
||||
const char* gdv_fn_sha128_decimal128(int64_t context, int64_t x_high, uint64_t x_low,
|
||||
int32_t x_precision, int32_t x_scale,
|
||||
gdv_boolean x_isvalid, int32_t *out_length);
|
||||
const char* gdv_fn_sha1_decimal128(int64_t context, int64_t x_high, uint64_t x_low,
|
||||
int32_t x_precision, int32_t x_scale,
|
||||
gdv_boolean x_isvalid, int32_t *out_length);
|
||||
|
||||
int32_t gdv_fn_dec_from_string(int64_t context, const char* in, int32_t in_length,
|
||||
int32_t* precision_from_str, int32_t* scale_from_str,
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace gandiva {
|
||||
return HashUtils::GetHash(context, message, message_length, EVP_sha256(),
|
||||
sha256_result_length, out_length);
|
||||
}
|
||||
const char* HashUtils::HashUsingSha128(int64_t context,
|
||||
const void* message,
|
||||
size_t message_length,
|
||||
int32_t *out_length) {
|
||||
const char* HashUtils::HashUsingSha1(int64_t context,
|
||||
const void* message,
|
||||
size_t message_length,
|
||||
int32_t *out_length) {
|
||||
// The buffer size is the hash size + null character
|
||||
int sha128_result_length = 40;
|
||||
int sha1_result_length = 40;
|
||||
return HashUtils::GetHash(context, message, message_length, EVP_sha1(),
|
||||
sha128_result_length, out_length);
|
||||
sha1_result_length, out_length);
|
||||
}
|
||||
|
||||
const char* HashUtils::GetHash(int64_t context,
|
||||
|
||||
@@ -31,10 +31,10 @@ class GANDIVA_EXPORT HashUtils {
|
||||
size_t message_length,
|
||||
int32_t *out_length);
|
||||
|
||||
static const char *HashUsingSha128(int64_t context,
|
||||
const void *message,
|
||||
size_t message_length,
|
||||
int32_t *out_length);
|
||||
static const char *HashUsingSha1(int64_t context,
|
||||
const void *message,
|
||||
size_t message_length,
|
||||
int32_t *out_length);
|
||||
|
||||
static uint64_t DoubleToLong(double value);
|
||||
private:
|
||||
|
||||
@@ -1136,11 +1136,11 @@ TEST_F(TestDecimal, TestSha) {
|
||||
auto res_1 = field("res1", utf8());
|
||||
|
||||
// build expressions.
|
||||
// hashSHA128(a)
|
||||
// hashSHA1(a)
|
||||
auto node_a = TreeExprBuilder::MakeField(field_a);
|
||||
auto hashSha128 = TreeExprBuilder::MakeFunction("hashSHA128",
|
||||
{node_a}, utf8());
|
||||
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha128, res_0);
|
||||
auto hashSha1 = TreeExprBuilder::MakeFunction("hashSHA1",
|
||||
{node_a}, utf8());
|
||||
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha1, res_0);
|
||||
|
||||
auto hashSha256 = TreeExprBuilder::MakeFunction("hashSHA256",
|
||||
{node_a}, utf8());
|
||||
@@ -1159,7 +1159,7 @@ TEST_F(TestDecimal, TestSha) {
|
||||
auto validity_array = {false, true, true};
|
||||
|
||||
auto array_dec = MakeArrowArrayDecimal(
|
||||
decimal_5_2, MakeDecimalVector({"3.45", "0", "0.0"}, 2),
|
||||
decimal_5_2, MakeDecimalVector({"3.45", "0", "0.01"}, 2),
|
||||
validity_array);
|
||||
|
||||
// prepare input record batch
|
||||
@@ -1173,21 +1173,30 @@ TEST_F(TestDecimal, TestSha) {
|
||||
|
||||
auto response = outputs.at(0);
|
||||
EXPECT_EQ(response->null_count(), 0);
|
||||
EXPECT_EQ(response->GetScalar(0).ValueOrDie()->ToString(), "");
|
||||
for (int i = 2; i < num_records; ++i) {
|
||||
const auto &value_at_position = response->GetScalar(i).ValueOrDie()->ToString();
|
||||
EXPECT_EQ(value_at_position,
|
||||
EXPECT_NE(response->GetScalar(0).ValueOrDie()->ToString(), "");
|
||||
|
||||
// Checks if the hash size in response is correct
|
||||
const int sha1_hash_size = 40;
|
||||
for (int i = 1; i < num_records; ++i) {
|
||||
const auto& value_at_position = response->GetScalar(i).ValueOrDie()->ToString();
|
||||
|
||||
EXPECT_EQ(value_at_position.size(), sha1_hash_size);
|
||||
EXPECT_NE(value_at_position,
|
||||
response->GetScalar(i - 1).ValueOrDie()->ToString());
|
||||
}
|
||||
|
||||
response = outputs.at(1);
|
||||
EXPECT_EQ(response->null_count(), 0);
|
||||
EXPECT_EQ(response->GetScalar(0).ValueOrDie()->ToString(), "");
|
||||
for (int i = 2; i < num_records; ++i) {
|
||||
const auto &value_at_position = response->GetScalar(i).ValueOrDie()->ToString();
|
||||
EXPECT_EQ(value_at_position,
|
||||
EXPECT_NE(response->GetScalar(0).ValueOrDie()->ToString(), "");
|
||||
|
||||
// Checks if the hash size in response is correct
|
||||
const int sha256_hash_size = 64;
|
||||
for (int i = 1; i < num_records; ++i) {
|
||||
const auto& value_at_position = response->GetScalar(i).ValueOrDie()->ToString();
|
||||
|
||||
EXPECT_EQ(value_at_position.size(), sha256_hash_size);
|
||||
EXPECT_NE(value_at_position,
|
||||
response->GetScalar(i - 1).ValueOrDie()->ToString());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace gandiva
|
||||
@@ -313,26 +313,26 @@ TEST_F(TestHash, TestSha1Simple) {
|
||||
auto res_3 = field("res3", utf8());
|
||||
|
||||
// build expressions.
|
||||
// hashSHA128(a)
|
||||
// hashSHA1(a)
|
||||
auto node_a = TreeExprBuilder::MakeField(field_a);
|
||||
auto hashSha128_1 = TreeExprBuilder::MakeFunction("hashSHA128",
|
||||
{node_a}, utf8());
|
||||
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha128_1, res_0);
|
||||
auto hashSha1_1 = TreeExprBuilder::MakeFunction("hashSHA1",
|
||||
{node_a}, utf8());
|
||||
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha1_1, res_0);
|
||||
|
||||
auto node_b = TreeExprBuilder::MakeField(field_b);
|
||||
auto hashSha128_2 = TreeExprBuilder::MakeFunction("hashSHA128",
|
||||
{node_b}, utf8());
|
||||
auto expr_1 = TreeExprBuilder::MakeExpression(hashSha128_2, res_1);
|
||||
auto hashSha1_2 = TreeExprBuilder::MakeFunction("hashSHA1",
|
||||
{node_b}, utf8());
|
||||
auto expr_1 = TreeExprBuilder::MakeExpression(hashSha1_2, res_1);
|
||||
|
||||
auto node_c = TreeExprBuilder::MakeField(field_c);
|
||||
auto hashSha128_3 = TreeExprBuilder::MakeFunction("hashSHA128",
|
||||
{node_c}, utf8());
|
||||
auto expr_2 = TreeExprBuilder::MakeExpression(hashSha128_3, res_2);
|
||||
auto hashSha1_3 = TreeExprBuilder::MakeFunction("hashSHA1",
|
||||
{node_c}, utf8());
|
||||
auto expr_2 = TreeExprBuilder::MakeExpression(hashSha1_3, res_2);
|
||||
|
||||
auto node_d = TreeExprBuilder::MakeField(field_d);
|
||||
auto hashSha128_4 = TreeExprBuilder::MakeFunction("hashSHA128",
|
||||
{node_d}, utf8());
|
||||
auto expr_3 = TreeExprBuilder::MakeExpression(hashSha128_4, res_3);
|
||||
auto hashSha1_4 = TreeExprBuilder::MakeFunction("hashSHA1",
|
||||
{node_d}, utf8());
|
||||
auto expr_3 = TreeExprBuilder::MakeExpression(hashSha1_4, res_3);
|
||||
|
||||
// Build a projector for the expressions.
|
||||
std::shared_ptr<Projector> projector;
|
||||
@@ -398,11 +398,11 @@ TEST_F(TestHash, TestSha1Varlen) {
|
||||
auto res_0 = field("res0", utf8());
|
||||
|
||||
// build expressions.
|
||||
// hashSHA128(a)
|
||||
// hashSHA1(a)
|
||||
auto node_a = TreeExprBuilder::MakeField(field_a);
|
||||
auto hashSha128 = TreeExprBuilder::MakeFunction("hashSHA128",
|
||||
{node_a}, utf8());
|
||||
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha128, res_0);
|
||||
auto hashSha1 = TreeExprBuilder::MakeFunction("hashSHA1",
|
||||
{node_a}, utf8());
|
||||
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha1, res_0);
|
||||
|
||||
// Build a projector for the expressions.
|
||||
std::shared_ptr<Projector> projector;
|
||||
|
||||
Reference in new issue
Block a user