Skip to content

Commit

Permalink
refactor: Use const ref in Filter (#11725)
Browse files Browse the repository at this point in the history
Summary:
For `int128_t` and `Timestamp` types.

Pull Request resolved: #11725

Reviewed By: Yuhta

Differential Revision: D66726951

Pulled By: bikramSingh91

fbshipit-source-id: dff4ea944790f6076764eaafb5e3fdafd67548ef
  • Loading branch information
zuyu authored and facebook-github-bot committed Dec 4, 2024
1 parent f209751 commit 2c57445
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 55 deletions.
4 changes: 2 additions & 2 deletions velox/dwio/parquet/reader/TimestampColumnReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace facebook::velox::parquet {
namespace {

// Range filter for Parquet Int96 Timestamp.
class ParquetInt96TimestampRange : public common::TimestampRange {
class ParquetInt96TimestampRange final : public common::TimestampRange {
public:
// @param lower Lower end of the range, inclusive.
// @param upper Upper end of the range, inclusive.
Expand All @@ -36,7 +36,7 @@ class ParquetInt96TimestampRange : public common::TimestampRange {

// Int96 is read as int128_t value and converted to Timestamp by extracting
// days and nanos.
bool testInt128(int128_t value) const final override {
bool testInt128(const int128_t& value) const final {
const int32_t days = static_cast<int32_t>(value >> 64);
const uint64_t nanos = value & ((((1ULL << 63) - 1ULL) << 1) + 1);
const auto ts = Timestamp::fromDaysAndNanos(days, nanos);
Expand Down
8 changes: 4 additions & 4 deletions velox/type/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ FilterPtr HugeintValuesUsingHashTable::create(const folly::dynamic& obj) {
}

HugeintValuesUsingHashTable::HugeintValuesUsingHashTable(
const int128_t min,
const int128_t max,
const int128_t& min,
const int128_t& max,
const std::vector<int128_t>& values,
const bool nullAllowed)
: Filter(true, nullAllowed, FilterKind::kHugeintValuesUsingHashTable),
Expand All @@ -1005,7 +1005,7 @@ HugeintValuesUsingHashTable::HugeintValuesUsingHashTable(
}
}

bool HugeintValuesUsingHashTable::testInt128(int128_t value) const {
bool HugeintValuesUsingHashTable::testInt128(const int128_t& value) const {
return values_.contains(value);
}

Expand Down Expand Up @@ -1469,7 +1469,7 @@ bool MultiRange::testBytes(const char* value, int32_t length) const {
return false;
}

bool MultiRange::testTimestamp(Timestamp timestamp) const {
bool MultiRange::testTimestamp(const Timestamp& timestamp) const {
for (const auto& filter : filters_) {
if (filter->testTimestamp(timestamp)) {
return true;
Expand Down
Loading

0 comments on commit 2c57445

Please sign in to comment.