kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [3/3] incubator-kudu git commit: generic_iterators: remove unnecessary shared_ptr
Date Tue, 17 May 2016 17:51:22 GMT
generic_iterators: remove unnecessary shared_ptr

This removes another case where we used vector<shared_ptr<...>> to work
around the lack of unique_ptr pre-C++11.

Change-Id: If700532645103f61395bd1797303ebcdf596b8fc
Reviewed-on: http://gerrit.cloudera.org:8080/3099
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/e53fa21a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/e53fa21a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/e53fa21a

Branch: refs/heads/master
Commit: e53fa21a2b32ebcbb9033a3aeb6d26a2a453f68c
Parents: 6d6013b
Author: Todd Lipcon <todd@apache.org>
Authored: Mon May 16 22:25:37 2016 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Tue May 17 17:51:02 2016 +0000

----------------------------------------------------------------------
 src/kudu/common/generic_iterators.cc | 13 ++++++++-----
 src/kudu/common/generic_iterators.h  |  3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/e53fa21a/src/kudu/common/generic_iterators.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/generic_iterators.cc b/src/kudu/common/generic_iterators.cc
index bdabd1c..4be0a5d 100644
--- a/src/kudu/common/generic_iterators.cc
+++ b/src/kudu/common/generic_iterators.cc
@@ -37,6 +37,7 @@ using std::remove_if;
 using std::shared_ptr;
 using std::sort;
 using std::string;
+using std::unique_ptr;
 using std::tuple;
 
 DEFINE_bool(materializing_iterator_do_pushdown, true,
@@ -160,13 +161,15 @@ MergeIterator::MergeIterator(
   orig_iters_.assign(iters.begin(), iters.end());
 }
 
+MergeIterator::~MergeIterator() {}
+
 Status MergeIterator::Init(ScanSpec *spec) {
   CHECK(!initted_);
   // TODO: check that schemas match up!
 
   RETURN_NOT_OK(InitSubIterators(spec));
 
-  for (shared_ptr<MergeIterState> &state : iters_) {
+  for (unique_ptr<MergeIterState> &state : iters_) {
     RETURN_NOT_OK(state->PullNextBlock());
   }
 
@@ -174,7 +177,7 @@ Status MergeIterator::Init(ScanSpec *spec) {
   // to start with. Otherwise, HasNext() won't properly return false
   // if we were passed only empty iterators.
   iters_.erase(
-      remove_if(iters_.begin(), iters_.end(), [] (const shared_ptr<MergeIterState>&
iter) {
+      remove_if(iters_.begin(), iters_.end(), [] (const unique_ptr<MergeIterState>&
iter) {
         return PREDICT_FALSE(iter->IsFullyExhausted());
       }),
       iters_.end());
@@ -193,7 +196,7 @@ Status MergeIterator::InitSubIterators(ScanSpec *spec) {
   for (shared_ptr<RowwiseIterator> &iter : orig_iters_) {
     ScanSpec *spec_copy = spec != nullptr ? scan_spec_copies_.Construct(*spec) : nullptr;
     RETURN_NOT_OK(PredicateEvaluatingIterator::InitAndMaybeWrap(&iter, spec_copy));
-    iters_.push_back(shared_ptr<MergeIterState>(new MergeIterState(iter)));
+    iters_.push_back(unique_ptr<MergeIterState>(new MergeIterState(iter)));
   }
 
   // Since we handle predicates in all the wrapped iterators, we can clear
@@ -222,7 +225,7 @@ void MergeIterator::PrepareBatch(RowBlock* dst) {
   // We can always provide at least as many rows as are remaining
   // in the currently queued up blocks.
   size_t available = 0;
-  for (shared_ptr<MergeIterState> &iter : iters_) {
+  for (unique_ptr<MergeIterState> &iter : iters_) {
     available += iter->remaining_in_block();
   }
 
@@ -246,7 +249,7 @@ Status MergeIterator::MaterializeBlock(RowBlock *dst) {
     // Typically the number of iters_ is not that large, so using a priority
     // queue is not worth it
     for (size_t i = 0; i < iters_.size(); i++) {
-      shared_ptr<MergeIterState> &state = iters_[i];
+      unique_ptr<MergeIterState> &state = iters_[i];
 
       if (smallest == nullptr ||
           schema_.Compare(state->next_row(), smallest->next_row()) < 0) {

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/e53fa21a/src/kudu/common/generic_iterators.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/generic_iterators.h b/src/kudu/common/generic_iterators.h
index bd4a162..3356a6f 100644
--- a/src/kudu/common/generic_iterators.h
+++ b/src/kudu/common/generic_iterators.h
@@ -43,6 +43,7 @@ class MergeIterator : public RowwiseIterator {
   // a subset of the columns in 'iters'.
   MergeIterator(const Schema &schema,
                 const std::vector<std::shared_ptr<RowwiseIterator> > &iters);
+  virtual ~MergeIterator();
 
   // The passed-in iterators should be already initialized.
   Status Init(ScanSpec *spec) OVERRIDE;
@@ -69,7 +70,7 @@ class MergeIterator : public RowwiseIterator {
   // Holds the subiterators until Init is called.
   // This is required because we can't create a MergeIterState of an uninitialized iterator.
   std::deque<std::shared_ptr<RowwiseIterator> > orig_iters_;
-  std::vector<std::shared_ptr<MergeIterState> > iters_;
+  std::vector<std::unique_ptr<MergeIterState> > iters_;
 
   // When the underlying iterators are initialized, each needs its own
   // copy of the scan spec in order to do its own pushdown calculations, etc.


Mime
View raw message