This is an automated email from the ASF dual-hosted git repository. alexey pushed a commit to branch branch-1.18.x in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/branch-1.18.x by this push: new a672f95b8 [tablet] clean-up on ColumnMaterializationContext a672f95b8 is described below commit a672f95b8460f2c89872ffb5e3d2ce71d22d41a5 Author: Alexey Serbin <ale...@apache.org> AuthorDate: Mon Oct 7 10:56:45 2024 -0700 [tablet] clean-up on ColumnMaterializationContext I was modifying the ColumnBlock's code and did this small pass-by improvement in the releated code of ColumnMaterializationContext and around. This is mostly const-correctness and style guide-related updates. This patch doesn't contain any functional modifications. Change-Id: I7cc68b7a7ae6d7bfb7413742936bca138d812a88 Reviewed-on: http://gerrit.cloudera.org:8080/21903 Tested-by: Alexey Serbin <ale...@apache.org> Reviewed-by: Abhishek Chennaka <achenn...@cloudera.com> (cherry picked from commit 48648f973b8d14b309e0eb1eeb2a3e26845f3375) Reviewed-on: http://gerrit.cloudera.org:8080/21907 Tested-by: Abhishek Chennaka <achenn...@cloudera.com> --- src/kudu/common/column_materialization_context.h | 16 ++++++++-------- src/kudu/common/columnblock.h | 4 ++-- src/kudu/common/schema.h | 7 ++----- src/kudu/tablet/cfile_set.cc | 4 +--- src/kudu/tablet/delta_applier.cc | 14 +++++--------- src/kudu/tablet/delta_applier.h | 5 ++--- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/kudu/common/column_materialization_context.h b/src/kudu/common/column_materialization_context.h index 899e6bd8c..1ccea5fa2 100644 --- a/src/kudu/common/column_materialization_context.h +++ b/src/kudu/common/column_materialization_context.h @@ -31,24 +31,24 @@ namespace kudu { class ColumnMaterializationContext { public: ColumnMaterializationContext(size_t col_idx, - const ColumnPredicate* pred, - ColumnBlock* block, - SelectionVector* sel) + const ColumnPredicate* pred, + ColumnBlock* block, + SelectionVector* sel) : col_idx_(col_idx), pred_(pred), block_(block), sel_(sel), decoder_eval_status_(kNotSet) { - if (!pred_ || !sel || !block) { - decoder_eval_status_ = kDecoderEvalNotSupported; - } + if (!pred_ || !sel || !block) { + decoder_eval_status_ = kDecoderEvalNotSupported; + } } // Column index in within the projection schema, not the underlying schema. - const size_t col_idx() { return col_idx_; } + size_t col_idx() const { return col_idx_; } // Predicate being evaluated. - const ColumnPredicate* pred() { return pred_; } + const ColumnPredicate* pred() const { return pred_; } // Destination for copied data. ColumnBlock* block() { return block_; } diff --git a/src/kudu/common/columnblock.h b/src/kudu/common/columnblock.h index 4b030d0f4..c3263f340 100644 --- a/src/kudu/common/columnblock.h +++ b/src/kudu/common/columnblock.h @@ -211,7 +211,7 @@ inline bool operator!=(const ColumnBlock& a, const ColumnBlock& b) { // One of the cells in a ColumnBlock. class ColumnBlockCell { public: - ColumnBlockCell(ColumnBlock block, size_t row_idx) + ColumnBlockCell(const ColumnBlock& block, size_t row_idx) : block_(block), row_idx_(row_idx) {} const TypeInfo* typeinfo() const { return block_.type_info(); } @@ -226,7 +226,7 @@ class ColumnBlockCell { void set_null(bool is_null) { block_.SetCellIsNull(row_idx_, is_null); } protected: ColumnBlock block_; - size_t row_idx_; + const size_t row_idx_; }; inline ColumnBlockCell ColumnBlock::cell(size_t idx) const { diff --git a/src/kudu/common/schema.h b/src/kudu/common/schema.h index 58251821d..7f06d70a0 100644 --- a/src/kudu/common/schema.h +++ b/src/kudu/common/schema.h @@ -96,7 +96,6 @@ struct ColumnId { // for decimal types. Column attributes describe logical features of // the column; these features are usually relative to the column's type. struct ColumnTypeAttributes { - public: ColumnTypeAttributes() : precision(0), scale(0), @@ -143,7 +142,6 @@ struct ColumnTypeAttributes { // Column attributes are presently specified in the ColumnSchema // protobuf message, but this should ideally be separate. struct ColumnStorageAttributes { - public: ColumnStorageAttributes() : encoding(AUTO_ENCODING), compression(DEFAULT_COMPRESSION), @@ -173,7 +171,6 @@ struct ColumnStorageAttributes { // In the future, as more complex alter operations need to be supported, // this may evolve into a class, but for now it's just POD. struct ColumnSchemaDelta { -public: explicit ColumnSchemaDelta(std::string name) : name(std::move(name)), remove_default(false) { @@ -241,8 +238,8 @@ class ColumnSchema { bool is_auto_incrementing = false, const void* read_default = nullptr, const void* write_default = nullptr, - ColumnStorageAttributes attributes = ColumnStorageAttributes(), - ColumnTypeAttributes type_attributes = ColumnTypeAttributes(), + ColumnStorageAttributes attributes = {}, + ColumnTypeAttributes type_attributes = {}, std::string comment = "") : name_(std::move(name)), type_info_(GetTypeInfo(type)), diff --git a/src/kudu/tablet/cfile_set.cc b/src/kudu/tablet/cfile_set.cc index a10fd4f11..1e40a8662 100644 --- a/src/kudu/tablet/cfile_set.cc +++ b/src/kudu/tablet/cfile_set.cc @@ -593,9 +593,7 @@ Status CFileSet::Iterator::MaterializeColumn(ColumnMaterializationContext *ctx) RETURN_NOT_OK(PrepareColumn(ctx)); ColumnIterator* iter = col_iters_[ctx->col_idx()].get(); - RETURN_NOT_OK(iter->Scan(ctx)); - - return Status::OK(); + return iter->Scan(ctx); } Status CFileSet::Iterator::FinishBatch() { diff --git a/src/kudu/tablet/delta_applier.cc b/src/kudu/tablet/delta_applier.cc index deb75ffad..dba68444e 100644 --- a/src/kudu/tablet/delta_applier.cc +++ b/src/kudu/tablet/delta_applier.cc @@ -20,6 +20,7 @@ #include <optional> #include <ostream> #include <string> +#include <type_traits> #include <utility> #include <vector> @@ -57,8 +58,7 @@ DeltaApplier::~DeltaApplier() { Status DeltaApplier::Init(ScanSpec* spec) { RETURN_NOT_OK(base_iter_->Init(spec)); - RETURN_NOT_OK(delta_iter_->Init(spec)); - return Status::OK(); + return delta_iter_->Init(spec); } @@ -98,8 +98,7 @@ Status DeltaApplier::PrepareBatch(size_t* nrows) { // See InitializeSelectionVector() below. prepare_flags |= DeltaIterator::PREPARE_FOR_SELECT; } - RETURN_NOT_OK(delta_iter_->PrepareBatch(*nrows, prepare_flags)); - return Status::OK(); + return delta_iter_->PrepareBatch(*nrows, prepare_flags); } Status DeltaApplier::FinishBatch() { @@ -135,12 +134,9 @@ Status DeltaApplier::MaterializeColumn(ColumnMaterializationContext* ctx) { if (delta_iter_->MayHaveDeltas()) { ctx->SetDecoderEvalNotSupported(); RETURN_NOT_OK(base_iter_->MaterializeColumn(ctx)); - RETURN_NOT_OK(delta_iter_->ApplyUpdates(ctx->col_idx(), ctx->block(), *ctx->sel())); - } else { - RETURN_NOT_OK(base_iter_->MaterializeColumn(ctx)); + return delta_iter_->ApplyUpdates(ctx->col_idx(), ctx->block(), *ctx->sel()); } - - return Status::OK(); + return base_iter_->MaterializeColumn(ctx); } } // namespace tablet diff --git a/src/kudu/tablet/delta_applier.h b/src/kudu/tablet/delta_applier.h index e0608340b..8b3f91728 100644 --- a/src/kudu/tablet/delta_applier.h +++ b/src/kudu/tablet/delta_applier.h @@ -14,8 +14,8 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -#ifndef KUDU_TABLET_DELTA_APPLIER_H -#define KUDU_TABLET_DELTA_APPLIER_H + +#pragma once #include <cstddef> #include <memory> @@ -94,4 +94,3 @@ class DeltaApplier final : public ColumnwiseIterator { } // namespace tablet } // namespace kudu -#endif /* KUDU_TABLET_DELTA_APPLIER_H */