From f46fa37f01731092f80c9f97c9d727d380087255 Mon Sep 17 00:00:00 2001 From: "Ma, Rong" Date: Thu, 11 Apr 2024 09:52:47 +0800 Subject: [PATCH] address comments --- velox/functions/sparksql/Hash.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/velox/functions/sparksql/Hash.cpp b/velox/functions/sparksql/Hash.cpp index f1a1279dce52..2915733ce49e 100644 --- a/velox/functions/sparksql/Hash.cpp +++ b/velox/functions/sparksql/Hash.cpp @@ -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_; @@ -168,7 +169,7 @@ class PrimitiveVectorHasher : public SparkVectorHasher { PrimitiveVectorHasher(DecodedVector& decoded) : SparkVectorHasher(decoded) {} - ReturnType hashNotNull(vector_size_t index, SeedType seed) override { + ReturnType hashNotNullAt(vector_size_t index, SeedType seed) override { return hashOne( this->decoded_.template valueAt::NativeType>( index), @@ -189,7 +190,7 @@ class ArrayVectorHasher : public SparkVectorHasher { elementHasher_ = createVectorHasher(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]); @@ -222,7 +223,7 @@ class MapVectorHasher : public SparkVectorHasher { valueHasher_ = createVectorHasher(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]); @@ -260,7 +261,7 @@ class RowVectorHasher : public SparkVectorHasher { } } - 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); @@ -308,7 +309,7 @@ void applyWithType( auto hasher = createVectorHasher(*decoded); selected->applyToSelected([&](auto row) { - result.set(row, hasher->hashNotNull(row, result.valueAt(row))); + result.set(row, hasher->hashNotNullAt(row, result.valueAt(row))); }); } }