diff --git a/velox/dwio/common/SelectiveIntegerColumnReader.h b/velox/dwio/common/SelectiveIntegerColumnReader.h index 2716f800bba8..c94b5a60d789 100644 --- a/velox/dwio/common/SelectiveIntegerColumnReader.h +++ b/velox/dwio/common/SelectiveIntegerColumnReader.h @@ -127,23 +127,26 @@ void SelectiveIntegerColumnReader::processFilter( ExtractValues extractValues, const RowSet& rows) { if (filter == nullptr) { - readHelper( - &dwio::common::alwaysTrue(), rows, extractValues); + static_cast(this) + ->template readHelper( + &dwio::common::alwaysTrue(), rows, extractValues); return; } switch (filter->kind()) { case velox::common::FilterKind::kAlwaysTrue: - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper( + filter, rows, extractValues); break; case velox::common::FilterKind::kIsNull: if constexpr (kEncodingHasNulls) { filterNulls( rows, true, !std::is_same_v); } else { - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper( + filter, rows, extractValues); } break; case velox::common::FilterKind::kIsNotNull: @@ -152,41 +155,55 @@ void SelectiveIntegerColumnReader::processFilter( std::is_same_v) { filterNulls(rows, false, false); } else { - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper( + filter, rows, extractValues); } break; case velox::common::FilterKind::kBigintRange: - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper( + filter, rows, extractValues); break; case velox::common::FilterKind::kNegatedBigintRange: - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper< + Reader, + velox::common::NegatedBigintRange, + isDense>(filter, rows, extractValues); break; case velox::common::FilterKind::kBigintValuesUsingHashTable: - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper< + Reader, + velox::common::BigintValuesUsingHashTable, + isDense>(filter, rows, extractValues); break; case velox::common::FilterKind::kBigintValuesUsingBitmask: - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper< + Reader, + velox::common::BigintValuesUsingBitmask, + isDense>(filter, rows, extractValues); break; case velox::common::FilterKind::kNegatedBigintValuesUsingHashTable: - readHelper< - Reader, - velox::common::NegatedBigintValuesUsingHashTable, - isDense>(filter, rows, extractValues); + static_cast(this) + ->template readHelper< + Reader, + velox::common::NegatedBigintValuesUsingHashTable, + isDense>(filter, rows, extractValues); break; case velox::common::FilterKind::kNegatedBigintValuesUsingBitmask: - readHelper< - Reader, - velox::common::NegatedBigintValuesUsingBitmask, - isDense>(filter, rows, extractValues); + static_cast(this) + ->template readHelper< + Reader, + velox::common::NegatedBigintValuesUsingBitmask, + isDense>(filter, rows, extractValues); break; default: - readHelper( - filter, rows, extractValues); + static_cast(this) + ->template readHelper( + filter, rows, extractValues); break; } } diff --git a/velox/dwio/parquet/reader/TimestampColumnReader.h b/velox/dwio/parquet/reader/TimestampColumnReader.h index 7f5670e21fb3..308743ecea4f 100644 --- a/velox/dwio/parquet/reader/TimestampColumnReader.h +++ b/velox/dwio/parquet/reader/TimestampColumnReader.h @@ -101,16 +101,15 @@ class TimestampColumnReader : public IntegerColumnReader { typename TFilter, bool isDense, typename ExtractValues> - void readHelperTimestamp( + void readHelper( velox::common::Filter* filter, const RowSet& rows, ExtractValues extractValues) { - if constexpr (std::is_same_v) { + if (auto* range = dynamic_cast(filter)) { // Convert TimestampRange to ParquetInt96TimestampRange. - auto* range = reinterpret_cast(filter); ParquetInt96TimestampRange newRange = ParquetInt96TimestampRange( range->lower(), range->upper(), range->nullAllowed()); - reinterpret_cast(this)->Reader::readWithVisitor( + this->readWithVisitor( rows, dwio::common::ColumnVisitor< int128_t, @@ -118,7 +117,7 @@ class TimestampColumnReader : public IntegerColumnReader { ExtractValues, isDense>(newRange, this, rows, extractValues)); } else { - reinterpret_cast(this)->Reader::readWithVisitor( + this->readWithVisitor( rows, dwio::common:: ColumnVisitor( @@ -130,89 +129,6 @@ class TimestampColumnReader : public IntegerColumnReader { return; } - template < - typename Reader, - bool isDense, - bool kEncodingHasNulls, - typename ExtractValues> - void processTimestampFilter( - velox::common::Filter* filter, - ExtractValues extractValues, - const RowSet& rows) { - if (filter == nullptr) { - readHelperTimestamp( - &dwio::common::alwaysTrue(), rows, extractValues); - return; - } - - switch (filter->kind()) { - case velox::common::FilterKind::kAlwaysTrue: - readHelperTimestamp( - filter, rows, extractValues); - break; - case velox::common::FilterKind::kIsNull: - if constexpr (kEncodingHasNulls) { - filterNulls( - rows, - true, - !std:: - is_same_v); - } else { - readHelperTimestamp( - filter, rows, extractValues); - } - break; - case velox::common::FilterKind::kIsNotNull: - if constexpr ( - kEncodingHasNulls && - std::is_same_v) { - filterNulls(rows, false, false); - } else { - readHelperTimestamp( - filter, rows, extractValues); - } - break; - case velox::common::FilterKind::kTimestampRange: - readHelperTimestamp( - filter, rows, extractValues); - break; - default: - VELOX_UNREACHABLE(); - } - } - - template - void readTimestamp(const RowSet& rows) { - const bool isDense = rows.back() == rows.size() - 1; - velox::common::Filter* filter = - scanSpec_->filter() ? scanSpec_->filter() : &dwio::common::alwaysTrue(); - if (scanSpec_->keepValues()) { - if (scanSpec_->valueHook()) { - if (isDense) { - processValueHook(rows, scanSpec_->valueHook()); - } else { - processValueHook(rows, scanSpec_->valueHook()); - } - } else { - if (isDense) { - processTimestampFilter( - filter, dwio::common::ExtractToReader(this), rows); - } else { - processTimestampFilter( - filter, dwio::common::ExtractToReader(this), rows); - } - } - } else { - if (isDense) { - processTimestampFilter( - filter, dwio::common::DropValues(), rows); - } else { - processTimestampFilter( - filter, dwio::common::DropValues(), rows); - } - } - } - void read( int64_t offset, const RowSet& rows, @@ -220,7 +136,7 @@ class TimestampColumnReader : public IntegerColumnReader { auto& data = formatData_->as(); // Use int128_t as a workaround. Timestamp in Velox is of 16-byte length. prepareRead(offset, rows, nullptr); - readTimestamp(rows); + readCommon(rows); readOffset_ += rows.back() + 1; }