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 11, 2024
1 parent dcc82c9 commit 2312470
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions velox/functions/sparksql/Hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ class SparkVectorHasher {
if (decoded_.isNullAt(index)) {
return seed;
}
return hashNotNull(index, seed);
return hashNotNullAt(index, seed);
}

virtual ReturnType hashNotNull(vector_size_t index, SeedType seed) = 0;
// Compute the hash value of input vector at index for non-null values.
virtual ReturnType hashNotNullAt(vector_size_t index, SeedType seed) = 0;

protected:
const DecodedVector& decoded_;
Expand Down Expand Up @@ -168,7 +169,7 @@ class PrimitiveVectorHasher : public SparkVectorHasher<HashClass> {
PrimitiveVectorHasher(DecodedVector& decoded)
: SparkVectorHasher<HashClass>(decoded) {}

ReturnType hashNotNull(vector_size_t index, SeedType seed) override {
ReturnType hashNotNullAt(vector_size_t index, SeedType seed) override {
return hashOne<HashClass, SeedType, ReturnType>(
this->decoded_.template valueAt<typename TypeTraits<kind>::NativeType>(
index),
Expand All @@ -189,7 +190,7 @@ class ArrayVectorHasher : public SparkVectorHasher<HashClass> {
elementHasher_ = createVectorHasher<HashClass>(decodedElements_);
}

ReturnType hashNotNull(vector_size_t index, SeedType seed) override {
ReturnType hashNotNullAt(vector_size_t index, SeedType seed) override {
auto size = base_->sizeAt(indices_[index]);
auto offset = base_->offsetAt(indices_[index]);

Expand Down Expand Up @@ -222,7 +223,7 @@ class MapVectorHasher : public SparkVectorHasher<HashClass> {
valueHasher_ = createVectorHasher<HashClass>(decodedValues_);
}

ReturnType hashNotNull(vector_size_t index, SeedType seed) override {
ReturnType hashNotNullAt(vector_size_t index, SeedType seed) override {
auto size = base_->sizeAt(indices_[index]);
auto offset = base_->offsetAt(indices_[index]);

Expand Down Expand Up @@ -260,7 +261,7 @@ class RowVectorHasher : public SparkVectorHasher<HashClass> {
}
}

ReturnType hashNotNull(vector_size_t index, SeedType seed) override {
ReturnType hashNotNullAt(vector_size_t index, SeedType seed) override {
ReturnType result = seed;
for (auto i = 0; i < base_->childrenSize(); ++i) {
result = hashers_[i]->hashAt(indices_[index], result);
Expand Down Expand Up @@ -308,7 +309,7 @@ void applyWithType(

auto hasher = createVectorHasher<HashClass>(*decoded);
selected->applyToSelected([&](auto row) {
result.set(row, hasher->hashNotNull(row, result.valueAt(row)));
result.set(row, hasher->hashNotNullAt(row, result.valueAt(row)));
});
}
}
Expand Down

0 comments on commit 2312470

Please sign in to comment.