You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by na...@apache.org on 2016/06/23 22:44:25 UTC

[7/9] incubator-quickstep git commit: Cache expensive numTuples() and end() results

Cache expensive numTuples() and end() results


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

Branch: refs/heads/memcpy_opt
Commit: c3159976fe5d3ee6196adccba5cfb77a19649ade
Parents: 9bb5c55
Author: Navneet Potti <na...@gmail.com>
Authored: Mon Jun 13 16:18:04 2016 -0500
Committer: Navneet Potti <na...@apache.org>
Committed: Mon Jun 13 16:25:25 2016 -0500

----------------------------------------------------------------------
 storage/ValueAccessor.hpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c3159976/storage/ValueAccessor.hpp
----------------------------------------------------------------------
diff --git a/storage/ValueAccessor.hpp b/storage/ValueAccessor.hpp
index e2a898e..b2eecd8 100644
--- a/storage/ValueAccessor.hpp
+++ b/storage/ValueAccessor.hpp
@@ -320,6 +320,8 @@ class TupleIdSequenceAdapterValueAccessor : public ValueAccessor {
       : accessor_(accessor),
         owned_accessor_(take_ownership_of_accessor ? accessor : nullptr),
         id_sequence_(id_sequence),
+        num_tuples_(id_sequence.numTuples()),
+        end_(id_sequence.end()),
         current_position_(id_sequence.before_begin()) {
   }
 
@@ -345,13 +347,12 @@ class TupleIdSequenceAdapterValueAccessor : public ValueAccessor {
   inline bool iterationFinished() const {
     TupleIdSequence::const_iterator next_position = current_position_;
     ++next_position;
-    return (current_position_ == id_sequence_.end())
-           || (next_position == id_sequence_.end());
+    return current_position_ == end_ || next_position == end_;
   }
 
   inline bool next() {
     ++current_position_;
-    return current_position_ != id_sequence_.end();
+    return current_position_ != end_;
   }
 
   inline void previous() {
@@ -367,7 +368,7 @@ class TupleIdSequenceAdapterValueAccessor : public ValueAccessor {
   }
 
   inline tuple_id getNumTuples() const {
-    return id_sequence_.numTuples();
+    return num_tuples_;
   }
 
   template <bool check_null = true>
@@ -488,6 +489,10 @@ class TupleIdSequenceAdapterValueAccessor : public ValueAccessor {
   const TupleIdSequence &id_sequence_;
   TupleIdSequence::const_iterator current_position_;
 
+  // The two members below are cached to avoid expensive function calls
+  const std::size_t num_tuples_;
+  const TupleIdSequence::const_iterator end_;
+
   DISALLOW_COPY_AND_ASSIGN(TupleIdSequenceAdapterValueAccessor);
 };