kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [2/3] incubator-kudu git commit: Stop using shared_ptr<DeltaIterator>
Date Tue, 17 May 2016 17:51:21 GMT
Stop using shared_ptr<DeltaIterator>

These objects were never shared, but shared_ptr was used long ago because we
were unable to put scoped pointers inside vectors.  Now with C++11 we can use
unique_ptr and avoid these unnecessary shared_ptrs.

This might have a small performance improvement due to reduced atomics, but
more importantly it makes it obvious that these are single-owner objects.

Change-Id: I9293fe20403a21f483ec9bfe0dd39b8e614fbd68
Reviewed-on: http://gerrit.cloudera.org:8080/3098
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <adar@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/6d6013b9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/6d6013b9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/6d6013b9

Branch: refs/heads/master
Commit: 6d6013b9124299206bcc266bb0c3201e88815a0d
Parents: 3aedf35
Author: Todd Lipcon <todd@apache.org>
Authored: Mon May 16 22:17:36 2016 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Tue May 17 17:50:56 2016 +0000

----------------------------------------------------------------------
 src/kudu/tablet/compaction.cc            | 17 +++++++++------
 src/kudu/tablet/delta_applier.cc         |  3 ++-
 src/kudu/tablet/delta_applier.h          |  4 ++--
 src/kudu/tablet/delta_compaction-test.cc |  3 ++-
 src/kudu/tablet/delta_compaction.cc      |  3 ++-
 src/kudu/tablet/delta_compaction.h       |  4 ++--
 src/kudu/tablet/delta_iterator_merger.cc | 31 ++++++++++++++-------------
 src/kudu/tablet/delta_iterator_merger.h  |  6 +++---
 src/kudu/tablet/delta_tracker.cc         | 13 +++++------
 src/kudu/tablet/delta_tracker.h          | 11 ++++------
 src/kudu/tablet/diskrowset-test.cc       |  5 +++--
 src/kudu/tablet/diskrowset.cc            |  5 +++--
 12 files changed, 56 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/compaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/compaction.cc b/src/kudu/tablet/compaction.cc
index af349f7..0af47ca 100644
--- a/src/kudu/tablet/compaction.cc
+++ b/src/kudu/tablet/compaction.cc
@@ -39,6 +39,7 @@
 #include "kudu/util/debug/trace_event.h"
 
 using std::shared_ptr;
+using std::unique_ptr;
 using std::unordered_set;
 using strings::Substitute;
 
