This is an automated email from the ASF dual-hosted git repository.

mgreber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new abc876353 [tablet] micro-updates on DiskRowSet and related classes
abc876353 is described below

commit abc8763532d7b71d2708ec3ce16a53bbaff79162
Author: Alexey Serbin <[email protected]>
AuthorDate: Mon Oct 28 17:35:06 2024 -0700

    [tablet] micro-updates on DiskRowSet and related classes
    
    This patch changes RollingDiskRowSetWriter::GetWrittenRowSetMetadata()
    to return a const reference to RowSetMetadataVector instead of copying
    its contents into the output parameter.  Also, it makes CHECK/DCHECK
    assertions more consistent the patch brings the code in compliance with
    the project's C++ code style and other unsorted updates.
    
    This patch doesn't contain any functional modifications.
    
    Change-Id: I1797634c67b4eb0214fbbbd8af4aea5236054ec9
    Reviewed-on: http://gerrit.cloudera.org:8080/22028
    Tested-by: Kudu Jenkins
    Reviewed-by: Gabriella Lotz <[email protected]>
    Reviewed-by: Marton Greber <[email protected]>
---
 src/kudu/tablet/compaction-test.cc |  3 +-
 src/kudu/tablet/diskrowset-test.cc |  3 +-
 src/kudu/tablet/diskrowset.cc      | 80 ++++++++++++++++++--------------------
 src/kudu/tablet/diskrowset.h       | 48 ++++++++++++-----------
 src/kudu/tablet/tablet.cc          |  9 ++---
 src/kudu/tablet/tablet.h           | 15 +++----
 6 files changed, 75 insertions(+), 83 deletions(-)

diff --git a/src/kudu/tablet/compaction-test.cc 
b/src/kudu/tablet/compaction-test.cc
index 0fd17cb46..6b2151116 100644
--- a/src/kudu/tablet/compaction-test.cc
+++ b/src/kudu/tablet/compaction-test.cc
@@ -330,8 +330,7 @@ class TestCompaction : public KuduRowSetTest {
         &rsw));
     RETURN_NOT_OK(rsw.Finish());
 
