Fix formating problems

This commit is contained in:
Anthony Louis committed 2021-04-09 19:34:24 -03:00
1 parent 826d1cb08b
commit 8f95d4583f
9 files changed
+631 -708

No files matched your search

+4 -2
View File
@@ -92,7 +92,8 @@ set(SRC_FILES
random_generator_holder.cc
${GANDIVA_PRECOMPILED_CC_PATH})
set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS})
set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE
${GANDIVA_OPENSSL_LIBS})
set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS})
@@ -207,7 +208,8 @@ endfunction()
set(GANDIVA_INTERNALS_TEST_ARGUMENTS)
if(WIN32)
list(APPEND GANDIVA_INTERNALS_TEST_ARGUMENTS EXTRA_LINK_LIBS LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS})
list(APPEND GANDIVA_INTERNALS_TEST_ARGUMENTS EXTRA_LINK_LIBS LLVM::LLVM_INTERFACE
${GANDIVA_OPENSSL_LIBS})
endif()
add_gandiva_test(internals-test
SOURCES
+6 -8
View File
@@ -213,10 +213,9 @@ typedef std::unordered_map<const FunctionSignature*, const NativeFunction*, KeyH
// - can return errors
//
// 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_sha1_##TYPE), \
#define HASH_SHA1_NULL_NEVER(NAME, ALIASES, TYPE) \
NativeFunction(#NAME, std::vector<std::string> ALIASES, DataTypeVector{TYPE()}, \
utf8(), kResultNullNever, ARROW_STRINGIFY(gdv_fn_sha1_##TYPE), \
NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors)
// HashSHA256 functions that :
@@ -224,10 +223,9 @@ typedef std::unordered_map<const FunctionSignature*, const NativeFunction*, KeyH
// - can return errors
//
// The function name includes the base name & input type name. gdv_fn_sha256_float64
#define HASH_SHA256_NULL_NEVER(NAME, ALIASES, TYPE) \
NativeFunction(#NAME, std::vector<std::string> ALIASES, \
DataTypeVector{TYPE()}, utf8(), kResultNullNever, \
ARROW_STRINGIFY(gdv_fn_sha256_##TYPE), \
#define HASH_SHA256_NULL_NEVER(NAME, ALIASES, TYPE) \
NativeFunction(#NAME, std::vector<std::string> ALIASES, DataTypeVector{TYPE()}, \
utf8(), kResultNullNever, ARROW_STRINGIFY(gdv_fn_sha256_##TYPE), \
NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors)
// Iterate the inner macro over all numeric types
+338 -356
View File
@@ -21,9 +21,9 @@
#include <vector>
#include "arrow/util/value_parsing.h"
#include "gandiva/hash_utils.h"
#include "gandiva/engine.h"
#include "gandiva/exported_funcs.h"
#include "gandiva/hash_utils.h"
#include "gandiva/in_holder.h"
#include "gandiva/like_holder.h"
#include "gandiva/random_generator_holder.h"
@@ -123,95 +123,79 @@ int32_t gdv_fn_populate_varlen_vector(int64_t context_ptr, int8_t* data_ptr,
return 0;
}
#define SHA1_HASH_FUNCTION(TYPE) \
GANDIVA_EXPORT \
const char *gdv_fn_sha1_##TYPE(int64_t context, gdv_##TYPE value, \
bool validity, int32_t *out_length) { \
if (!validity) { \
return gandiva::gdv_hash_using_sha1(context, NULLPTR, \
0, out_length); \
} \
auto value_as_long = gandiva::gdv_double_to_long((double)value); \
const char *result = gandiva::gdv_hash_using_sha1(context, \
&value_as_long, \
sizeof(value_as_long), \
out_length); \
\
return result; \
} \
#define SHA1_HASH_FUNCTION(TYPE) \
GANDIVA_EXPORT \
const char* gdv_fn_sha1_##TYPE(int64_t context, gdv_##TYPE value, bool validity, \
int32_t* out_length) { \
if (!validity) { \
return gandiva::gdv_hash_using_sha1(context, NULLPTR, 0, out_length); \
} \
auto value_as_long = gandiva::gdv_double_to_long((double)value); \
const char* result = gandiva::gdv_hash_using_sha1( \
context, &value_as_long, sizeof(value_as_long), out_length); \
\
return result; \
}
#define SHA1_HASH_FUNCTION_BUF(TYPE) \
GANDIVA_EXPORT \
const char *gdv_fn_sha1_##TYPE(int64_t context, \
gdv_##TYPE value, \
int32_t value_length, \
bool value_validity, \
int32_t *out_length) { \
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::gdv_hash_using_sha1(context, NULLPTR, \
0, out_length); \
return gandiva::gdv_hash_using_sha1(context, NULLPTR, 0, out_length); \
} \
return gandiva::gdv_hash_using_sha1(context, value, \
value_length, out_length); \
return gandiva::gdv_hash_using_sha1(context, value, value_length, out_length); \
}
#define SHA256_HASH_FUNCTION(TYPE) \
GANDIVA_EXPORT \
const char *gdv_fn_sha256_##TYPE(int64_t context, gdv_##TYPE value, \
bool validity, int32_t *out_length) { \
if (!validity) { \
return gandiva::gdv_hash_using_sha256(context, NULLPTR, \
0, out_length); \
} \
auto value_as_long = gandiva::gdv_double_to_long((double)value); \
const char *result = gandiva::gdv_hash_using_sha256(context, \
&value_as_long, \
sizeof(value_as_long), \
out_length); \
return result; \
} \
#define SHA256_HASH_FUNCTION(TYPE) \
GANDIVA_EXPORT \
const char* gdv_fn_sha256_##TYPE(int64_t context, gdv_##TYPE value, bool validity, \
int32_t* out_length) { \
if (!validity) { \
return gandiva::gdv_hash_using_sha256(context, NULLPTR, 0, out_length); \
} \
auto value_as_long = gandiva::gdv_double_to_long((double)value); \
const char* result = gandiva::gdv_hash_using_sha256( \
context, &value_as_long, sizeof(value_as_long), out_length); \
return result; \
}
#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 *out_length) { \
if (!value_validity) { \
return gandiva::gdv_hash_using_sha256(context, NULLPTR, \
0, out_length); \
} \
\
return gandiva::gdv_hash_using_sha256(context, value, \
value_length, out_length); \
#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* out_length) { \
if (!value_validity) { \
return gandiva::gdv_hash_using_sha256(context, NULLPTR, 0, out_length); \
} \
\
return gandiva::gdv_hash_using_sha256(context, value, value_length, out_length); \
}
// Expand inner macro for all numeric types.
#define SHA_NUMERIC_BOOL_DATE_PARAMS(INNER) \
INNER(int8) \
INNER(int16) \
INNER(int32) \
INNER(int64) \
INNER(uint8) \
INNER(uint16) \
INNER(uint32) \
INNER(uint64) \
INNER(float32) \
INNER(float64) \
INNER(boolean) \
INNER(date64) \
INNER(date32) \
INNER(time32) \
INNER(int8) \
INNER(int16) \
INNER(int32) \
INNER(int64) \
INNER(uint8) \
INNER(uint16) \
INNER(uint32) \
INNER(uint64) \
INNER(float32) \
INNER(float64) \
INNER(boolean) \
INNER(date64) \
INNER(date32) \
INNER(time32) \
INNER(timestamp)
// Expand inner macro for all numeric types.
#define SHA_VAR_LEN_PARAMS(INNER) \
INNER(utf8) \
INNER(binary)
SHA_NUMERIC_BOOL_DATE_PARAMS(SHA256_HASH_FUNCTION)
SHA_VAR_LEN_PARAMS(SHA256_HASH_FUNCTION_BUF)
@@ -225,29 +209,27 @@ SHA_VAR_LEN_PARAMS(SHA1_HASH_FUNCTION_BUF)
GANDIVA_EXPORT
const char* gdv_fn_sha256_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) {
gdv_boolean x_isvalid, int32_t* out_length) {
if (!x_isvalid) {
return gandiva::gdv_hash_using_sha256(context, NULLPTR,
0, out_length);
return gandiva::gdv_hash_using_sha256(context, NULLPTR, 0, out_length);
}
const gandiva::BasicDecimal128 decimal_128(x_high, x_low);
return gandiva::gdv_hash_using_sha256(context, decimal_128.ToBytes().data(),
16, out_length);
return gandiva::gdv_hash_using_sha256(context, decimal_128.ToBytes().data(), 16,
out_length);
}
GANDIVA_EXPORT
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) {
gdv_boolean x_isvalid, int32_t* out_length) {
if (!x_isvalid) {
return gandiva::gdv_hash_using_sha1(context, NULLPTR,
0, out_length);
return gandiva::gdv_hash_using_sha1(context, NULLPTR, 0, out_length);
}
const gandiva::BasicDecimal128 decimal_128(x_high, x_low);
return gandiva::gdv_hash_using_sha1(context, decimal_128.ToBytes().data(),
16, out_length);
return gandiva::gdv_hash_using_sha1(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,415 +448,415 @@ 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_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_sha1_int8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_int8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_int8));
// 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_sha1_int16",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_int16",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_int16));
// 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_sha1_int32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_int32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_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_sha1_int64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_int64));
// 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_sha1_int64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_int64));
// 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_sha1_uint8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_uint8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_uint8));
// 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_sha1_uint16",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_uint16",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_uint16));
// 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_sha1_uint32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_uint32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_uint32));
// 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_sha1_uint64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_uint64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_uint64));
// 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_sha1_float32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_float32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_float32));
// 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_sha1_float64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_float64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_float64));
// 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_sha1_boolean",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_boolean",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_boolean));
// 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_sha1_date64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_date64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_date64));
// 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_sha1_date32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_date32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_date32));
// 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_sha1_time32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_time32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_time32));
// 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_sha1_timestamp",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_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_sha1_timestamp",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_timestamp));
// gdv_fn_sha1_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
};
// gdv_fn_sha1_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_sha1_utf8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_utf8));
engine->AddGlobalMappingForFunc("gdv_fn_sha1_utf8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_utf8));
// gdv_fn_sha1_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
};
// gdv_fn_sha1_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_sha1_binary",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_binary));
engine->AddGlobalMappingForFunc("gdv_fn_sha1_binary",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void*>(gdv_fn_sha1_binary));
// gdv_fn_sha256_int8
args = {
types->i64_type(), // context
types->i8_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i8_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_int8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_int8));
reinterpret_cast<void*>(gdv_fn_sha256_int8));
// gdv_fn_sha256_int16
args = {
types->i64_type(), // context
types->i16_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i16_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_int16",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_int16));
reinterpret_cast<void*>(gdv_fn_sha256_int16));
// gdv_fn_sha256_int32
args = {
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_int32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_int32));
reinterpret_cast<void*>(gdv_fn_sha256_int32));
// gdv_fn_sha256_int32
args = {
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_int64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_int64));
reinterpret_cast<void*>(gdv_fn_sha256_int64));
// gdv_fn_sha256_uint8
args = {
types->i64_type(), // context
types->i8_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i8_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_uint8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_uint8));
reinterpret_cast<void*>(gdv_fn_sha256_uint8));
// gdv_fn_sha256_uint16
args = {
types->i64_type(), // context
types->i16_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i16_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_uint16",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_uint16));
reinterpret_cast<void*>(gdv_fn_sha256_uint16));
// gdv_fn_sha256_uint32
args = {
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_uint32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_uint32));
reinterpret_cast<void*>(gdv_fn_sha256_uint32));
// gdv_fn_sha256_uint64
args = {
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_uint64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_uint64));
reinterpret_cast<void*>(gdv_fn_sha256_uint64));
// gdv_fn_sha256_float32
args = {
types->i64_type(), // context
types->float_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->float_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_float32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_float32));
reinterpret_cast<void*>(gdv_fn_sha256_float32));
// gdv_fn_sha256_float64
args = {
types->i64_type(), // context
types->double_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->double_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_float64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_float64));
reinterpret_cast<void*>(gdv_fn_sha256_float64));
// gdv_fn_sha256_boolean
args = {
types->i64_type(), // context
types->i1_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i1_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_boolean",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_boolean));
reinterpret_cast<void*>(gdv_fn_sha256_boolean));
// gdv_fn_sha256_date64
args = {
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_date64",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_date64));
reinterpret_cast<void*>(gdv_fn_sha256_date64));
// gdv_fn_sha256_date32
args = {
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_date32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_date32));
reinterpret_cast<void*>(gdv_fn_sha256_date32));
// gdv_fn_sha256_time32
args = {
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i32_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_time32",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_time32));
reinterpret_cast<void*>(gdv_fn_sha256_time32));
// gdv_fn_sha256_timestamp
args = {
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
types->i64_type(), // context
types->i64_type(), // value
types->i1_type(), // validity
types->i32_ptr_type() // out_length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_timestamp",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_timestamp));
reinterpret_cast<void*>(gdv_fn_sha256_timestamp));
// gdv_fn_hash_sha256_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
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_sha256_utf8",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_utf8));
reinterpret_cast<void*>(gdv_fn_sha256_utf8));
// gdv_fn_hash_sha256_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
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_sha256_binary",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_binary));
reinterpret_cast<void*>(gdv_fn_sha256_binary));
// gdv_fn_sha1_decimal128
args = {
types->i64_type(), // context
types->i64_type(), // high_bits
types->i64_type(), // low_bits
types->i32_type(), // precision
types->i32_type(), // scale
types->i1_type(), // validity
types->i32_ptr_type() // out length
types->i64_type(), // context
types->i64_type(), // high_bits
types->i64_type(), // low_bits
types->i32_type(), // precision
types->i32_type(), // scale
types->i1_type(), // validity
types->i32_ptr_type() // out length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha1_decimal128",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha1_decimal128));
reinterpret_cast<void*>(gdv_fn_sha1_decimal128));
// gdv_fn_sha256_decimal128
args = {
types->i64_type(), // context
types->i64_type(), // high_bits
types->i64_type(), // low_bits
types->i32_type(), // precision
types->i32_type(), // scale
types->i1_type(), // validity
types->i32_ptr_type() // out length
types->i64_type(), // context
types->i64_type(), // high_bits
types->i64_type(), // low_bits
types->i32_type(), // precision
types->i32_type(), // scale
types->i1_type(), // validity
types->i32_ptr_type() // out length
};
engine->AddGlobalMappingForFunc("gdv_fn_sha256_decimal128",
types->i8_ptr_type() /*return_type*/, args,
reinterpret_cast<void *>(gdv_fn_sha256_decimal128));
reinterpret_cast<void*>(gdv_fn_sha256_decimal128));
}
} // namespace gandiva
+2 -2
View File
@@ -70,12 +70,12 @@ int gdv_fn_time_with_zone(int* time_fields, const char* zone, int zone_len,
GANDIVA_EXPORT
const char* gdv_fn_sha256_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);
gdv_boolean x_isvalid, int32_t* out_length);
GANDIVA_EXPORT
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);
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,
+95 -104
View File
@@ -15,126 +15,117 @@
// specific language governing permissions and limitations
// under the License.
#include <cstring>
#include "openssl/evp.h"
#include "gandiva/hash_utils.h"
#include "gandiva/gdv_function_stubs.h"
#include <cstring>
#include "arrow/util/logging.h"
#include "gandiva/gdv_function_stubs.h"
#include "openssl/evp.h"
namespace gandiva {
/// Hashes a generic message using the SHA256 algorithm
const char* gdv_hash_using_sha256(int64_t context,
const void* message,
size_t message_length,
int32_t *out_length) {
constexpr int sha256_result_length = 64;
return gdv_hash_using_sha(context, message, message_length, EVP_sha256(),
sha256_result_length, out_length);
/// Hashes a generic message using the SHA256 algorithm
const char* gdv_hash_using_sha256(int64_t context, const void* message,
size_t message_length, int32_t* out_length) {
constexpr int sha256_result_length = 64;
return gdv_hash_using_sha(context, message, message_length, EVP_sha256(),
sha256_result_length, out_length);
}
/// Hashes a generic message using the SHA1 algorithm
const char* gdv_hash_using_sha1(int64_t context, const void* message,
size_t message_length, int32_t* out_length) {
constexpr int sha1_result_length = 40;
return gdv_hash_using_sha(context, message, message_length, EVP_sha1(),
sha1_result_length, out_length);
}
/// \brief Hashes a generic message using SHA algorithm.
///
/// It uses the EVP API in the OpenSSL library to generate
/// the hash. The type of the hash is defined by the
/// \b hash_type \b parameter.
const char* gdv_hash_using_sha(int64_t context, const void* message,
size_t message_length, const EVP_MD* hash_type,
uint32_t result_buf_size, int32_t* out_length) {
EVP_MD_CTX* md_ctx = EVP_MD_CTX_new();
if (md_ctx == nullptr) {
gdv_fn_context_set_error_msg(context,
"Could not create the context for SHA processing.");
*out_length = 0;
return "";
}
int evp_success_status = 1;
/// Hashes a generic message using the SHA1 algorithm
const char* gdv_hash_using_sha1(int64_t context,
const void* message,
size_t message_length,
int32_t *out_length) {
constexpr int sha1_result_length = 40;
return gdv_hash_using_sha(context, message, message_length, EVP_sha1(),
sha1_result_length, out_length);
if (EVP_DigestInit_ex(md_ctx, hash_type, nullptr) != evp_success_status ||
EVP_DigestUpdate(md_ctx, message, message_length) != evp_success_status) {
gdv_fn_context_set_error_msg(context,
"Could not obtain the hash for the defined value.");
EVP_MD_CTX_free(md_ctx);
*out_length = 0;
return "";
}
/// \brief Hashes a generic message using SHA algorithm.
///
/// It uses the EVP API in the OpenSSL library to generate
/// the hash. The type of the hash is defined by the
/// \b hash_type \b parameter.
const char* gdv_hash_using_sha(int64_t context,
const void* message,
size_t message_length,
const EVP_MD *hash_type,
uint32_t result_buf_size,
int32_t *out_length) {
EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
// Create the temporary buffer used by the EVP to generate the hash
unsigned int hash_digest_size = EVP_MD_size(hash_type);
auto* result = static_cast<unsigned char*>(OPENSSL_malloc(hash_digest_size));
if (md_ctx == nullptr) {
gdv_fn_context_set_error_msg(context,
"Could not create the context for SHA processing.");
*out_length = 0;
return "";
}
if (result == nullptr) {
gdv_fn_context_set_error_msg(context, "Could not allocate memory for SHA processing");
EVP_MD_CTX_free(md_ctx);
*out_length = 0;
return "";
}
int evp_success_status = 1;
unsigned int result_length;
EVP_DigestFinal_ex(md_ctx, result, &result_length);
if (EVP_DigestInit_ex(md_ctx, hash_type, nullptr) != evp_success_status ||
EVP_DigestUpdate(md_ctx, message, message_length) != evp_success_status) {
gdv_fn_context_set_error_msg(context,
"Could not obtain the hash for the defined value.");
EVP_MD_CTX_free(md_ctx);
*out_length = 0;
return "";
}
// Create the temporary buffer used by the EVP to generate the hash
unsigned int hash_digest_size = EVP_MD_size(hash_type);
auto* result = static_cast<unsigned char*>(OPENSSL_malloc(hash_digest_size));
if (result == nullptr) {
gdv_fn_context_set_error_msg(context,
"Could not allocate memory for SHA processing");
EVP_MD_CTX_free(md_ctx);
*out_length = 0;
return "";
}
unsigned int result_length;
EVP_DigestFinal_ex(md_ctx, result, &result_length);
if(result_length != hash_digest_size &&
result_buf_size != (2 * hash_digest_size)){
gdv_fn_context_set_error_msg(context,
"Could not obtain the hash for the defined value");
EVP_MD_CTX_free(md_ctx);
OPENSSL_free(result);
*out_length = 0;
return "";
}
auto result_buffer =
reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, result_buf_size));
if (result_buffer == nullptr) {
gdv_fn_context_set_error_msg(context,
"Could not allocate memory for the result buffer");
// Free the resources used by the EVP
EVP_MD_CTX_free(md_ctx);
OPENSSL_free(result);
*out_length = 0;
return "";
}
unsigned int result_buff_index = 0;
for (unsigned int j = 0; j < result_length; j++) {
DCHECK(result_buff_index >= 0 && result_buff_index < result_buf_size);
unsigned char hex_number = result[j];
result_buff_index += snprintf(result_buffer + result_buff_index,
3, "%02x", hex_number);
}
// Free the resources used by the EVP to avoid memory leaks
if (result_length != hash_digest_size && result_buf_size != (2 * hash_digest_size)) {
gdv_fn_context_set_error_msg(context,
"Could not obtain the hash for the defined value");
EVP_MD_CTX_free(md_ctx);
OPENSSL_free(result);
*out_length = result_buf_size;
return result_buffer;
*out_length = 0;
return "";
}
uint64_t gdv_double_to_long(double value) {
uint64_t result;
memcpy(&result, &value, sizeof(result));
return result;
auto result_buffer =
reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, result_buf_size));
if (result_buffer == nullptr) {
gdv_fn_context_set_error_msg(context,
"Could not allocate memory for the result buffer");
// Free the resources used by the EVP
EVP_MD_CTX_free(md_ctx);
OPENSSL_free(result);
*out_length = 0;
return "";
}
unsigned int result_buff_index = 0;
for (unsigned int j = 0; j < result_length; j++) {
DCHECK(result_buff_index >= 0 && result_buff_index < result_buf_size);
unsigned char hex_number = result[j];
char* next_pos_to_write = result_buffer + result_buff_index;
result_buff_index +=
snprintf(next_pos_to_write, sizeof(next_pos_to_write), "%02x", hex_number);
}
// Free the resources used by the EVP to avoid memory leaks
EVP_MD_CTX_free(md_ctx);
OPENSSL_free(result);
*out_length = result_buf_size;
return result_buffer;
}
uint64_t gdv_double_to_long(double value) {
uint64_t result;
memcpy(&result, &value, sizeof(result));
return result;
}
} // namespace gandiva
+9 -16
View File
@@ -18,31 +18,24 @@
#ifndef ARROW_SRC_HASH_UTILS_H_
#define ARROW_SRC_HASH_UTILS_H_
#include <cstdlib>
#include <cstdint>
#include <cstdlib>
#include "gandiva/visibility.h"
#include "openssl/evp.h"
namespace gandiva {
const char* gdv_hash_using_sha256(int64_t context,
const void* message,
size_t message_length,
int32_t *out_length);
const char* gdv_hash_using_sha256(int64_t context, const void* message,
size_t message_length, int32_t* out_length);
const char* gdv_hash_using_sha1(int64_t context,
const void* message,
size_t message_length,
int32_t *out_length);
const char* gdv_hash_using_sha1(int64_t context, const void* message,
size_t message_length, int32_t* out_length);
const char* gdv_hash_using_sha(int64_t context,
const void* message,
size_t message_length,
const EVP_MD *hash_type,
uint32_t result_buf_size,
int32_t *out_length);
const char* gdv_hash_using_sha(int64_t context, const void* message,
size_t message_length, const EVP_MD* hash_type,
uint32_t result_buf_size, int32_t* out_length);
uint64_t gdv_double_to_long(double value);
} // namespace gandiva
#endif //ARROW_SRC_HASH_UTILS_H_
#endif // ARROW_SRC_HASH_UTILS_H_
+43 -52
View File
@@ -18,10 +18,8 @@
#include <gtest/gtest.h>
#include <unordered_set>
#include "gandiva/hash_utils.h"
#include "gandiva/execution_context.h"
using namespace gandiva;
#include "gandiva/hash_utils.h"
TEST(TestShaHashUtils, TestSha1Numeric) {
gandiva::ExecutionContext ctx;
@@ -31,14 +29,14 @@ TEST(TestShaHashUtils, TestSha1Numeric) {
std::vector<double> values_to_be_hashed;
// Generate a list of values to obtains the SHA1 hash
values_to_be_hashed.push_back(gdv_double_to_long(0.0));
values_to_be_hashed.push_back(gdv_double_to_long(0.1));
values_to_be_hashed.push_back(gdv_double_to_long(0.2));
values_to_be_hashed.push_back(gdv_double_to_long(-0.10000001));
values_to_be_hashed.push_back(gdv_double_to_long(-0.0000001));
values_to_be_hashed.push_back(gdv_double_to_long(1.000000));
values_to_be_hashed.push_back(gdv_double_to_long(-0.0000002));
values_to_be_hashed.push_back(gdv_double_to_long(0.999999));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.0));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.1));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.2));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.10000001));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.0000001));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(1.000000));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.0000002));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.999999));
// Checks if the hash value is different for each one of the values
std::unordered_set<std::string> sha_values;
@@ -47,8 +45,8 @@ TEST(TestShaHashUtils, TestSha1Numeric) {
for (auto value : values_to_be_hashed) {
int out_length;
const char *sha_1 = gdv_hash_using_sha1(ctx_ptr, &value, sizeof(value),
&out_length);
const char* sha_1 =
gandiva::gdv_hash_using_sha1(ctx_ptr, &value, sizeof(value), &out_length);
std::string sha1_as_str(sha_1, out_length);
EXPECT_EQ(sha1_as_str.size(), sha1_size);
@@ -66,24 +64,24 @@ TEST(TestShaHashUtils, TestSha256Numeric) {
std::vector<double> values_to_be_hashed;
// Generate a list of values to obtains the SHA1 hash
values_to_be_hashed.push_back(gdv_double_to_long(0.0));
values_to_be_hashed.push_back(gdv_double_to_long(0.1));
values_to_be_hashed.push_back(gdv_double_to_long(0.2));
values_to_be_hashed.push_back(gdv_double_to_long(-0.10000001));
values_to_be_hashed.push_back(gdv_double_to_long(-0.0000001));
values_to_be_hashed.push_back(gdv_double_to_long(1.000000));
values_to_be_hashed.push_back(gdv_double_to_long(-0.0000002));
values_to_be_hashed.push_back(gdv_double_to_long(0.999999));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.0));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.1));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.2));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.10000001));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.0000001));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(1.000000));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(-0.0000002));
values_to_be_hashed.push_back(gandiva::gdv_double_to_long(0.999999));
// Checks if the hash value is different for each one of the values
std::unordered_set<std::string> sha_values;
int sha256_size = 64;
for(auto value : values_to_be_hashed){
for (auto value : values_to_be_hashed) {
int out_length;
const char *sha_256 = gdv_hash_using_sha256(ctx_ptr, &value, sizeof(value),
&out_length);
const char* sha_256 =
gandiva::gdv_hash_using_sha256(ctx_ptr, &value, sizeof(value), &out_length);
std::string sha256_as_str(sha_256, out_length);
EXPECT_EQ(sha256_as_str.size(), sha256_size);
@@ -98,35 +96,31 @@ TEST(TestShaHashUtils, TestSha1Varlen) {
auto ctx_ptr = reinterpret_cast<int64_t>(&ctx);
std::string first_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string first_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string second_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
std::string second_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
// The strings expected hashes are obtained from shell executing the following command:
// echo -n <output-string> | openssl dgst sha1
std::string expected_first_result = "160fcdbc2fa694d884868f5fae7a4bae82706185";
std::string expected_second_result = "a456b3e0f88669d2482170a42fade226a815bee1";
// Generate the hashes and compare with expected outputs
const int sha1_size = 40;
int out_length;
const char *sha_1 = gdv_hash_using_sha1(ctx_ptr,
first_string.c_str(),
first_string.size(),
&out_length);
const char* sha_1 = gandiva::gdv_hash_using_sha1(ctx_ptr, first_string.c_str(),
first_string.size(), &out_length);
std::string sha1_as_str(sha_1, out_length);
EXPECT_EQ(sha1_as_str.size(), sha1_size);
EXPECT_EQ(sha1_as_str, expected_first_result);
const char *sha_2 = gdv_hash_using_sha1(ctx_ptr,
second_string.c_str(),
second_string.size(),
&out_length);
const char* sha_2 = gandiva::gdv_hash_using_sha1(ctx_ptr, second_string.c_str(),
second_string.size(), &out_length);
std::string sha2_as_str(sha_2, out_length);
EXPECT_EQ(sha2_as_str.size(), sha1_size);
EXPECT_EQ(sha2_as_str, expected_second_result);
@@ -137,12 +131,13 @@ TEST(TestShaHashUtils, TestSha256Varlen) {
auto ctx_ptr = reinterpret_cast<int64_t>(&ctx);
std::string first_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string first_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string second_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
std::string second_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
// The strings expected hashes are obtained from shell executing the following command:
// echo -n <output-string> | openssl dgst sha1
@@ -155,19 +150,15 @@ TEST(TestShaHashUtils, TestSha256Varlen) {
const int sha256_size = 64;
int out_length;
const char *sha_1 = gdv_hash_using_sha256(ctx_ptr,
first_string.c_str(),
first_string.size(),
&out_length);
const char* sha_1 = gandiva::gdv_hash_using_sha256(ctx_ptr, first_string.c_str(),
first_string.size(), &out_length);
std::string sha1_as_str(sha_1, out_length);
EXPECT_EQ(sha1_as_str.size(), sha256_size);
EXPECT_EQ(sha1_as_str, expected_first_result);
const char *sha_2 = gdv_hash_using_sha256(ctx_ptr,
second_string.c_str(),
second_string.size(),
&out_length);
const char* sha_2 = gandiva::gdv_hash_using_sha256(ctx_ptr, second_string.c_str(),
second_string.size(), &out_length);
std::string sha2_as_str(sha_2, out_length);
EXPECT_EQ(sha2_as_str.size(), sha256_size);
EXPECT_EQ(sha2_as_str, expected_second_result);
}
}
+8 -16
View File
@@ -1127,7 +1127,7 @@ TEST_F(TestDecimal, TestCastDecimalOverflow) {
TEST_F(TestDecimal, TestSha) {
// schema for input fields
const std::shared_ptr<arrow::DataType> &decimal_5_2 = arrow::decimal128(5, 2);
const std::shared_ptr<arrow::DataType>& decimal_5_2 = arrow::decimal128(5, 2);
auto field_a = field("a", decimal_5_2);
auto schema = arrow::schema({field_a});
@@ -1138,20 +1138,16 @@ TEST_F(TestDecimal, TestSha) {
// build expressions.
// hashSHA1(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
auto hashSha1 = TreeExprBuilder::MakeFunction("hashSHA1",
{node_a}, utf8());
auto hashSha1 = TreeExprBuilder::MakeFunction("hashSHA1", {node_a}, utf8());
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha1, res_0);
auto hashSha256 = TreeExprBuilder::MakeFunction("hashSHA256",
{node_a}, utf8());
auto hashSha256 = TreeExprBuilder::MakeFunction("hashSHA256", {node_a}, utf8());
auto expr_1 = TreeExprBuilder::MakeExpression(hashSha256, res_1);
// Build a projector for the expressions.
std::shared_ptr<Projector> projector;
auto status =
Projector::Make(schema, {expr_0, expr_1},
TestConfiguration(), &projector);
Projector::Make(schema, {expr_0, expr_1}, TestConfiguration(), &projector);
ASSERT_OK(status) << status.message();
// Create a row-batch with some sample data
@@ -1159,12 +1155,10 @@ TEST_F(TestDecimal, TestSha) {
auto validity_array = {false, true, true};
auto array_dec = MakeArrowArrayDecimal(
decimal_5_2, MakeDecimalVector({"3.45", "0", "0.01"}, 2),
validity_array);
decimal_5_2, MakeDecimalVector({"3.45", "0", "0.01"}, 2), validity_array);
// prepare input record batch
auto in_batch = arrow::RecordBatch::Make(schema, num_records,
{array_dec});
auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array_dec});
// Evaluate expression
arrow::ArrayVector outputs;
@@ -1181,8 +1175,7 @@ TEST_F(TestDecimal, TestSha) {
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());
EXPECT_NE(value_at_position, response->GetScalar(i - 1).ValueOrDie()->ToString());
}
response = outputs.at(1);
@@ -1195,8 +1188,7 @@ TEST_F(TestDecimal, TestSha) {
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());
EXPECT_NE(value_at_position, response->GetScalar(i - 1).ValueOrDie()->ToString());
}
}
} // namespace gandiva
+126 -152
View File
@@ -28,11 +28,11 @@
namespace gandiva {
using arrow::boolean;
using arrow::float32;
using arrow::float64;
using arrow::int32;
using arrow::int64;
using arrow::utf8;
using arrow::float64;
using arrow::float32;
class TestHash : public ::testing::Test {
public:
@@ -56,10 +56,8 @@ TEST_F(TestHash, TestSimple) {
// hash64(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
auto literal_10 = TreeExprBuilder::MakeLiteral((int32_t)10);
auto hash32 = TreeExprBuilder::MakeFunction("hash32",
{node_a, literal_10}, int32());
auto hash64 = TreeExprBuilder::MakeFunction("hash64",
{node_a}, int64());
auto hash32 = TreeExprBuilder::MakeFunction("hash32", {node_a, literal_10}, int32());
auto hash64 = TreeExprBuilder::MakeFunction("hash64", {node_a}, int64());
auto expr_0 = TreeExprBuilder::MakeExpression(hash32, res_0);
auto expr_1 = TreeExprBuilder::MakeExpression(hash64, res_1);
@@ -111,10 +109,8 @@ TEST_F(TestHash, TestBuf) {
// hash64(a, 10)
auto node_a = TreeExprBuilder::MakeField(field_a);
auto literal_10 = TreeExprBuilder::MakeLiteral(static_cast<int64_t>(10));
auto hash32 = TreeExprBuilder::MakeFunction("hash32",
{node_a}, int32());
auto hash64 = TreeExprBuilder::MakeFunction("hash64",
{node_a, literal_10}, int64());
auto hash32 = TreeExprBuilder::MakeFunction("hash32", {node_a}, int32());
auto hash64 = TreeExprBuilder::MakeFunction("hash64", {node_a, literal_10}, int64());
auto expr_0 = TreeExprBuilder::MakeExpression(hash32, res_0);
auto expr_1 = TreeExprBuilder::MakeExpression(hash64, res_1);
@@ -170,52 +166,42 @@ TEST_F(TestHash, TestSha256Simple) {
// build expressions.
// hashSHA256(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
auto hashSha256_1 = TreeExprBuilder::MakeFunction("hashSHA256",
{node_a}, utf8());
auto hashSha256_1 = TreeExprBuilder::MakeFunction("hashSHA256", {node_a}, utf8());
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha256_1, res_0);
auto node_b = TreeExprBuilder::MakeField(field_b);
auto hashSha256_2 = TreeExprBuilder::MakeFunction("hashSHA256",
{node_b}, utf8());
auto hashSha256_2 = TreeExprBuilder::MakeFunction("hashSHA256", {node_b}, utf8());
auto expr_1 = TreeExprBuilder::MakeExpression(hashSha256_2, res_1);
auto node_c = TreeExprBuilder::MakeField(field_c);
auto hashSha256_3 = TreeExprBuilder::MakeFunction("hashSHA256",
{node_c}, utf8());
auto hashSha256_3 = TreeExprBuilder::MakeFunction("hashSHA256", {node_c}, utf8());
auto expr_2 = TreeExprBuilder::MakeExpression(hashSha256_3, res_2);
auto node_d = TreeExprBuilder::MakeField(field_d);
auto hashSha256_4 = TreeExprBuilder::MakeFunction("hashSHA256",
{node_d}, utf8());
auto hashSha256_4 = TreeExprBuilder::MakeFunction("hashSHA256", {node_d}, utf8());
auto expr_3 = TreeExprBuilder::MakeExpression(hashSha256_4, res_3);
// Build a projector for the expressions.
std::shared_ptr<Projector> projector;
auto status =
Projector::Make(schema, {expr_0, expr_1, expr_2, expr_3},
TestConfiguration(), &projector);
auto status = Projector::Make(schema, {expr_0, expr_1, expr_2, expr_3},
TestConfiguration(), &projector);
ASSERT_OK(status) << status.message();
// Create a row-batch with some sample data
int num_records = 2;
auto validity_array = {false, true};
auto array_int32 =
MakeArrowArrayInt32({1, 0}, validity_array);
auto array_int32 = MakeArrowArrayInt32({1, 0}, validity_array);
auto array_int64 =
MakeArrowArrayInt64({1, 0}, validity_array);
auto array_int64 = MakeArrowArrayInt64({1, 0}, validity_array);
auto array_float32 =
MakeArrowArrayFloat32({1.0, 0.0}, validity_array);
auto array_float32 = MakeArrowArrayFloat32({1.0, 0.0}, validity_array);
auto array_float64 =
MakeArrowArrayFloat64({1.0, 0.0}, validity_array);
auto array_float64 = MakeArrowArrayFloat64({1.0, 0.0}, validity_array);
// prepare input record batch
auto in_batch = arrow::RecordBatch::Make(schema, num_records,
{array_int32, array_int64,
array_float32, array_float64});
auto in_batch = arrow::RecordBatch::Make(
schema, num_records, {array_int32, array_int64, array_float32, array_float64});
// Evaluate expression
arrow::ArrayVector outputs;
@@ -256,23 +242,23 @@ TEST_F(TestHash, TestSha256Varlen) {
// build expressions.
// hashSHA256(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
auto hashSha256 = TreeExprBuilder::MakeFunction("hashSHA256",
{node_a}, utf8());
auto hashSha256 = TreeExprBuilder::MakeFunction("hashSHA256", {node_a}, utf8());
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha256, res_0);
// Build a projector for the expressions.
std::shared_ptr<Projector> projector;
auto status =
Projector::Make(schema, {expr_0}, TestConfiguration(), &projector);
auto status = Projector::Make(schema, {expr_0}, TestConfiguration(), &projector);
EXPECT_TRUE(status.ok()) << status.message();
// Create a row-batch with some sample data
int num_records = 3;
std::string first_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY "
"[ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string second_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY "
"[ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
std::string first_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY "
"[ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string second_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY "
"[ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
auto array_a =
MakeArrowArrayUtf8({"foo", first_string, second_string}, {false, true, true});
@@ -293,153 +279,141 @@ TEST_F(TestHash, TestSha256Varlen) {
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());
EXPECT_NE(value_at_position, response->GetScalar(i - 1).ValueOrDie()->ToString());
}
}
TEST_F(TestHash, TestSha1Simple) {
// schema for input fields
auto field_a = field("a", int32());
auto field_b = field("b", int64());
auto field_c = field("c", float32());
auto field_d = field("d", float64());
auto schema = arrow::schema({field_a, field_b, field_c, field_d});
// schema for input fields
auto field_a = field("a", int32());
auto field_b = field("b", int64());
auto field_c = field("c", float32());
auto field_d = field("d", float64());
auto schema = arrow::schema({field_a, field_b, field_c, field_d});
// output fields
auto res_0 = field("res0", utf8());
auto res_1 = field("res1", utf8());
auto res_2 = field("res2", utf8());
auto res_3 = field("res3", utf8());
// output fields
auto res_0 = field("res0", utf8());
auto res_1 = field("res1", utf8());
auto res_2 = field("res2", utf8());
auto res_3 = field("res3", utf8());
// build expressions.
// hashSHA1(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
auto hashSha1_1 = TreeExprBuilder::MakeFunction("hashSHA1",
{node_a}, utf8());
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha1_1, res_0);
// build expressions.
// hashSHA1(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
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 hashSha1_2 = TreeExprBuilder::MakeFunction("hashSHA1",
{node_b}, utf8());
auto expr_1 = TreeExprBuilder::MakeExpression(hashSha1_2, res_1);
auto node_b = TreeExprBuilder::MakeField(field_b);
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 hashSha1_3 = TreeExprBuilder::MakeFunction("hashSHA1",
{node_c}, utf8());
auto expr_2 = TreeExprBuilder::MakeExpression(hashSha1_3, res_2);
auto node_c = TreeExprBuilder::MakeField(field_c);
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 hashSha1_4 = TreeExprBuilder::MakeFunction("hashSHA1",
{node_d}, utf8());
auto expr_3 = TreeExprBuilder::MakeExpression(hashSha1_4, res_3);
auto node_d = TreeExprBuilder::MakeField(field_d);
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;
auto status =
Projector::Make(schema, {expr_0, expr_1, expr_2, expr_3},
TestConfiguration(), &projector);
EXPECT_TRUE(status.ok()) << status.message();
// Build a projector for the expressions.
std::shared_ptr<Projector> projector;
auto status = Projector::Make(schema, {expr_0, expr_1, expr_2, expr_3},
TestConfiguration(), &projector);
EXPECT_TRUE(status.ok()) << status.message();
// Create a row-batch with some sample data
int num_records = 2;
auto validity_array = {false, true};
// Create a row-batch with some sample data
int num_records = 2;
auto validity_array = {false, true};
auto array_int32 =
MakeArrowArrayInt32({1, 0}, validity_array);
auto array_int32 = MakeArrowArrayInt32({1, 0}, validity_array);
auto array_int64 =
MakeArrowArrayInt64({1, 0}, validity_array);
auto array_int64 = MakeArrowArrayInt64({1, 0}, validity_array);
auto array_float32 =
MakeArrowArrayFloat32({1.0, 0.0}, validity_array);
auto array_float32 = MakeArrowArrayFloat32({1.0, 0.0}, validity_array);
auto array_float64 =
MakeArrowArrayFloat64({1.0, 0.0}, validity_array);
auto array_float64 = MakeArrowArrayFloat64({1.0, 0.0}, validity_array);
// prepare input record batch
auto in_batch = arrow::RecordBatch::Make(schema, num_records,{array_int32, array_int64,
array_float32, array_float64});
// prepare input record batch
auto in_batch = arrow::RecordBatch::Make(
schema, num_records, {array_int32, array_int64, array_float32, array_float64});
// Evaluate expression
arrow::ArrayVector outputs;
status = projector->Evaluate(*in_batch, pool_, &outputs);
ASSERT_OK(status);
// Evaluate expression
arrow::ArrayVector outputs;
status = projector->Evaluate(*in_batch, pool_, &outputs);
ASSERT_OK(status);
auto response_int32 = outputs.at(0);
auto response_int64 = outputs.at(1);
auto response_float32 = outputs.at(2);
auto response_float64 = outputs.at(3);
auto response_int32 = outputs.at(0);
auto response_int64 = outputs.at(1);
auto response_float32 = outputs.at(2);
auto response_float64 = outputs.at(3);
// Checks if the null and zero representation for numeric values
// are consistent between the types
EXPECT_ARROW_ARRAY_EQUALS(response_int32, response_int64);
EXPECT_ARROW_ARRAY_EQUALS(response_int64, response_float32);
EXPECT_ARROW_ARRAY_EQUALS(response_float32, response_float64);
// Checks if the null and zero representation for numeric values
// are consistent between the types
EXPECT_ARROW_ARRAY_EQUALS(response_int32, response_int64);
EXPECT_ARROW_ARRAY_EQUALS(response_int64, response_float32);
EXPECT_ARROW_ARRAY_EQUALS(response_float32, response_float64);
const int sha1_hash_size = 40;
const int sha1_hash_size = 40;
// Checks if the hash size in response is correct
for (int i = 1; i < num_records; ++i) {
const auto& value_at_position = response_int32->GetScalar(i).ValueOrDie()->ToString();
// Checks if the hash size in response is correct
for (int i = 1; i < num_records; ++i) {
const auto& value_at_position = response_int32->GetScalar(i).ValueOrDie()->ToString();
EXPECT_EQ(value_at_position.size(), sha1_hash_size);
EXPECT_NE(value_at_position,
response_int32->GetScalar(i - 1).ValueOrDie()->ToString());
}
EXPECT_EQ(value_at_position.size(), sha1_hash_size);
EXPECT_NE(value_at_position,
response_int32->GetScalar(i - 1).ValueOrDie()->ToString());
}
}
TEST_F(TestHash, TestSha1Varlen) {
// schema for input fields
auto field_a = field("a", utf8());
auto schema = arrow::schema({field_a});
// schema for input fields
auto field_a = field("a", utf8());
auto schema = arrow::schema({field_a});
// output fields
auto res_0 = field("res0", utf8());
// output fields
auto res_0 = field("res0", utf8());
// build expressions.
// hashSHA1(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
auto hashSha1 = TreeExprBuilder::MakeFunction("hashSHA1",
{node_a}, utf8());
auto expr_0 = TreeExprBuilder::MakeExpression(hashSha1, res_0);
// build expressions.
// hashSHA1(a)
auto node_a = TreeExprBuilder::MakeField(field_a);
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;
auto status =
Projector::Make(schema, {expr_0}, TestConfiguration(), &projector);
ASSERT_OK(status) << status.message();
// Build a projector for the expressions.
std::shared_ptr<Projector> projector;
auto status = Projector::Make(schema, {expr_0}, TestConfiguration(), &projector);
ASSERT_OK(status) << status.message();
// Create a row-batch with some sample data
int num_records = 3;
// Create a row-batch with some sample data
int num_records = 3;
std::string first_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string second_string = "ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
std::string first_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ]";
std::string second_string =
"ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeın\nY [ˈʏpsilɔn], "
"Yen [jɛn], Yoga [ˈjoːgɑ] コンニチハ";
auto array_a =
MakeArrowArrayUtf8({"", first_string, second_string},
{false, true, true});
auto array_a =
MakeArrowArrayUtf8({"", first_string, second_string}, {false, true, true});
// prepare input record batch
auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array_a});
// prepare input record batch
auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array_a});
// Evaluate expression
arrow::ArrayVector outputs;
status = projector->Evaluate(*in_batch, pool_, &outputs);
ASSERT_OK(status);
// Evaluate expression
arrow::ArrayVector outputs;
status = projector->Evaluate(*in_batch, pool_, &outputs);
ASSERT_OK(status);
auto response = outputs.at(0);
const int sha1_hash_size = 40;
auto response = outputs.at(0);
const int sha1_hash_size = 40;
EXPECT_EQ(response->null_count(), 0);
for (int i = 1; i < num_records; ++i) {
const auto& value_at_position = response->GetScalar(i).ValueOrDie()->ToString();
EXPECT_EQ(response->null_count(), 0);
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());
}
EXPECT_EQ(value_at_position.size(), sha1_hash_size);
EXPECT_NE(value_at_position, response->GetScalar(i - 1).ValueOrDie()->ToString());
}
}
} // namespace gandiva