Skip to content

Commit

Permalink
Refactor common code in RowContainer::equalWithNulls and equalNoNulls (
Browse files Browse the repository at this point in the history
…facebookincubator#8323)

Summary:
Avoids the repetitive code in value comparisons.

Pull Request resolved: facebookincubator#8323

Reviewed By: kevinwilfong

Differential Revision: D52727918

Pulled By: mbasmanova

fbshipit-source-id: a055fcae6b11ac81f15e04e1576aad735d982155
  • Loading branch information
aditi-pandit authored and facebook-github-bot committed Jan 12, 2024
1 parent 281dbf2 commit 912897f
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions velox/exec/RowContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -953,21 +953,13 @@ class RowContainer {
uint8_t nullMask,
const DecodedVector& decoded,
vector_size_t index) {
using T = typename KindToFlatVector<Kind>::HashRowType;
bool rowIsNull = isNullAt(row, nullByte, nullMask);
bool indexIsNull = decoded.isNullAt(index);
if (rowIsNull || indexIsNull) {
return rowIsNull == indexIsNull;
}
if (Kind == TypeKind::ROW || Kind == TypeKind::ARRAY ||
Kind == TypeKind::MAP) {
return compareComplexType(row, offset, decoded, index) == 0;
}
if (Kind == TypeKind::VARCHAR || Kind == TypeKind::VARBINARY) {
return compareStringAsc(
valueAt<StringView>(row, offset), decoded, index) == 0;
}
return decoded.valueAt<T>(index) == valueAt<T>(row, offset);

return equalsNoNulls<Kind>(row, offset, decoded, index);
}

template <TypeKind Kind>
Expand All @@ -976,17 +968,17 @@ class RowContainer {
int32_t offset,
const DecodedVector& decoded,
vector_size_t index) {
using T = typename KindToFlatVector<Kind>::HashRowType;

if (Kind == TypeKind::ROW || Kind == TypeKind::ARRAY ||
if constexpr (
Kind == TypeKind::ROW || Kind == TypeKind::ARRAY ||
Kind == TypeKind::MAP) {
return compareComplexType(row, offset, decoded, index) == 0;
}
if (Kind == TypeKind::VARCHAR || Kind == TypeKind::VARBINARY) {
if constexpr (Kind == TypeKind::VARCHAR || Kind == TypeKind::VARBINARY) {
return compareStringAsc(
valueAt<StringView>(row, offset), decoded, index) == 0;
}

using T = typename KindToFlatVector<Kind>::HashRowType;
return decoded.valueAt<T>(index) == valueAt<T>(row, offset);
}

Expand Down

0 comments on commit 912897f

Please sign in to comment.