Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marin-ma committed Apr 30, 2024
1 parent f888e7a commit 9c22758
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions velox/functions/sparksql/Hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,52 @@ namespace {
const int32_t kDefaultSeed = 42;

// Computes the hash value of input using the hash function in HashClass.
template <typename HashClass, typename SeedType, typename ReturnType>
ReturnType hashOne(int32_t input, SeedType seed) {
template <typename HashClass>
typename HashClass::ReturnType hashOne(
int32_t input,
typename HashClass::SeedType seed) {
return HashClass::hashInt32(input, seed);
}

template <typename HashClass, typename SeedType, typename ReturnType>
ReturnType hashOne(int64_t input, SeedType seed) {
template <typename HashClass>
typename HashClass::ReturnType hashOne(
int64_t input,
typename HashClass::SeedType seed) {
return HashClass::hashInt64(input, seed);
}

template <typename HashClass, typename SeedType, typename ReturnType>
ReturnType hashOne(float input, SeedType seed) {
template <typename HashClass>
typename HashClass::ReturnType hashOne(
float input,
typename HashClass::SeedType seed) {
return HashClass::hashFloat(input, seed);
}

template <typename HashClass, typename SeedType, typename ReturnType>
ReturnType hashOne(double input, SeedType seed) {
template <typename HashClass>
typename HashClass::ReturnType hashOne(
double input,
typename HashClass::SeedType seed) {
return HashClass::hashDouble(input, seed);
}

template <typename HashClass, typename SeedType, typename ReturnType>
ReturnType hashOne(int128_t input, SeedType seed) {
template <typename HashClass>
typename HashClass::ReturnType hashOne(
int128_t input,
typename HashClass::SeedType seed) {
return HashClass::hashLongDecimal(input, seed);
}

template <typename HashClass, typename SeedType, typename ReturnType>
ReturnType hashOne(Timestamp input, SeedType seed) {
template <typename HashClass>
typename HashClass::ReturnType hashOne(
Timestamp input,
typename HashClass::SeedType seed) {
return HashClass::hashTimestamp(input, seed);
}

template <typename HashClass, typename SeedType, typename ReturnType>
ReturnType hashOne(StringView input, SeedType seed) {
template <typename HashClass>
typename HashClass::ReturnType hashOne(
StringView input,
typename HashClass::SeedType seed) {
return HashClass::hashBytes(input, seed);
}

Expand Down Expand Up @@ -158,7 +172,7 @@ class PrimitiveVectorHasher : public SparkVectorHasher<HashClass> {
: SparkVectorHasher<HashClass>(decoded) {}

ReturnType hashValueAt(vector_size_t index, SeedType seed) {
return hashOne<HashClass, SeedType, ReturnType>(
return hashOne<HashClass>(
this->decoded_.template valueAt<typename TypeTraits<kind>::NativeType>(
index),
seed);
Expand Down

0 comments on commit 9c22758

Please sign in to comment.