-    vector<shared_ptr<RowSetMetadata>> metas;
-    rsw.GetWrittenRowSetMetadata(&metas);
+    const auto& metas = rsw.GetWrittenRowSetMetadata();
     for (const auto& meta : metas) {
       if (!meta->HasBloomDataBlockForTests()) {
         return Status::IllegalState("no bloom filter data blocks found");
diff --git a/src/kudu/tablet/diskrowset-test.cc 
b/src/kudu/tablet/diskrowset-test.cc
index 4a52e25c3..c2afb4150 100644
--- a/src/kudu/tablet/diskrowset-test.cc
+++ b/src/kudu/tablet/diskrowset-test.cc
@@ -528,8 +528,7 @@ TEST_F(TestRowSet, TestRollingDiskRowSetWriter) {
   DoWriteTestRowSet(FLAGS_roundtrip_num_rows, &writer);
 
   // Should have rolled 4 times.
-  vector<shared_ptr<RowSetMetadata> > metas;
-  writer.GetWrittenRowSetMetadata(&metas);
+  const auto& metas = writer.GetWrittenRowSetMetadata();
   EXPECT_EQ(4, metas.size());
   int64_t count = 0;
   for (const shared_ptr<RowSetMetadata>& meta : metas) {
diff --git a/src/kudu/tablet/diskrowset.cc b/src/kudu/tablet/diskrowset.cc
index 974b24537..912cf0ffb 100644
--- a/src/kudu/tablet/diskrowset.cc
+++ b/src/kudu/tablet/diskrowset.cc
@@ -104,9 +104,6 @@ class OpId;
 
 namespace tablet {
 
-const char *DiskRowSet::kMinKeyMetaEntryName = "min_key";
-const char *DiskRowSet::kMaxKeyMetaEntryName = "max_key";
-
 DiskRowSetWriter::DiskRowSetWriter(RowSetMetadata* rowset_metadata,
                                    const Schema* schema,
                                    BloomFilterSizing bloom_sizing)
@@ -185,9 +182,9 @@ Status DiskRowSetWriter::InitAdHocIndexWriter() {
 
 }
 
-Status DiskRowSetWriter::AppendBlock(const RowBlock &block, int 
live_row_count) {
+Status DiskRowSetWriter::AppendBlock(const RowBlock& block, int 
live_row_count) {
   DCHECK_EQ(block.schema()->num_columns(), schema_->num_columns());
-  CHECK(!finished_);
+  DCHECK(!finished_);
 
   // If this is the very first block, encode the first key and save it as 
metadata
   // in the index column.
@@ -250,7 +247,7 @@ Status DiskRowSetWriter::Finish() {
 
 Status DiskRowSetWriter::FinishAndReleaseBlocks(BlockCreationTransaction* 
transaction) {
   TRACE_EVENT0("tablet", "DiskRowSetWriter::FinishAndReleaseBlocks");
-  CHECK(!finished_);
+  DCHECK(!finished_);
 
   if (written_count_ == 0) {
     finished_ = true;
@@ -263,7 +260,7 @@ Status 
DiskRowSetWriter::FinishAndReleaseBlocks(BlockCreationTransaction* transa
       key_index_writer()->GetMetaValueOrDie(DiskRowSet::kMinKeyMetaEntryName);
   Slice first_enc_slice(first_encoded_key);
 
-  CHECK(first_enc_slice <= last_enc_slice)
+  DCHECK(first_enc_slice <= last_enc_slice)
       << "First Key not <= Last key: first_key="
       << KUDU_REDACT(first_enc_slice.ToDebugString())
       << "   last_key=" << KUDU_REDACT(last_enc_slice.ToDebugString());
@@ -299,7 +296,7 @@ Status 
DiskRowSetWriter::FinishAndReleaseBlocks(BlockCreationTransaction* transa
   return Status::OK();
 }
 
-cfile::CFileWriter *DiskRowSetWriter::key_index_writer() {
+cfile::CFileWriter* DiskRowSetWriter::key_index_writer() {
   return ad_hoc_index_writer_ ? ad_hoc_index_writer_.get() : 
col_writer_->writer_for_col_idx(0);
 }
 
@@ -341,9 +338,12 @@ RollingDiskRowSetWriter::RollingDiskRowSetWriter(
   CHECK(schema.has_column_ids());
 }
 
+RollingDiskRowSetWriter::~RollingDiskRowSetWriter() {
+}
+
 Status RollingDiskRowSetWriter::Open() {
   TRACE_EVENT0("tablet", "RollingDiskRowSetWriter::Open");
-  CHECK_EQ(state_, kInitialized);
+  DCHECK_EQ(kInitialized, state_);
 
   RETURN_NOT_OK(RollWriter());
   state_ = kStarted;
@@ -362,9 +362,9 @@ Status RollingDiskRowSetWriter::RollWriter() {
 
   FsManager* fs = tablet_metadata_->fs_manager();
   unique_ptr<WritableBlock> undo_data_block;
-  unique_ptr<WritableBlock> redo_data_block;
   RETURN_NOT_OK(fs->CreateNewBlock(CreateBlockOptions({ 
tablet_metadata_->tablet_id() }),
                                    &undo_data_block));
+  unique_ptr<WritableBlock> redo_data_block;
   RETURN_NOT_OK(fs->CreateNewBlock(CreateBlockOptions({ 
tablet_metadata_->tablet_id() }),
                                    &redo_data_block));
   cur_undo_ds_block_id_ = undo_data_block->id();
@@ -382,15 +382,15 @@ Status RollingDiskRowSetWriter::RollWriter() {
 }
 
 Status RollingDiskRowSetWriter::RollIfNecessary() {
-  DCHECK_EQ(state_, kStarted);
+  DCHECK_EQ(kStarted, state_);
   if (can_roll_ && cur_writer_->written_size() > target_rowset_size_) {
     RETURN_NOT_OK(RollWriter());
   }
   return Status::OK();
 }
 
-Status RollingDiskRowSetWriter::AppendBlock(const RowBlock &block, int 
live_row_count) {
-  DCHECK_EQ(state_, kStarted);
+Status RollingDiskRowSetWriter::AppendBlock(const RowBlock& block, int 
live_row_count) {
+  DCHECK_EQ(kStarted, state_);
   RETURN_NOT_OK(cur_writer_->AppendBlock(block, live_row_count));
 
   written_count_ += block.nrows();
@@ -427,7 +427,7 @@ Status RollingDiskRowSetWriter::AppendDeltas(rowid_t 
row_idx_in_block,
   can_roll_ = false;
 
   *row_idx = row_idx_in_cur_drs_ + row_idx_in_block;
-  for (const Mutation *mut = delta_head; mut != nullptr; mut = mut->next()) {
+  for (const Mutation* mut = delta_head; mut != nullptr; mut = mut->next()) {
     DeltaKey undo_key(*row_idx, mut->timestamp());
     RETURN_NOT_OK(writer->AppendDelta<Type>(undo_key, mut->changelist()));
     delta_stats->UpdateStats(mut->timestamp(), mut->changelist());
@@ -440,14 +440,13 @@ Status RollingDiskRowSetWriter::FinishCurrentWriter() {
   if (!cur_writer_) {
     return Status::OK();
   }
-  CHECK_EQ(state_, kStarted);
-
-  Status writer_status = 
cur_writer_->FinishAndReleaseBlocks(block_transaction_.get());
+  DCHECK_EQ(kStarted, state_);
 
   // If no rows were written (e.g. due to an empty flush or a compaction with 
all rows
   // deleted), FinishAndReleaseBlocks(...) returns Aborted. In that case, we 
don't
   // generate a RowSetMetadata.
-  if (writer_status.IsAborted()) {
+  if (const auto writer_status = cur_writer_->FinishAndReleaseBlocks(
+          block_transaction_.get()); writer_status.IsAborted()) {
     CHECK_EQ(cur_writer_->written_count(), 0);
   } else {
     RETURN_NOT_OK(writer_status);
@@ -472,12 +471,12 @@ Status RollingDiskRowSetWriter::FinishCurrentWriter() {
     }
 
     written_size_ += cur_writer_->written_size();
-    written_drs_metas_.push_back(cur_drs_metadata_);
+    written_drs_metas_.emplace_back(std::move(cur_drs_metadata_));
   }
 
-  cur_writer_.reset(nullptr);
-  cur_undo_writer_.reset(nullptr);
-  cur_redo_writer_.reset(nullptr);
+  cur_writer_.reset();
+  cur_undo_writer_.reset();
+  cur_redo_writer_.reset();
 
   cur_drs_metadata_.reset();
   return Status::OK();
@@ -485,7 +484,7 @@ Status RollingDiskRowSetWriter::FinishCurrentWriter() {
 
 Status RollingDiskRowSetWriter::Finish() {
   TRACE_EVENT0("tablet", "RollingDiskRowSetWriter::Finish");
-  DCHECK_EQ(state_, kStarted);
+  DCHECK_EQ(kStarted, state_);
 
   RETURN_NOT_OK(FinishCurrentWriter());
   RETURN_NOT_OK(block_transaction_->CommitCreatedBlocks());
@@ -494,12 +493,9 @@ Status RollingDiskRowSetWriter::Finish() {
   return Status::OK();
 }
 
-void RollingDiskRowSetWriter::GetWrittenRowSetMetadata(RowSetMetadataVector* 
metas) const {
-  CHECK_EQ(state_, kFinished);
-  metas->assign(written_drs_metas_.begin(), written_drs_metas_.end());
-}
-
-RollingDiskRowSetWriter::~RollingDiskRowSetWriter() {
+const RowSetMetadataVector& 
RollingDiskRowSetWriter::GetWrittenRowSetMetadata() const {
+  DCHECK_EQ(kFinished, state_);
+  return written_drs_metas_;
 }
 
 ////////////////////////////////////////////////////////////
@@ -510,7 +506,7 @@ Status DiskRowSet::Open(const shared_ptr<RowSetMetadata>& 
rowset_metadata,
                         log::LogAnchorRegistry* log_anchor_registry,
                         const TabletMemTrackers& mem_trackers,
                         const IOContext* io_context,
-                        shared_ptr<DiskRowSet> *rowset) {
+                        shared_ptr<DiskRowSet>* rowset) {
   auto rs(DiskRowSet::make_shared(
       rowset_metadata, log_anchor_registry, mem_trackers));
   RETURN_NOT_OK(rs->Open(io_context));
@@ -640,7 +636,7 @@ Status DiskRowSet::NewMajorDeltaCompaction(const 
vector<ColumnId>& col_ids,
                                            HistoryGcOpts history_gc_opts,
                                            unique_ptr<MajorDeltaCompaction>* 
out) const {
   DCHECK(open_);
-  shared_lock<rw_spinlock> l(component_lock_);
+  shared_lock l(component_lock_);
 
   vector<shared_ptr<DeltaStore>> included_stores;
   unique_ptr<DeltaIterator> delta_iter;
@@ -661,7 +657,7 @@ Status DiskRowSet::NewMajorDeltaCompaction(const 
vector<ColumnId>& col_ids,
 Status DiskRowSet::NewRowIterator(const RowIteratorOptions& opts,
                                   unique_ptr<RowwiseIterator>* out) const {
   DCHECK(open_);
-  shared_lock<rw_spinlock> l(component_lock_);
+  shared_lock l(component_lock_);
 
   shared_ptr<CFileSet::Iterator> 
base_iter(base_data_->NewIterator(opts.projection,
                                                                    
opts.io_context));
@@ -673,15 +669,15 @@ Status DiskRowSet::NewRowIterator(const 
RowIteratorOptions& opts,
 }
 
 Status DiskRowSet::NewCompactionInput(const Schema* projection,
-                                      const MvccSnapshot &snap,
+                                      const MvccSnapshot& snap,
                                       const IOContext* io_context,
                                       unique_ptr<CompactionOrFlushInput>* out) 
const {
   return CompactionOrFlushInput::Create(*this, projection, snap, io_context, 
out);
 }
 
 Status DiskRowSet::MutateRow(Timestamp timestamp,
-                             const RowSetKeyProbe &probe,
-                             const RowChangeList &update,
+                             const RowSetKeyProbe& probe,
+                             const RowChangeList& update,
                              const consensus::OpId& op_id,
                              const IOContext* io_context,
                              ProbeStats* stats,
@@ -691,7 +687,7 @@ Status DiskRowSet::MutateRow(Timestamp timestamp,
   rowid_t num_rows;
   RETURN_NOT_OK(CountRows(io_context, &num_rows));
 #endif
-  shared_lock<rw_spinlock> l(component_lock_);
+  shared_lock l(component_lock_);
 
   optional<rowid_t> row_idx;
   RETURN_NOT_OK(base_data_->FindRow(probe, io_context, &row_idx, stats));
@@ -713,7 +709,7 @@ Status DiskRowSet::MutateRow(Timestamp timestamp,
   return delta_tracker_->Update(timestamp, *row_idx, update, op_id, result);
 }
 
-Status DiskRowSet::CheckRowPresent(const RowSetKeyProbe &probe,
+Status DiskRowSet::CheckRowPresent(const RowSetKeyProbe& probe,
                                    const IOContext* io_context,
                                    bool* present,
                                    ProbeStats* stats) const {
@@ -722,7 +718,7 @@ Status DiskRowSet::CheckRowPresent(const RowSetKeyProbe 
&probe,
   rowid_t num_rows;
   RETURN_NOT_OK(CountRows(io_context, &num_rows));
 #endif
-  shared_lock<rw_spinlock> l(component_lock_);
+  shared_lock l(component_lock_);
 
   rowid_t row_idx;
   RETURN_NOT_OK(base_data_->CheckRowPresent(probe, io_context, present, 
&row_idx, stats));
@@ -741,13 +737,13 @@ Status DiskRowSet::CheckRowPresent(const RowSetKeyProbe 
&probe,
   return Status::OK();
 }
 
-Status DiskRowSet::CountRows(const IOContext* io_context, rowid_t *count) 
const {
+Status DiskRowSet::CountRows(const IOContext* io_context, rowid_t* count) 
const {
   DCHECK(open_);
   rowid_t num_rows = num_rows_.load();
   if (PREDICT_TRUE(num_rows != -1)) {
     *count = num_rows;
   } else {
-    shared_lock<rw_spinlock> l(component_lock_);
+    shared_lock l(component_lock_);
     RETURN_NOT_OK(base_data_->CountRows(io_context, count));
     num_rows_.store(*count);
   }
@@ -774,13 +770,13 @@ Status DiskRowSet::CountLiveRows(uint64_t* count) const {
 Status DiskRowSet::GetBounds(std::string* min_encoded_key,
                              std::string* max_encoded_key) const {
   DCHECK(open_);
-  shared_lock<rw_spinlock> l(component_lock_);
+  shared_lock l(component_lock_);
   return base_data_->GetBounds(min_encoded_key, max_encoded_key);
 }
 
 void DiskRowSet::GetDiskRowSetSpaceUsage(DiskRowSetSpace* drss) const {
   DCHECK(open_);
-  shared_lock<rw_spinlock> l(component_lock_);
+  shared_lock l(component_lock_);
   drss->base_data_size = base_data_->OnDiskDataSize();
   drss->bloom_size = base_data_->BloomFileOnDiskSize();
   drss->ad_hoc_index_size = base_data_->AdhocIndexOnDiskSize();
diff --git a/src/kudu/tablet/diskrowset.h b/src/kudu/tablet/diskrowset.h
index a6b75ee6f..070260cbc 100644
--- a/src/kudu/tablet/diskrowset.h
+++ b/src/kudu/tablet/diskrowset.h
@@ -102,9 +102,9 @@ class Mutation;
 class MvccSnapshot;
 class OperationResultPB;
 
-class DiskRowSetWriter {
+class DiskRowSetWriter final {
  public:
-  // TODO: document ownership of rowset_metadata
+  // TODO(todd): document ownership of rowset_metadata
   DiskRowSetWriter(RowSetMetadata* rowset_metadata, const Schema* schema,
                    BloomFilterSizing bloom_sizing);
 
@@ -116,7 +116,7 @@ class DiskRowSetWriter {
   // if configured.
   // Rows must be appended in ascending order.
   // 'live_row_count' means the number of live rows in this input block.
-  Status AppendBlock(const RowBlock &block, int live_row_count = 0);
+  Status AppendBlock(const RowBlock& block, int live_row_count = 0);
 
   // Closes the CFiles and their underlying writable blocks.
   // If no rows were written, returns Status::Aborted().
@@ -128,10 +128,10 @@ class DiskRowSetWriter {
 
   // The base DiskRowSetWriter never rolls. This method is necessary for tests
   // which are templatized on the writer type.
-  Status RollIfNecessary() { return Status::OK(); }
+  static Status RollIfNecessary() { return Status::OK(); }
 
   rowid_t written_count() const {
-    CHECK(finished_);
+    DCHECK(finished_);
     return written_count_;
   }
 
@@ -153,7 +153,7 @@ class DiskRowSetWriter {
 
   // Return the cfile::Writer responsible for writing the key index.
   // (the ad-hoc writer for composite keys, otherwise the key column writer)
-  cfile::CFileWriter *key_index_writer();
+  cfile::CFileWriter* key_index_writer();
 
   RowSetMetadata* rowset_metadata_;
   const Schema* const schema_;
@@ -176,12 +176,13 @@ class DiskRowSetWriter {
 // with ".N" where N starts at 0 and increases as new rowsets are generated.
 //
 // See AppendBlock(...) for important usage information.
-class RollingDiskRowSetWriter {
+class RollingDiskRowSetWriter final {
  public:
   // Create a new rolling writer. The given 'tablet_metadata' must stay valid
   // for the lifetime of this writer, and is used to construct the new rowsets
   // that this RollingDiskRowSetWriter creates.
-  RollingDiskRowSetWriter(TabletMetadata* tablet_metadata, const Schema& 
schema,
+  RollingDiskRowSetWriter(TabletMetadata* tablet_metadata,
+                          const Schema& schema,
                           BloomFilterSizing bloom_sizing,
                           size_t target_rowset_size);
   ~RollingDiskRowSetWriter();
@@ -197,7 +198,7 @@ class RollingDiskRowSetWriter {
   // of rows that they correspond to. This ensures that the output delta files
   // and data files are aligned.
   // 'live_row_count' means the number of live rows in this input block.
-  Status AppendBlock(const RowBlock &block, int live_row_count = 0);
+  Status AppendBlock(const RowBlock& block, int live_row_count = 0);
 
   // Appends a sequence of REDO deltas for the same row to the current redo
   // delta file. 'row_idx_in_block' is the positional index after the last
@@ -226,11 +227,12 @@ class RollingDiskRowSetWriter {
 
   int64_t rows_written_count() const { return written_count_; }
 
-  const Schema &schema() const { return schema_; }
+  const Schema& schema() const { return schema_; }
 
-  // Return the set of rowset paths that were written by this writer.
-  // This must only be called after Finish() returns an OK result.
-  void GetWrittenRowSetMetadata(RowSetMetadataVector* metas) const;
+  // Return the set of rowset paths that were written by this writer via
+  // the 'metas' out parameter. This must only be called after Finish() returns
+  // an OK result.
+  const RowSetMetadataVector& GetWrittenRowSetMetadata() const;
 
   uint64_t written_size() const { return written_size_; }
 
@@ -326,8 +328,8 @@ class DiskRowSet :
     public RowSet,
     public enable_make_shared<DiskRowSet> {
  public:
-  static const char *kMinKeyMetaEntryName;
-  static const char *kMaxKeyMetaEntryName;
+  static constexpr const char* const kMinKeyMetaEntryName = "min_key";
+  static constexpr const char* const kMaxKeyMetaEntryName = "max_key";
 
   // Open a rowset from disk.
   // If successful, sets *rowset to the newly open rowset
@@ -335,7 +337,7 @@ class DiskRowSet :
                      log::LogAnchorRegistry* log_anchor_registry,
                      const TabletMemTrackers& mem_trackers,
                      const fs::IOContext* io_context,
-                     std::shared_ptr<DiskRowSet> *rowset);
+                     std::shared_ptr<DiskRowSet>* rowset);
 
   ////////////////////////////////////////////////////////////
   // "Management" functions
@@ -361,16 +363,16 @@ class DiskRowSet :
   // 'key' should be the key portion of the row -- i.e a contiguous
   // encoding of the key columns.
   Status MutateRow(Timestamp timestamp,
-                   const RowSetKeyProbe &probe,
-                   const RowChangeList &update,
+                   const RowSetKeyProbe& probe,
+                   const RowChangeList& update,
                    const consensus::OpId& op_id,
                    const fs::IOContext* io_context,
                    ProbeStats* stats,
                    OperationResultPB* result) override;
 
-  Status CheckRowPresent(const RowSetKeyProbe &probe,
+  Status CheckRowPresent(const RowSetKeyProbe& probe,
                          const fs::IOContext* io_context,
-                         bool *present, ProbeStats* stats) const override;
+                         bool* present, ProbeStats* stats) const override;
 
   ////////////////////
   // Read functions.
@@ -379,13 +381,13 @@ class DiskRowSet :
                         std::unique_ptr<RowwiseIterator>* out) const override;
 
   Status NewCompactionInput(const Schema* projection,
-                            const MvccSnapshot &snap,
+                            const MvccSnapshot& snap,
                             const fs::IOContext* io_context,
                             std::unique_ptr<CompactionOrFlushInput>* out) 
const override;
 
   // Gets the number of rows in this rowset, checking 'num_rows_' first. If not
   // yet set, consults the base data and stores the result in 'num_rows_'.
-  Status CountRows(const fs::IOContext* io_context, rowid_t *count) const 
final;
+  Status CountRows(const fs::IOContext* io_context, rowid_t* count) const 
final;
 
   // Count the number of live rows in this DRS.
   Status CountLiveRows(uint64_t* count) const override;
@@ -440,7 +442,7 @@ class DiskRowSet :
   // Major compacts all the delta files for all the columns.
   Status MajorCompactDeltaStores(const fs::IOContext* io_context, 
HistoryGcOpts history_gc_opts);
 
-  std::mutex *compact_flush_lock() override {
+  std::mutex* compact_flush_lock() override {
     return &compact_flush_lock_;
   }
 
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index bc6e9ad50..7145b68f1 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -2080,9 +2080,8 @@ Status Tablet::DoMergeCompactionOrFlush(const 
RowSetsInCompactionOrFlush &input,
 
   // The RollingDiskRowSet writer wrote out one or more RowSets as the
   // output. Open these into 'new_rowsets'.
-  RowSetMetadataVector new_drs_metas;
-  drsw.GetWrittenRowSetMetadata(&new_drs_metas);
-  CHECK(!new_drs_metas.empty());
+  const auto& new_drs_metas(drsw.GetWrittenRowSetMetadata());
+  DCHECK(!new_drs_metas.empty());
 
   if (metrics_) {
     metrics_->bytes_flushed->IncrementBy(drsw.written_size());
@@ -2094,7 +2093,7 @@ Status Tablet::DoMergeCompactionOrFlush(const 
RowSetsInCompactionOrFlush &input,
   new_disk_rowsets.reserve(new_drs_metas.size());
   {
     TRACE_EVENT0("tablet", "Opening compaction results");
-    for (const shared_ptr<RowSetMetadata>& meta : new_drs_metas) {
+    for (const auto& meta : new_drs_metas) {
       // TODO(awong): it'd be nice to plumb delta stats from the rowset writer
       // into the new deltafile readers opened here.
       shared_ptr<DiskRowSet> new_rowset;
@@ -2103,7 +2102,7 @@ Status Tablet::DoMergeCompactionOrFlush(const 
RowSetsInCompactionOrFlush &input,
                                   mem_trackers_,
                                   &io_context,
                                   &new_rowset);
-      if (!s.ok()) {
+      if (PREDICT_FALSE(!s.ok())) {
         LOG_WITH_PREFIX(WARNING) << "Unable to open snapshot " << op_name << " 
results "
                                  << meta->ToString() << ": " << s.ToString();
         return s;
diff --git a/src/kudu/tablet/tablet.h b/src/kudu/tablet/tablet.h
index aa6a6f999..5bb60decd 100644
--- a/src/kudu/tablet/tablet.h
+++ b/src/kudu/tablet/tablet.h
@@ -61,25 +61,23 @@
 namespace kudu {
 
 class AlterTableTest;
+class AlterTableTest_TestMajorCompactDeltasAfterAddUpdateRemoveColumn_Test;
+class AlterTableTest_TestMajorCompactDeltasAfterUpdatingRemovedColumn_Test;
+class AlterTableTest_TestMajorCompactDeltasIntoMissingBaseData_Test;
 class ConstContiguousRow;
 class EncodedKey;
 class KeyRange;
 class MemTracker;
-class RandomizedTabletHistoryGcITest;
+class RandomizedTabletHistoryGcITest_TestRandomHistoryGCWorkload_Test;
 class RowBlock;
 class ScanSpec;
 class TabletHistoryGcITest;
+class TabletHistoryGcITest_TestUndoDeltaBlockGc_Test;
 class Throttler;
 class Timestamp;
 struct IterWithBounds;
 struct IteratorStats;
 
-class AlterTableTest_TestMajorCompactDeltasAfterAddUpdateRemoveColumn_Test;
-class AlterTableTest_TestMajorCompactDeltasAfterUpdatingRemovedColumn_Test;
-class AlterTableTest_TestMajorCompactDeltasIntoMissingBaseData_Test;
-class RandomizedTabletHistoryGcITest_TestRandomHistoryGCWorkload_Test;
-class TabletHistoryGcITest_TestUndoDeltaBlockGc_Test;
-
 namespace consensus {
 class OpId;
 }  // namespace consensus
@@ -97,13 +95,12 @@ class LogAnchorRegistry;
 } // namespace log
 
 namespace tserver {
-class 
TabletServerTest_TestRecoveryWithMutationsWhileFlushingAndCompacting_Test;
 class TabletServerTest_SetEncodedKeysWhenStartingUp_Test;
 class TabletServerTest_TestEIODuringDelete_Test;
 class TabletServerTest_TestKUDU_176_RecoveryAfterMajorDeltaCompaction_Test;
 class 
TabletServerTest_TestKUDU_177_RecoveryOfDMSEditsAfterMajorDeltaCompaction_Test;
-class TabletServerTest_TestRecoveryWithMutationsWhileFlushing_Test;
 class 
TabletServerTest_TestRecoveryWithMutationsWhileFlushingAndCompacting_Test;
+class TabletServerTest_TestRecoveryWithMutationsWhileFlushing_Test;
 } // namespace tserver
 
 namespace tablet {

Reply via email to