Skip to content

Commit 04faded

Browse files
xiaoxmengmeta-codesync[bot]
authored andcommitted
refactor: minor code cleanup in reader path (#15432)
Summary: Pull Request resolved: #15432 X-link: facebookincubator/nimble#301 Reviewed By: HuamengJiang, Yuhta Differential Revision: D86459223 fbshipit-source-id: cda6e66788f8b5d6d5df07e4faca263084ede5d6
1 parent 66bea5d commit 04faded

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed

velox/dwio/common/ColumnVisitors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ class ColumnVisitor {
491491

492492
protected:
493493
const TFilter& filter_;
494-
SelectiveColumnReader* reader_;
494+
SelectiveColumnReader* const reader_;
495495
const bool allowNulls_;
496496
const vector_size_t* rows_;
497497
vector_size_t numRows_;

velox/dwio/common/FormatData.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ class FormatData {
131131
/// Base class for format-specific reader initialization arguments.
132132
class FormatParams {
133133
public:
134-
explicit FormatParams(memory::MemoryPool& pool, ColumnReaderStatistics& stats)
135-
: pool_(pool), stats_(stats) {}
134+
FormatParams(memory::MemoryPool& pool, ColumnReaderStatistics& stats)
135+
: pool_(&pool), stats_(&stats) {}
136136

137137
virtual ~FormatParams() = default;
138138

@@ -143,16 +143,16 @@ class FormatParams {
143143
const velox::common::ScanSpec& scanSpec) = 0;
144144

145145
memory::MemoryPool& pool() {
146-
return pool_;
146+
return *pool_;
147147
}
148148

149149
ColumnReaderStatistics& runtimeStatistics() {
150-
return stats_;
150+
return *stats_;
151151
}
152152

153153
private:
154-
memory::MemoryPool& pool_;
155-
ColumnReaderStatistics& stats_;
154+
memory::MemoryPool* const pool_;
155+
ColumnReaderStatistics* const stats_;
156156
};
157157

158158
} // namespace facebook::velox::dwio::common

velox/dwio/common/ScanSpec.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class ColumnStatistics;
3434
}
3535
namespace common {
3636

37-
// Describes the filtering and value extraction for a
38-
// SelectiveColumnReader. This is owned by the TableScan Operator and
39-
// is passed to SelectiveColumnReaders at construction. This is
40-
// mutable by readers to reflect filter order and other adaptations.
37+
/// Describes the filtering and value extraction for a
38+
/// SelectiveColumnReader. This is owned by the TableScan Operator and
39+
/// is passed to SelectiveColumnReaders at construction. This is
40+
/// mutable by readers to reflect filter order and other adaptations.
4141
class ScanSpec {
4242
public:
4343
enum class ColumnType : int8_t {
@@ -46,7 +46,7 @@ class ScanSpec {
4646
kComposite, // A struct with all children not read from file
4747
};
4848

49-
// Convert ColumnType to its string name representation.
49+
/// Convert ColumnType to its string name representation.
5050
static std::string_view columnTypeString(ColumnType columnType);
5151

5252
static constexpr column_index_t kNoChannel = ~0;
@@ -56,9 +56,9 @@ class ScanSpec {
5656

5757
explicit ScanSpec(const std::string& name) : fieldName_(name) {}
5858

59-
// Filter to apply. If 'this' corresponds to a struct/list/map, this
60-
// can only be isNull or isNotNull, other filtering is given by
61-
// 'children'.
59+
/// Filter to apply. If 'this' corresponds to a struct/list/map, this
60+
/// can only be isNull or isNotNull, other filtering is given by
61+
/// 'children'.
6262
const common::Filter* filter() const {
6363
return filterDisabled_ ? nullptr : filter_.get();
6464
}
@@ -167,8 +167,8 @@ class ScanSpec {
167167
return projectOut_ || deltaUpdate_;
168168
}
169169

170-
// Position in the RowVector returned by the top level scan. Applies
171-
// only to children of the root struct where projectOut_ is true.
170+
/// Position in the RowVector returned by the top level scan. Applies
171+
/// only to children of the root struct where projectOut_ is true.
172172
column_index_t channel() const {
173173
return channel_;
174174
}
@@ -408,29 +408,29 @@ class ScanSpec {
408408
// Number of times read is called on the corresponding reader. This
409409
// is used for setup on first use and to produce a read sequence
410410
// number for LazyVectors.
411-
uint64_t numReads_ = 0;
411+
uint64_t numReads_{0};
412412

413413
// Ordinal position of 'this' in its containing spec. For a struct
414414
// member this is the position of the reader in the child
415415
// readers. If this describes an operation on an array element or a
416416
// map with numeric key, this is the subscript as defined for array
417417
// or map.
418-
int64_t subscript_ = -1;
418+
int64_t subscript_{-1};
419419
// Column name if this is a struct mamber. String key if this
420420
// describes an operation on a map value.
421421
std::string fieldName_;
422422
// Ordinal position of the extracted value in the containing
423423
// RowVector. Set only when this describes a struct member.
424-
column_index_t channel_ = kNoChannel;
424+
column_index_t channel_{kNoChannel};
425425

426426
VectorPtr constantValue_;
427-
bool projectOut_ = false;
427+
bool projectOut_{false};
428428

429-
ColumnType columnType_ = ColumnType::kRegular;
429+
ColumnType columnType_{ColumnType::kRegular};
430430

431431
// True if a string dictionary or flat map in this field should be
432432
// returned as flat.
433-
bool makeFlat_ = false;
433+
bool makeFlat_{false};
434434
std::shared_ptr<const common::Filter> filter_;
435435
bool filterDisabled_ = false;
436436
dwio::common::DeltaColumnUpdater* deltaUpdate_ = nullptr;

velox/dwio/common/SelectiveColumnReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,15 @@ void SelectiveColumnReader::addSkippedParentNulls(
479479
int64_t from,
480480
int64_t to,
481481
int32_t numNulls) {
482-
auto rowsPerRowGroup = formatData_->rowsPerRowGroup();
482+
const auto rowsPerRowGroup = formatData_->rowsPerRowGroup();
483483
if (rowsPerRowGroup.has_value() &&
484484
from / rowsPerRowGroup.value() >
485485
parentNullsRecordedTo_ / rowsPerRowGroup.value()) {
486486
// the new nulls are in a different row group than the last.
487487
parentNullsRecordedTo_ = from;
488488
numParentNulls_ = 0;
489489
}
490-
if (parentNullsRecordedTo_) {
490+
if (parentNullsRecordedTo_ > 0) {
491491
VELOX_CHECK_EQ(parentNullsRecordedTo_, from);
492492
}
493493
numParentNulls_ += numNulls;

velox/dwio/common/SelectiveStructColumnReader.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ void SelectiveStructColumnReaderBase::read(
407407
}
408408

409409
const uint64_t* structNulls = nulls();
410-
411410
// A struct reader may have a null/non-null filter
412411
if (scanSpec_->filter()) {
413412
const auto kind = scanSpec_->filter()->kind();

velox/dwio/common/SelectiveStructColumnReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class SelectiveStructColumnReaderBase : public SelectiveColumnReader {
110110

111111
// The subscript of childSpecs will be set to this value if the column is
112112
// constant (either explicitly or because it's missing).
113-
static constexpr int32_t kConstantChildSpecSubscript = -1;
113+
static constexpr int32_t kConstantChildSpecSubscript{-1};
114114

115115
SelectiveStructColumnReaderBase(
116116
const TypePtr& requestedType,
@@ -199,7 +199,7 @@ class SelectiveStructColumnReaderBase : public SelectiveColumnReader {
199199

200200
int64_t lazyVectorReadOffset_;
201201

202-
int64_t currentRowNumber_ = -1;
202+
int64_t currentRowNumber_{-1};
203203

204204
const Mutation* mutation_ = nullptr;
205205

0 commit comments

Comments
 (0)