Repository: kudu
Updated Branches:
  refs/heads/master ba2ae3de4 -> 1db453f54


Consolidate Row/CompactionInputRow printing on compaction

We are duplicating row printing code in a lot of places. This adds
a couple of methods to avoid that.

Change-Id: Ifd9f59094ac1f5f9c6343c77771d5770dcc089f9
Reviewed-on: http://gerrit.cloudera.org:8080/4988
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <[email protected]>


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

Branch: refs/heads/master
Commit: ff7d5621d9a73f5dceb2326e59bdc1b2bcdcc5fa
Parents: ba2ae3d
Author: David Alves <[email protected]>
Authored: Sun Nov 6 10:49:04 2016 -0800
Committer: David Ribeiro Alves <[email protected]>
Committed: Thu Nov 10 18:47:31 2016 +0000

----------------------------------------------------------------------
 src/kudu/tablet/compaction.cc       | 36 ++++++++++++++++----------------
 src/kudu/tablet/compaction.h        |  4 ++++
 src/kudu/tablet/delta_compaction.cc | 13 ++----------
 3 files changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/ff7d5621/src/kudu/tablet/compaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/compaction.cc b/src/kudu/tablet/compaction.cc
index 53bf505..addea71 100644
--- a/src/kudu/tablet/compaction.cc
+++ b/src/kudu/tablet/compaction.cc
@@ -521,6 +521,17 @@ class MergeCompactionInput : public CompactionInput {
 
 } // anonymous namespace
 