@@ -134,8 +135,8 @@ class MemRowSetCompactionInput : public CompactionInput {
 class DiskRowSetCompactionInput : public CompactionInput {
  public:
   DiskRowSetCompactionInput(gscoped_ptr<RowwiseIterator> base_iter,
-                            shared_ptr<DeltaIterator> redo_delta_iter,
-                            shared_ptr<DeltaIterator> undo_delta_iter)
+                            unique_ptr<DeltaIterator> redo_delta_iter,
+                            unique_ptr<DeltaIterator> undo_delta_iter)
       : base_iter_(std::move(base_iter)),
         redo_delta_iter_(std::move(redo_delta_iter)),
         undo_delta_iter_(std::move(undo_delta_iter)),
@@ -198,8 +199,8 @@ class DiskRowSetCompactionInput : public CompactionInput {
  private:
   DISALLOW_COPY_AND_ASSIGN(DiskRowSetCompactionInput);
   gscoped_ptr<RowwiseIterator> base_iter_;
-  shared_ptr<DeltaIterator> redo_delta_iter_;
-  shared_ptr<DeltaIterator> undo_delta_iter_;
+  unique_ptr<DeltaIterator> redo_delta_iter_;
+  unique_ptr<DeltaIterator> undo_delta_iter_;
 
   Arena arena_;
 
@@ -527,17 +528,19 @@ Status CompactionInput::Create(const DiskRowSet &rowset,
   gscoped_ptr<RowwiseIterator> base_iter(new MaterializingIterator(base_cwise));
 
   // Creates a DeltaIteratorMerger that will only include the relevant REDO deltas.
-  shared_ptr<DeltaIterator> redo_deltas;
+  unique_ptr<DeltaIterator> redo_deltas;
   RETURN_NOT_OK_PREPEND(rowset.delta_tracker_->NewDeltaIterator(
       projection, snap, DeltaTracker::REDOS_ONLY, &redo_deltas), "Could not open REDOs");
   // Creates a DeltaIteratorMerger that will only include UNDO deltas. Using the
   // "empty" snapshot ensures that all deltas are included.
-  shared_ptr<DeltaIterator> undo_deltas;
+  unique_ptr<DeltaIterator> undo_deltas;
   RETURN_NOT_OK_PREPEND(rowset.delta_tracker_->NewDeltaIterator(
       projection, MvccSnapshot::CreateSnapshotIncludingNoTransactions(),
       DeltaTracker::UNDOS_ONLY, &undo_deltas), "Could not open UNDOs");
 
-  out->reset(new DiskRowSetCompactionInput(std::move(base_iter), redo_deltas, undo_deltas));
+  out->reset(new DiskRowSetCompactionInput(std::move(base_iter),
+                                           std::move(redo_deltas),
+                                           std::move(undo_deltas)));
   return Status::OK();
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_applier.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_applier.cc b/src/kudu/tablet/delta_applier.cc
index 7439b10..35afef7 100644
--- a/src/kudu/tablet/delta_applier.cc
+++ b/src/kudu/tablet/delta_applier.cc
@@ -26,13 +26,14 @@
 
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 
 namespace kudu {
 namespace tablet {
 
   // Construct. The base_iter and delta_iter should not be Initted.
 DeltaApplier::DeltaApplier(shared_ptr<CFileSet::Iterator> base_iter,
-                           shared_ptr<DeltaIterator> delta_iter)
+                           unique_ptr<DeltaIterator> delta_iter)
     : base_iter_(std::move(base_iter)),
       delta_iter_(std::move(delta_iter)),
       first_prepare_(true) {}

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_applier.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_applier.h b/src/kudu/tablet/delta_applier.h
index 5877978..b5bcca3 100644
--- a/src/kudu/tablet/delta_applier.h
+++ b/src/kudu/tablet/delta_applier.h
@@ -71,11 +71,11 @@ class DeltaApplier : public ColumnwiseIterator {
 
   // Construct. The base_iter and delta_iter should not be Initted.
   DeltaApplier(std::shared_ptr<CFileSet::Iterator> base_iter,
-               std::shared_ptr<DeltaIterator> delta_iter);
+               std::unique_ptr<DeltaIterator> delta_iter);
   virtual ~DeltaApplier();
 
   std::shared_ptr<CFileSet::Iterator> base_iter_;
-  std::shared_ptr<DeltaIterator> delta_iter_;
+  std::unique_ptr<DeltaIterator> delta_iter_;
 
   bool first_prepare_;
 };

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_compaction-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_compaction-test.cc b/src/kudu/tablet/delta_compaction-test.cc
index 87ddcc2..c5aceab 100644
--- a/src/kudu/tablet/delta_compaction-test.cc
+++ b/src/kudu/tablet/delta_compaction-test.cc
@@ -42,6 +42,7 @@ DEFINE_int32(num_delta_files, 3, "number of delta files");
 using std::is_sorted;
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 using std::vector;
 
 namespace kudu {
@@ -181,7 +182,7 @@ TEST_F(TestDeltaCompaction, TestMergeMultipleSchemas) {
   // Merge
   MvccSnapshot snap(MvccSnapshot::CreateSnapshotIncludingAllTransactions());
   const Schema& merge_schema = schemas.back();
-  shared_ptr<DeltaIterator> merge_iter;
+  unique_ptr<DeltaIterator> merge_iter;
   ASSERT_OK(DeltaIteratorMerger::Create(inputs, &merge_schema,
                                         snap, &merge_iter));
   gscoped_ptr<DeltaFileWriter> dfw;

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_compaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_compaction.cc b/src/kudu/tablet/delta_compaction.cc
index 321cccf..df1e95a 100644
--- a/src/kudu/tablet/delta_compaction.cc
+++ b/src/kudu/tablet/delta_compaction.cc
@@ -43,6 +43,7 @@ using cfile::CFileIterator;
 using cfile::CFileReader;
 using cfile::IndexTreeIterator;
 using fs::WritableBlock;
+using std::unique_ptr;
 using std::vector;
 using strings::Substitute;
 
@@ -58,7 +59,7 @@ const size_t kRowsPerBlock = 100; // Number of rows per block of columns
 // to materialize it? should write a test for this.
 MajorDeltaCompaction::MajorDeltaCompaction(
     FsManager* fs_manager, const Schema& base_schema, CFileSet* base_data,
-    shared_ptr<DeltaIterator> delta_iter,
+    unique_ptr<DeltaIterator> delta_iter,
     vector<shared_ptr<DeltaStore> > included_stores,
     const vector<ColumnId>& col_ids)
     : fs_manager_(fs_manager),

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_compaction.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_compaction.h b/src/kudu/tablet/delta_compaction.h
index d8571f1..d797072 100644
--- a/src/kudu/tablet/delta_compaction.h
+++ b/src/kudu/tablet/delta_compaction.h
@@ -54,7 +54,7 @@ class MajorDeltaCompaction {
   // in an ALTER scenario?
   MajorDeltaCompaction(
       FsManager* fs_manager, const Schema& base_schema, CFileSet* base_data,
-      std::shared_ptr<DeltaIterator> delta_iter,
+      std::unique_ptr<DeltaIterator> delta_iter,
       std::vector<std::shared_ptr<DeltaStore> > included_stores,
       const std::vector<ColumnId>& col_ids);
   ~MajorDeltaCompaction();
@@ -113,7 +113,7 @@ class MajorDeltaCompaction {
   const SharedDeltaStoreVector included_stores_;
 
   // The merged view of the deltas from included_stores_.
-  const std::shared_ptr<DeltaIterator> delta_iter_;
+  const std::unique_ptr<DeltaIterator> delta_iter_;
 
   // Outputs:
   gscoped_ptr<MultiColumnWriter> base_data_writer_;

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_iterator_merger.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_iterator_merger.cc b/src/kudu/tablet/delta_iterator_merger.cc
index 9ce37fd..582917f 100644
--- a/src/kudu/tablet/delta_iterator_merger.cc
+++ b/src/kudu/tablet/delta_iterator_merger.cc
@@ -29,50 +29,51 @@ namespace tablet {
 
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 using std::vector;
 using strings::Substitute;
 
 DeltaIteratorMerger::DeltaIteratorMerger(
-    vector<shared_ptr<DeltaIterator> > iters)
+    vector<unique_ptr<DeltaIterator> > iters)
     : iters_(std::move(iters)) {}
 
 Status DeltaIteratorMerger::Init(ScanSpec *spec) {
-  for (const shared_ptr<DeltaIterator> &iter : iters_) {
+  for (const unique_ptr<DeltaIterator> &iter : iters_) {
     RETURN_NOT_OK(iter->Init(spec));
   }
   return Status::OK();
 }
 
 Status DeltaIteratorMerger::SeekToOrdinal(rowid_t idx) {
-  for (const shared_ptr<DeltaIterator> &iter : iters_) {
+  for (const unique_ptr<DeltaIterator> &iter : iters_) {
     RETURN_NOT_OK(iter->SeekToOrdinal(idx));
   }
   return Status::OK();
 }
 
 Status DeltaIteratorMerger::PrepareBatch(size_t nrows, PrepareFlag flag) {
-  for (const shared_ptr<DeltaIterator> &iter : iters_) {
+  for (const unique_ptr<DeltaIterator> &iter : iters_) {
     RETURN_NOT_OK(iter->PrepareBatch(nrows, flag));
   }
   return Status::OK();
 }
 
 Status DeltaIteratorMerger::ApplyUpdates(size_t col_to_apply, ColumnBlock *dst) {
-  for (const shared_ptr<DeltaIterator> &iter : iters_) {
+  for (const unique_ptr<DeltaIterator> &iter : iters_) {
     RETURN_NOT_OK(iter->ApplyUpdates(col_to_apply, dst));
   }
   return Status::OK();
 }
 
 Status DeltaIteratorMerger::ApplyDeletes(SelectionVector *sel_vec) {
-  for (const shared_ptr<DeltaIterator> &iter : iters_) {
+  for (const unique_ptr<DeltaIterator> &iter : iters_) {
     RETURN_NOT_OK(iter->ApplyDeletes(sel_vec));
   }
   return Status::OK();
 }
 
 Status DeltaIteratorMerger::CollectMutations(vector<Mutation *> *dst, Arena *arena)
{
-  for (const shared_ptr<DeltaIterator> &iter : iters_) {
+  for (const unique_ptr<DeltaIterator> &iter : iters_) {
     RETURN_NOT_OK(iter->CollectMutations(dst, arena));
   }
   // TODO: do we need to do some kind of sorting here to deal with out-of-order
@@ -90,7 +91,7 @@ Status DeltaIteratorMerger::FilterColumnIdsAndCollectDeltas(
     const vector<ColumnId>& col_ids,
     vector<DeltaKeyAndUpdate>* out,
     Arena* arena) {
-  for (const shared_ptr<DeltaIterator>& iter : iters_) {
+  for (const unique_ptr<DeltaIterator>& iter : iters_) {
     RETURN_NOT_OK(iter->FilterColumnIdsAndCollectDeltas(col_ids, out, arena));
   }
   // We use a stable sort here since an input may include multiple deltas for the
@@ -101,7 +102,7 @@ Status DeltaIteratorMerger::FilterColumnIdsAndCollectDeltas(
 }
 
 bool DeltaIteratorMerger::HasNext() {
-  for (const shared_ptr<DeltaIterator>& iter : iters_) {
+  for (const unique_ptr<DeltaIterator>& iter : iters_) {
     if (iter->HasNext()) {
       return true;
     }
@@ -115,7 +116,7 @@ string DeltaIteratorMerger::ToString() const {
   ret.append("DeltaIteratorMerger(");
 
   bool first = true;
-  for (const shared_ptr<DeltaIterator> &iter : iters_) {
+  for (const unique_ptr<DeltaIterator> &iter : iters_) {
     if (!first) {
       ret.append(", ");
     }
@@ -132,8 +133,8 @@ Status DeltaIteratorMerger::Create(
     const vector<shared_ptr<DeltaStore> > &stores,
     const Schema* projection,
     const MvccSnapshot &snapshot,
-    shared_ptr<DeltaIterator>* out) {
-  vector<shared_ptr<DeltaIterator> > delta_iters;
+    unique_ptr<DeltaIterator>* out) {
+  vector<unique_ptr<DeltaIterator> > delta_iters;
 
   for (const shared_ptr<DeltaStore> &store : stores) {
     DeltaIterator* raw_iter;
@@ -144,15 +145,15 @@ Status DeltaIteratorMerger::Create(
     RETURN_NOT_OK_PREPEND(s, Substitute("Could not create iterator for store $0",
                                         store->ToString()));
 
-    delta_iters.push_back(shared_ptr<DeltaIterator>(raw_iter));
+    delta_iters.push_back(unique_ptr<DeltaIterator>(raw_iter));
   }
 
   if (delta_iters.size() == 1) {
     // If we only have one input to the "merge", we can just directly
     // return that iterator.
-    *out = delta_iters[0];
+    *out = std::move(delta_iters[0]);
   } else {
-    *out = shared_ptr<DeltaIterator>(new DeltaIteratorMerger(delta_iters));
+    out->reset(new DeltaIteratorMerger(std::move(delta_iters)));
   }
   return Status::OK();
 }

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_iterator_merger.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_iterator_merger.h b/src/kudu/tablet/delta_iterator_merger.h
index e703447..be7f746 100644
--- a/src/kudu/tablet/delta_iterator_merger.h
+++ b/src/kudu/tablet/delta_iterator_merger.h
@@ -42,7 +42,7 @@ class DeltaIteratorMerger : public DeltaIterator {
       const std::vector<std::shared_ptr<DeltaStore> > &stores,
       const Schema* projection,
       const MvccSnapshot &snapshot,
-      std::shared_ptr<DeltaIterator>* out);
+      std::unique_ptr<DeltaIterator>* out);
 
   ////////////////////////////////////////////////////////////
   // Implementations of DeltaIterator
@@ -60,9 +60,9 @@ class DeltaIteratorMerger : public DeltaIterator {
   virtual std::string ToString() const OVERRIDE;
 
  private:
-  explicit DeltaIteratorMerger(vector<std::shared_ptr<DeltaIterator> > iters);
+  explicit DeltaIteratorMerger(vector<std::unique_ptr<DeltaIterator> > iters);
 
-  std::vector<std::shared_ptr<DeltaIterator> > iters_;
+  std::vector<std::unique_ptr<DeltaIterator> > iters_;
 };
 
 } // namespace tablet

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_tracker.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_tracker.cc b/src/kudu/tablet/delta_tracker.cc
index 0b940d9..dc77a55 100644
--- a/src/kudu/tablet/delta_tracker.cc
+++ b/src/kudu/tablet/delta_tracker.cc
@@ -38,6 +38,7 @@ using fs::ReadableBlock;
 using fs::WritableBlock;
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 using strings::Substitute;
 
 DeltaTracker::DeltaTracker(shared_ptr<RowSetMetadata> rowset_metadata,
@@ -109,7 +110,7 @@ Status DeltaTracker::MakeDeltaIteratorMergerUnlocked(size_t start_idx,
size_t en
                                                      const Schema* projection,
                                                      vector<shared_ptr<DeltaStore>
> *target_stores,
                                                      vector<BlockId> *target_blocks,
-                                                     std::shared_ptr<DeltaIterator>
*out) {
+                                                     std::unique_ptr<DeltaIterator>
*out) {
   CHECK(open_);
   CHECK_LE(start_idx, end_idx);
   CHECK_LT(end_idx, redo_delta_stores_.size());
@@ -249,7 +250,7 @@ Status DeltaTracker::DoCompactStores(size_t start_idx, size_t end_idx,
          gscoped_ptr<WritableBlock> block,
          vector<shared_ptr<DeltaStore> > *compacted_stores,
          vector<BlockId> *compacted_blocks) {
-  shared_ptr<DeltaIterator> inputs_merge;
+  unique_ptr<DeltaIterator> inputs_merge;
 
   // Currently, DeltaFile iterators ignore the passed-in projection in
   // FilterColumnIdsAndCollectDeltas(). So, we just pass an empty schema here.
@@ -284,7 +285,7 @@ void DeltaTracker::CollectStores(vector<shared_ptr<DeltaStore>>*
deltas,
 Status DeltaTracker::NewDeltaIterator(const Schema* schema,
                                       const MvccSnapshot& snap,
                                       WhichStores which,
-                                      shared_ptr<DeltaIterator>* out) const {
+                                      unique_ptr<DeltaIterator>* out) const {
   std::vector<shared_ptr<DeltaStore> > stores;
   CollectStores(&stores, which);
   return DeltaIteratorMerger::Create(stores, schema, snap, out);
@@ -295,7 +296,7 @@ Status DeltaTracker::NewDeltaFileIterator(
     const MvccSnapshot& snap,
     DeltaType type,
     vector<shared_ptr<DeltaStore> >* included_stores,
-    shared_ptr<DeltaIterator>* out) const {
+    unique_ptr<DeltaIterator>* out) const {
   {
     lock_guard<rw_spinlock> lock(&component_lock_);
     // TODO perf: is this really needed? Will check
@@ -323,10 +324,10 @@ Status DeltaTracker::NewDeltaFileIterator(
 Status DeltaTracker::WrapIterator(const shared_ptr<CFileSet::Iterator> &base,
                                   const MvccSnapshot &mvcc_snap,
                                   gscoped_ptr<ColumnwiseIterator>* out) const {
-  shared_ptr<DeltaIterator> iter;
+  unique_ptr<DeltaIterator> iter;
   RETURN_NOT_OK(NewDeltaIterator(&base->schema(), mvcc_snap, &iter));
 
-  out->reset(new DeltaApplier(base, iter));
+  out->reset(new DeltaApplier(base, std::move(iter)));
   return Status::OK();
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/delta_tracker.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_tracker.h b/src/kudu/tablet/delta_tracker.h
index d4e571b..c60ee0a 100644
--- a/src/kudu/tablet/delta_tracker.h
+++ b/src/kudu/tablet/delta_tracker.h
@@ -91,17 +91,14 @@ class DeltaTracker {
   //
   // 'schema' is the schema of the rows that are being read by the client.
   // It must remain valid for the lifetime of the returned iterator.
-  //
-  // TODO: this shouldn't need to return a shared_ptr, but there is some messiness
-  // where this has bled around.
   Status NewDeltaIterator(const Schema* schema,
                           const MvccSnapshot& snap,
                           WhichStores which,
-                          std::shared_ptr<DeltaIterator>* out) const;
+                          std::unique_ptr<DeltaIterator>* out) const;
 
   Status NewDeltaIterator(const Schema* schema,
                           const MvccSnapshot& snap,
-                          std::shared_ptr<DeltaIterator>* out) const {
+                          std::unique_ptr<DeltaIterator>* out) const {
     return NewDeltaIterator(schema, snap, UNDOS_AND_REDOS, out);
   }
 
@@ -114,7 +111,7 @@ class DeltaTracker {
     const MvccSnapshot &snap,
     DeltaType type,
     std::vector<std::shared_ptr<DeltaStore> >* included_stores,
-    std::shared_ptr<DeltaIterator>* out) const;
+    std::unique_ptr<DeltaIterator>* out) const;
 
   Status Open();
 
@@ -239,7 +236,7 @@ class DeltaTracker {
                                          const Schema* schema,
                                          vector<std::shared_ptr<DeltaStore > >
*target_stores,
                                          vector<BlockId> *target_blocks,
-                                         std::shared_ptr<DeltaIterator> *out);
+                                         std::unique_ptr<DeltaIterator> *out);
 
   std::shared_ptr<RowSetMetadata> rowset_metadata_;
 

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/diskrowset-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/diskrowset-test.cc b/src/kudu/tablet/diskrowset-test.cc
index 72273fa..fa36df4 100644
--- a/src/kudu/tablet/diskrowset-test.cc
+++ b/src/kudu/tablet/diskrowset-test.cc
@@ -41,6 +41,7 @@ DECLARE_int32(tablet_delta_store_minor_compact_max);
 
 using std::is_sorted;
 using std::shared_ptr;
+using std::unique_ptr;
 using std::unordered_set;
 
 namespace kudu {
@@ -446,7 +447,7 @@ TEST_F(TestRowSet, TestMakeDeltaIteratorMergerUnlocked) {
   int num_stores = dt->redo_delta_stores_.size();
   vector<shared_ptr<DeltaStore> > compacted_stores;
   vector<BlockId> compacted_blocks;
-  shared_ptr<DeltaIterator> merge_iter;
+  unique_ptr<DeltaIterator> merge_iter;
   ASSERT_OK(dt->MakeDeltaIteratorMergerUnlocked(0, num_stores - 1, &schema_,
                                                        &compacted_stores,
                                                        &compacted_blocks, &merge_iter));
@@ -521,7 +522,7 @@ TEST_F(TestRowSet, TestCompactStores) {
   // Verify that the resulting deltafile is valid
   vector<shared_ptr<DeltaStore> > compacted_stores;
   vector<BlockId> compacted_blocks;
-  shared_ptr<DeltaIterator> merge_iter;
+  unique_ptr<DeltaIterator> merge_iter;
   ASSERT_OK(dt->MakeDeltaIteratorMergerUnlocked(0, num_stores - 1, &schema_,
                                                        &compacted_stores,
                                                        &compacted_blocks, &merge_iter));

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/6d6013b9/src/kudu/tablet/diskrowset.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/diskrowset.cc b/src/kudu/tablet/diskrowset.cc
index a933083..5bbf2e7 100644
--- a/src/kudu/tablet/diskrowset.cc
+++ b/src/kudu/tablet/diskrowset.cc
@@ -63,6 +63,7 @@ using fs::WritableBlock;
 using log::LogAnchorRegistry;
 using std::shared_ptr;
 using std::string;
+using std::unique_ptr;
 
 const char *DiskRowSet::kMinKeyMetaEntryName = "min_key";
 const char *DiskRowSet::kMaxKeyMetaEntryName = "max_key";
@@ -554,7 +555,7 @@ Status DiskRowSet::NewMajorDeltaCompaction(const vector<ColumnId>&
col_ids,
   const Schema* schema = &rowset_metadata_->tablet_schema();
 
   vector<shared_ptr<DeltaStore> > included_stores;
-  shared_ptr<DeltaIterator> delta_iter;
+  unique_ptr<DeltaIterator> delta_iter;
   RETURN_NOT_OK(delta_tracker_->NewDeltaFileIterator(
     schema,
     MvccSnapshot::CreateSnapshotIncludingAllTransactions(),
@@ -565,7 +566,7 @@ Status DiskRowSet::NewMajorDeltaCompaction(const vector<ColumnId>&
col_ids,
   out->reset(new MajorDeltaCompaction(rowset_metadata_->fs_manager(),
                                       *schema,
                                       base_data_.get(),
-                                      delta_iter,
+                                      std::move(delta_iter),
                                       included_stores,
                                       col_ids));
   return Status::OK();


Mime
View raw message