mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
Add base sha128 method definition on globall mapper for gandiva function stubs
This commit is contained in:
1 parent
56ca07d7d1
commit
821260bf6a
1 file changed
+228
-13
@@ -29,7 +29,6 @@
|
||||
#include "gandiva/random_generator_holder.h"
|
||||
#include "gandiva/to_date_holder.h"
|
||||
|
||||
|
||||
/// Stub functions that can be accessed from LLVM or the pre-compiled library.
|
||||
|
||||
extern "C" {
|
||||
@@ -124,6 +123,40 @@ int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SHA128_HASH_FUNCTION(TYPE) \
|
||||
GANDIVA_EXPORT \
|
||||
const char *gdv_fn_sha128_from_##TYPE(int64_t context, gdv_##TYPE value, \
|
||||
bool validity, u_int32_t *out_length) { \
|
||||
if(!validity){ \
|
||||
*out_length = 0; \
|
||||
return ""; \
|
||||
} \
|
||||
\
|
||||
auto value_as_long = gandiva::HashUtils::double_to_long((double)value); \
|
||||
\
|
||||
const char *result = gandiva::HashUtils::hash_using_SHA128(context, \
|
||||
&value_as_long, \
|
||||
sizeof(value_as_long), \
|
||||
out_length); \
|
||||
\
|
||||
return result; \
|
||||
} \
|
||||
|
||||
#define SHA128_HASH_FUNCTION_BUF(TYPE) \
|
||||
GANDIVA_EXPORT \
|
||||
const char *gdv_fn_sha128_from_##TYPE(int64_t context, \
|
||||
gdv_##TYPE value, \
|
||||
int32_t value_length, \
|
||||
bool value_validity, \
|
||||
u_int32_t *out_length) { \
|
||||
if(!value_validity){ \
|
||||
*out_length = 0; \
|
||||
return ""; \
|
||||
} \
|
||||
\
|
||||
return gandiva::HashUtils::hash_using_SHA128(context, value, value_length, out_length); \
|
||||
}
|
||||
|
||||
#define SHA256_HASH_FUNCTION(TYPE) \
|
||||
GANDIVA_EXPORT \
|
||||
const char *gdv_fn_sha256_from_##TYPE(int64_t context, gdv_##TYPE value, \
|
||||
@@ -158,18 +191,6 @@ int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,
|
||||
return gandiva::HashUtils::hash_using_SHA256(context, value, value_length, out_length); \
|
||||
}
|
||||
|
||||
GANDIVA_EXPORT
|
||||
const char* gdv_fn_sha128_from_numeric(int64_t context, double value){
|
||||
uint64_t value_as_long = gandiva::HashUtils::double_to_long(value);
|
||||
|
||||
return gandiva::HashUtils::hash_using_SHA128(context, &value_as_long, sizeof(value_as_long), nullptr);
|
||||
}
|
||||
|
||||
GANDIVA_EXPORT
|
||||
const char* gdv_fn_hash_sha128_from_string(int64_t context, const char* value, uint64_t value_length){
|
||||
return gandiva::HashUtils::hash_using_SHA128(context, value, value_length, nullptr);
|
||||
}
|
||||
|
||||
// Expand inner macro for all numeric types.
|
||||
#define NUMERIC_BOOL_DATE_TYPES(INNER) \
|
||||
INNER(int8) \
|
||||
@@ -198,6 +219,9 @@ const char* gdv_fn_hash_sha128_from_string(int64_t context, const char* value, u
|
||||
NUMERIC_BOOL_DATE_TYPES(SHA256_HASH_FUNCTION)
|
||||
VAR_LEN_TYPES(SHA256_HASH_FUNCTION_BUF)
|
||||
|
||||
NUMERIC_BOOL_DATE_TYPES(SHA128_HASH_FUNCTION)
|
||||
VAR_LEN_TYPES(SHA128_HASH_FUNCTION_BUF)
|
||||
|
||||
#undef NUMERIC_BOOL_DATE_TYPES
|
||||
#undef VAR_LEN_TYPES
|
||||
|
||||
@@ -417,6 +441,197 @@ 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_from_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_from_int8",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_int8));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_int16",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_int16));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_int32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_int32));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_int64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_int64));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_uint8",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_uint8));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_uint16",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_uint16));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_uint32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_uint32));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_uint64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_uint64));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_float32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_float32));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_float64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_float64));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_boolean",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_boolean));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_date64",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_date64));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_date32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_date32));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_time32",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_time32));
|
||||
|
||||
// gdv_fn_sha128_from_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_from_timestamp",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_timestamp));
|
||||
|
||||
// gdv_fn_hash_sha128_from_utf8
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i8_ptr_type(), // const char*
|
||||
types->i32_type(), // value_length
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out
|
||||
};
|
||||
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_from_utf8",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_utf8));
|
||||
|
||||
// gdv_fn_hash_sha128_from_binary
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
types->i8_ptr_type(), // const char*
|
||||
types->i32_type(), // value_length
|
||||
types->i1_type(), // validity
|
||||
types->i32_ptr_type() // out
|
||||
};
|
||||
|
||||
engine->AddGlobalMappingForFunc("gdv_fn_sha128_from_binary",
|
||||
types->i8_ptr_type() /*return_type*/, args,
|
||||
reinterpret_cast<void *>(gdv_fn_sha128_from_binary));
|
||||
|
||||
// gdv_fn_sha256_from_int8
|
||||
args = {
|
||||
types->i64_type(), // context
|
||||
|
||||
Reference in new issue
Block a user