You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2016/11/21 14:36:37 UTC

[2/4] kudu git commit: Make RowChangeListDecoder::RemoveColumnIdsFromChangeList() take a RowChangeListEncoder as an out param

Make RowChangeListDecoder::RemoveColumnIdsFromChangeList() take a RowChangeListEncoder as an out param

All the other methods in this class, of this genre, take one but
this one was taking the raw faststring buffer instead. Though it
did have the advantage of not forcing the caller to clear() the
buffer everytime it was weirdly out of place and might introduce
subtle bugs with new semantics for RowChangeListEncoder.

Change-Id: I6584b22662b58227a80eaebb7d89199d3ea2498a
Reviewed-on: http://gerrit.cloudera.org:8080/4928
Reviewed-by: Todd Lipcon <to...@apache.org>
Tested-by: David Ribeiro Alves <dr...@apache.org>


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

Branch: refs/heads/master
Commit: 01b1366e44766b61d9f562be004f0299d516b121
Parents: fd81373
Author: David Alves <dr...@apache.org>
Authored: Thu Nov 3 03:16:32 2016 -0700
Committer: David Ribeiro Alves <dr...@apache.org>
Committed: Mon Nov 21 05:43:51 2016 +0000

----------------------------------------------------------------------
 src/kudu/common/row_changelist.cc | 12 +++++-------
 src/kudu/common/row_changelist.h  |  7 +++----
 src/kudu/tablet/memrowset.cc      |  7 +++++--
 3 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/01b1366e/src/kudu/common/row_changelist.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/row_changelist.cc b/src/kudu/common/row_changelist.cc
index d5f69cc..2ca7ac4 100644
--- a/src/kudu/common/row_changelist.cc
+++ b/src/kudu/common/row_changelist.cc
@@ -168,15 +168,13 @@ Status RowChangeListDecoder::Init() {
 
 Status RowChangeListDecoder::ProjectChangeList(const DeltaProjector& projector,
                                                const RowChangeList& src,
-                                               faststring* buf) {
+                                               RowChangeListEncoder* out) {
   RowChangeListDecoder decoder(src);
   RETURN_NOT_OK(decoder.Init());
-
-  buf->clear();
-  RowChangeListEncoder encoder(buf);
+  CHECK_EQ(DCHECK_NOTNULL(out)->type_, RowChangeList::kUninitialized);
 
   if (decoder.is_delete()) {
-    encoder.SetToDelete();
+    out->SetToDelete();
     return Status::OK();
   }
 
@@ -193,8 +191,8 @@ Status RowChangeListDecoder::ProjectChangeList(const DeltaProjector& projector,
       continue;
     }
 
-    encoder.SetType(decoder.type_);
-    encoder.EncodeColumnMutationRaw(dec.col_id, dec.null, dec.raw_value);
+    out->SetType(decoder.type_);
+    out->EncodeColumnMutationRaw(dec.col_id, dec.null, dec.raw_value);
   }
 
   return Status::OK();

http://git-wip-us.apache.org/repos/asf/kudu/blob/01b1366e/src/kudu/common/row_changelist.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/row_changelist.h b/src/kudu/common/row_changelist.h
index 57566b7..ed5f536 100644
--- a/src/kudu/common/row_changelist.h
+++ b/src/kudu/common/row_changelist.h
@@ -355,12 +355,11 @@ class RowChangeListDecoder {
   }
 
   // Project the 'src' RowChangeList using the delta 'projector'
-  // The projected RowChangeList will be encoded to specified 'buf'.
-  // The buffer will be cleared before adding the result and will be empty if the projection
-  // ends up producing an empty RowChangeList.
+  // The projected RowChangeList will be encoded in 'out'.
+  // Requires that 'out' is non-null and that it's uninitialized.
   static Status ProjectChangeList(const DeltaProjector& projector,
                                   const RowChangeList& src,
-                                  faststring* buf);
+                                  RowChangeListEncoder* out);
 
   // If 'src' is an UPDATE or REINSERT, then only add changes for columns NOT specified by
   // 'column_indexes' to 'out'. Delete changes are added to 'out' as-is. If an update only

http://git-wip-us.apache.org/repos/asf/kudu/blob/01b1366e/src/kudu/tablet/memrowset.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/memrowset.cc b/src/kudu/tablet/memrowset.cc
index c787164..04cc100 100644
--- a/src/kudu/tablet/memrowset.cc
+++ b/src/kudu/tablet/memrowset.cc
@@ -599,12 +599,15 @@ Status MemRowSet::Iterator::GetCurrentRow(RowBlockRow* dst_row,
     for (const Mutation *mut = src_row.redo_head();
          mut != nullptr;
          mut = mut->acquire_next()) {
+
+      delta_buf_.clear();
+      RowChangeListEncoder enc(&delta_buf_);
       RETURN_NOT_OK(RowChangeListDecoder::ProjectChangeList(delta_projector_,
                                                             mut->changelist(),
-                                                            &delta_buf_));
+                                                            &enc));
 
       // The projection resulted in an empty mutation (e.g. update of a removed column)
-      if (delta_buf_.size() == 0) continue;
+      if (enc.is_empty()) continue;
 
       Mutation *mutation = Mutation::CreateInArena(mutation_arena,
                                                    mut->timestamp(),