+string RowToString(const RowBlockRow& row, const Mutation* redo_head, const 
Mutation* undo_head) {
+  return Substitute("RowIdxInBlock: $0; Base: $1; Undo Mutations: $2; Redo 
Mutations: $3;",
+                    row.row_index(), row.schema()->DebugRow(row),
+                    Mutation::StringifyMutationList(*row.schema(), undo_head),
+                    Mutation::StringifyMutationList(*row.schema(), redo_head));
+}
+
+string CompactionInputRowToString(const CompactionInputRow& input_row) {
+  return RowToString(input_row.row, input_row.redo_head, input_row.undo_head);
+}
+
 ////////////////////////////////////////////////////////////
 
 Status CompactionInput::Create(const DiskRowSet &rowset,
@@ -641,12 +652,9 @@ Status ApplyMutationsAndGenerateUndos(const MvccSnapshot& 
snap,
   bool is_deleted = false;
 
   #define ERROR_LOG_CONTEXT \
-    "Source Row: " << dst_schema->DebugRow(src_row.row) << \
-    " Redo Mutations: " << Mutation::StringifyMutationList(*base_schema, 
src_row.redo_head) << \
-    " Undo Mutations: " << Mutation::StringifyMutationList(*base_schema, 
src_row.undo_head) << \
-    "\nDest Row: " << dst_schema->DebugRow(*dst_row) << \
-    " Redo Mutations: " << Mutation::StringifyMutationList(*dst_schema, 
redo_head) << \
-    " Undo Mutations: " << Mutation::StringifyMutationList(*dst_schema, 
undo_head)
+    Substitute("Source Row: $0\nDest Row: $1", \
+                CompactionInputRowToString(src_row), \
+                RowToString(*dst_row, undo_head, redo_head))
 
   faststring dst;
   RowChangeListEncoder undo_encoder(&dst);
@@ -812,10 +820,7 @@ Status FlushCompactionInput(CompactionInput* input,
       RowBlockRow dst_row = block.row(n);
       RETURN_NOT_OK(CopyRow(input_row->row, &dst_row, 
static_cast<Arena*>(nullptr)));
 
-      DVLOG(3) << "Input Row: " << dst_row.schema()->DebugRow(dst_row) <<
-        " RowIndex: " << input_row->row.row_index() <<
-        " Undo Mutations: " << Mutation::StringifyMutationList(*schema, 
input_row->undo_head) <<
-        " Redo Mutations: " << Mutation::StringifyMutationList(*schema, 
input_row->redo_head);
+      DVLOG(4) << "Input Row: " << CompactionInputRowToString(*input_row);
 
       // Collect the new UNDO/REDO mutations.
       Mutation* new_undos_head = nullptr;
@@ -835,10 +840,7 @@ Status FlushCompactionInput(CompactionInput* input,
                                                    &is_garbage_collected,
                                                    
&num_rows_history_truncated));
 
-      DVLOG(4) << "Output Row: " << dst_row.schema()->DebugRow(dst_row) <<
-          "; RowIndex: " << dst_row.row_index() <<
-          "; Undo Mutations: " << Mutation::StringifyMutationList(*schema, 
new_undos_head) <<
-          "; Redo Mutations: " << Mutation::StringifyMutationList(*schema, 
new_redos_head) <<
+      DVLOG(4) << "Output Row: " << RowToString(dst_row, new_redos_head, 
new_undos_head) <<
           "; Was garbage collected? " << is_garbage_collected <<
           "; Was history truncated? " <<
               (num_rows_history_truncated > prev_num_rows_history_truncated);
@@ -859,7 +861,7 @@ Status FlushCompactionInput(CompactionInput* input,
         out->AppendRedoDeltas(dst_row.row_index(), new_redos_head, 
&index_in_current_drs);
       }
 
-      DVLOG(5) << "Output Row: " << dst_row.schema()->DebugRow(dst_row)
+      DVLOG(4) << "Output Row: " << dst_row.schema()->DebugRow(dst_row)
                << "; RowId: " << index_in_current_drs;
 
       n++;
@@ -929,9 +931,7 @@ Status ReupdateMissedDeltas(const string &tablet_name,
     RETURN_NOT_OK(input->PrepareBlock(&rows));
 
     for (const CompactionInputRow &row : rows) {
-      DVLOG(4) << "Revisiting row: " << schema->DebugRow(row.row) <<
-          " Redo Mutations: " << Mutation::StringifyMutationList(*schema, 
row.redo_head) <<
-          " Undo Mutations: " << Mutation::StringifyMutationList(*schema, 
row.undo_head);
+      DVLOG(4) << "Revisiting row: " << CompactionInputRowToString(row);
 
       bool is_garbage_collected = false;
       for (const Mutation *mut = row.redo_head;

http://git-wip-us.apache.org/repos/asf/kudu/blob/ff7d5621/src/kudu/tablet/compaction.h
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/compaction.h b/src/kudu/tablet/compaction.h
index b706879..66634e6 100644
--- a/src/kudu/tablet/compaction.h
+++ b/src/kudu/tablet/compaction.h
@@ -231,6 +231,10 @@ Status ReupdateMissedDeltas(const string &tablet_name,
 // This consumes all of the input in the compaction input.
 Status DebugDumpCompactionInput(CompactionInput *input, vector<string> *lines);
 
+// Helper methods to print a row with full history.
+string RowToString(const RowBlockRow& row, const Mutation* redo_head, const 
Mutation* undo_head);
+string CompactionInputRowToString(const CompactionInputRow& input_row);
+
 } // namespace tablet
 } // namespace kudu
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/ff7d5621/src/kudu/tablet/delta_compaction.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_compaction.cc 
b/src/kudu/tablet/delta_compaction.cc
index 2c753c7..243426c 100644
--- a/src/kudu/tablet/delta_compaction.cc
+++ b/src/kudu/tablet/delta_compaction.cc
@@ -148,11 +148,7 @@ Status MajorDeltaCompaction::FlushRowSetAndDeltas() {
       // later at step 5.
       Mutation* new_redos_head = nullptr;
 
-      DVLOG(3) << "MDC: Input Row: " << dst_row.schema()->DebugRow(dst_row)
-               << " RowIndex: " << input_row->row.row_index()
-               << " Undo Mutations: (not shown)"
-               << " Redo Mutations: "
-               << Mutation::StringifyMutationList(base_schema_, 
input_row->redo_head);
+      DVLOG(3) << "MDC: Input Row: " << CompactionInputRowToString(*input_row);
 
       bool is_garbage_collected;
 
@@ -168,12 +164,7 @@ Status MajorDeltaCompaction::FlushRowSetAndDeltas() {
                                                    &is_garbage_collected,
                                                    
&num_rows_history_truncated));
 
-      DVLOG(3) << "MDC: Output Row: " << dst_row.schema()->DebugRow(dst_row)
-               << " RowIndex: " << input_row->row.row_index()
-               << " Generated Undo Mutations: "
-               << Mutation::StringifyMutationList(partial_schema_, 
new_undos_head)
-               << " Updated Redo Mutations: "
-               << Mutation::StringifyMutationList(partial_schema_, 
new_redos_head);
+      DVLOG(3) << "MDC: Output Row: " << RowToString(dst_row, new_undos_head, 
new_redos_head);
 
       // We only create a new undo delta file if we need to.
       if (new_undos_head != nullptr && !new_undo_delta_writer_) {

Reply via email to