Skip to content

Commit

Permalink
cc
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Abraham committed Jul 3, 2024
1 parent cb3b5b4 commit 0153b02
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions velox/functions/prestosql/BinaryFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,22 +337,19 @@ struct ToBase32Function {
}
};

template <typename T>
template <typename TExec>
struct FromBase32Function {
VELOX_DEFINE_FUNCTION_TYPES(T);
VELOX_DEFINE_FUNCTION_TYPES(TExec);

FOLLY_ALWAYS_INLINE void call(
out_type<Varbinary>& result,
const arg_type<Varchar>& input) {
try {
auto inputSize = input.size();
result.resize(
encoding::Base32::calculateDecodedSize(input.data(), inputSize));
encoding::Base32::decode(
input.data(), inputSize, result.data(), result.size());
} catch (const encoding::EncoderException& e) {
VELOX_USER_FAIL(e.what());
}
// T can be either arg_type<Varchar> or arg_type<Varbinary>. These are the
// same, but hard-coding one of them might be confusing.
template <typename T>
FOLLY_ALWAYS_INLINE void call(out_type<Varbinary>& result, const T& input) {
auto inputSize = input.size();
result.resize(
encoding::Base32::calculateDecodedSize(input.data(), inputSize));
encoding::Base32::decode(
input.data(), inputSize, result.data(), result.size());
}
};

Expand Down

0 comments on commit 0153b02

Please sign in to comment.