Skip to content

Commit

Permalink
Fix REAL and DOUBLE hash functions
Browse files Browse the repository at this point in the history
  • Loading branch information
majetideepak committed Jun 6, 2024
1 parent 8ea6979 commit ee88f95
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions velox/connectors/hive/HivePartitionFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ inline uint32_t hashOne<TypeKind::INTEGER>(const int32_t& value) {

template <>
inline uint32_t hashOne<TypeKind::REAL>(const float& value) {
return static_cast<uint32_t>(*reinterpret_cast<const int32_t*>(&value));
uint32_t ret;
memcpy(&ret, &value, sizeof ret);
return ret;
}

template <>
Expand All @@ -86,7 +88,9 @@ inline uint32_t hashOne<TypeKind::BIGINT>(const int64_t& value) {

template <>
inline uint32_t hashOne<TypeKind::DOUBLE>(const double& value) {
return hashInt64(*reinterpret_cast<const int64_t*>(&value));
int64_t val;
memcpy(&val, &value, sizeof val);
return hashInt64(val);
}

template <>
Expand Down

0 comments on commit ee88f95

Please sign in to comment.