Make DebugDumpCompactionInput use CompactionInputRowToString Recent patches changed and unified the way we print rows but this method was left out as multiple tests were depending on the old format.
This patch takes this the rest of the way and changes the tests so that they use the new format. Change-Id: I13a83ecdb8f801c7952d6e130db77726f3b14a83 Reviewed-on: http://gerrit.cloudera.org:8080/5215 Reviewed-by: Todd Lipcon <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/5abff6d7 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/5abff6d7 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/5abff6d7 Branch: refs/heads/master Commit: 5abff6d75204573a85cdee907a9e1f462f345ecb Parents: 4cc48d8 Author: David Alves <[email protected]> Authored: Thu Nov 24 03:15:44 2016 -0800 Committer: David Ribeiro Alves <[email protected]> Committed: Mon Nov 28 20:36:52 2016 +0000 ---------------------------------------------------------------------- src/kudu/integration-tests/alter_table-test.cc | 13 ++-- src/kudu/tablet/compaction-test.cc | 76 ++++++++++----------- src/kudu/tablet/compaction.cc | 5 +- src/kudu/tablet/tablet_history_gc-test.cc | 23 ++++--- 4 files changed, 58 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/5abff6d7/src/kudu/integration-tests/alter_table-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/integration-tests/alter_table-test.cc b/src/kudu/integration-tests/alter_table-test.cc index a387b47..e28f8bf 100644 --- a/src/kudu/integration-tests/alter_table-test.cc +++ b/src/kudu/integration-tests/alter_table-test.cc @@ -743,7 +743,8 @@ TEST_F(AlterTableTest, TestMajorCompactDeltasAfterUpdatingRemovedColumn) { "---------------------------\n" "MRS memrowset:\n" "RowSet RowSet(0):\n" - "(int32 c0=0, int32 c2=12345) Undos: [@3(DELETE)] Redos: []", + "RowIdxInBlock: 0; Base: (int32 c0=0, int32 c2=12345); Undo Mutations: [@3(DELETE)]; " + "Redo Mutations: [];", JoinStrings(rows, "\n")); } @@ -790,9 +791,10 @@ TEST_F(AlterTableTest, TestMajorCompactDeltasIntoMissingBaseData) { "---------------------------\n" "MRS memrowset:\n" "RowSet RowSet(0):\n" - "(int32 c0=0, int32 c1=0, int32 c2=54321) " - "Undos: [@5(SET c2=12345), @2(DELETE)] Redos: []\n" - "(int32 c0=16777216, int32 c1=1, int32 c2=12345) Undos: [@3(DELETE)] Redos: []", + "RowIdxInBlock: 0; Base: (int32 c0=0, int32 c1=0, int32 c2=54321); Undo Mutations: " + "[@5(SET c2=12345), @2(DELETE)]; Redo Mutations: [];\n" + "RowIdxInBlock: 1; Base: (int32 c0=16777216, int32 c1=1, int32 c2=12345); " + "Undo Mutations: [@3(DELETE)]; Redo Mutations: [];", JoinStrings(rows, "\n")); } @@ -845,7 +847,8 @@ TEST_F(AlterTableTest, TestMajorCompactDeltasAfterAddUpdateRemoveColumn) { "---------------------------\n" "MRS memrowset:\n" "RowSet RowSet(0):\n" - "(int32 c0=0, int32 c1=0) Undos: [@2(DELETE)] Redos: []", + "RowIdxInBlock: 0; Base: (int32 c0=0, int32 c1=0); Undo Mutations: [@2(DELETE)]; " + "Redo Mutations: [];", JoinStrings(rows, "\n")); } http://git-wip-us.apache.org/repos/asf/kudu/blob/5abff6d7/src/kudu/tablet/compaction-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/compaction-test.cc b/src/kudu/tablet/compaction-test.cc index 2924d7c..99cd49f 100644 --- a/src/kudu/tablet/compaction-test.cc +++ b/src/kudu/tablet/compaction-test.cc @@ -420,13 +420,13 @@ TEST_F(TestCompaction, TestMemRowSetInput) { gscoped_ptr<CompactionInput> input(CompactionInput::Create(*mrs, &schema_, snap)); IterateInput(input.get(), &out); ASSERT_EQ(10, out.size()); - ASSERT_EQ("(string key=hello 00000000, int32 val=0, int32 nullable_val=0) " - "Undos: [@1(DELETE)] " - "Redos: [@11(SET val=1, nullable_val=1), @21(SET val=2, nullable_val=NULL)]", + EXPECT_EQ("RowIdxInBlock: 0; Base: (string key=hello 00000000, int32 val=0, " + "int32 nullable_val=0); Undo Mutations: [@1(DELETE)]; Redo Mutations: " + "[@11(SET val=1, nullable_val=1), @21(SET val=2, nullable_val=NULL)];", out[0]); - ASSERT_EQ("(string key=hello 00000090, int32 val=9, int32 nullable_val=NULL) " - "Undos: [@10(DELETE)] " - "Redos: [@20(SET val=1, nullable_val=1), @30(SET val=2, nullable_val=NULL)]", + EXPECT_EQ("RowIdxInBlock: 9; Base: (string key=hello 00000090, int32 val=9, " + "int32 nullable_val=NULL); Undo Mutations: [@10(DELETE)]; Redo Mutations: " + "[@20(SET val=1, nullable_val=1), @30(SET val=2, nullable_val=NULL)];", out[9]); } @@ -445,17 +445,17 @@ TEST_F(TestCompaction, TestFlushMRSWithRolling) { vector<string> rows; rows.reserve(30000 / 2); rowsets[0]->DebugDump(&rows); - EXPECT_EQ("(string key=hello 00000000, int32 val=0, int32 nullable_val=0) " - "Undos: [@1(DELETE)] Redos: []", + EXPECT_EQ("RowIdxInBlock: 0; Base: (string key=hello 00000000, int32 val=0, " + "int32 nullable_val=0); Undo Mutations: [@1(DELETE)]; Redo Mutations: [];", rows[0]); rows.clear(); rowsets[1]->DebugDump(&rows); - EXPECT_EQ("(string key=hello 00154700, int32 val=15470, int32 nullable_val=15470) " - "Undos: [@15471(DELETE)] Redos: []", + EXPECT_EQ("RowIdxInBlock: 0; Base: (string key=hello 00154700, int32 val=15470, " + "int32 nullable_val=15470); Undo Mutations: [@15471(DELETE)]; Redo Mutations: [];", rows[0]); - EXPECT_EQ("(string key=hello 00154710, int32 val=15471, int32 nullable_val=NULL) " - "Undos: [@15472(DELETE)] Redos: []", + EXPECT_EQ("RowIdxInBlock: 1; Base: (string key=hello 00154710, int32 val=15471, " + "int32 nullable_val=NULL); Undo Mutations: [@15472(DELETE)]; Redo Mutations: [];", rows[1]); } @@ -485,21 +485,15 @@ TEST_F(TestCompaction, TestRowSetInput) { ASSERT_OK(CompactionInput::Create(*rs, &schema_, MvccSnapshot(mvcc_), &input)); IterateInput(input.get(), &out); ASSERT_EQ(10, out.size()); - EXPECT_EQ("(string key=hello 00000000, int32 val=0, int32 nullable_val=0) " - "Undos: [@1(DELETE)] " - "Redos: [" - "@11(SET val=1, nullable_val=1), " - "@21(SET val=2, nullable_val=NULL), " - "@31(SET val=3, nullable_val=3), " - "@41(SET val=4, nullable_val=NULL)]", + EXPECT_EQ("RowIdxInBlock: 0; Base: (string key=hello 00000000, int32 val=0, " + "int32 nullable_val=0); Undo Mutations: [@1(DELETE)]; Redo Mutations: " + "[@11(SET val=1, nullable_val=1), @21(SET val=2, nullable_val=NULL), " + "@31(SET val=3, nullable_val=3), @41(SET val=4, nullable_val=NULL)];", out[0]); - EXPECT_EQ("(string key=hello 00000090, int32 val=9, int32 nullable_val=NULL) " - "Undos: [@10(DELETE)] " - "Redos: [" - "@20(SET val=1, nullable_val=1), " - "@30(SET val=2, nullable_val=NULL), " - "@40(SET val=3, nullable_val=3), " - "@50(SET val=4, nullable_val=NULL)]", + EXPECT_EQ("RowIdxInBlock: 9; Base: (string key=hello 00000090, int32 val=9, " + "int32 nullable_val=NULL); Undo Mutations: [@10(DELETE)]; Redo Mutations: " + "[@20(SET val=1, nullable_val=1), @30(SET val=2, nullable_val=NULL), " + "@40(SET val=3, nullable_val=3), @50(SET val=4, nullable_val=NULL)];", out[9]); } @@ -563,12 +557,12 @@ TEST_F(TestCompaction, TestDuplicatedGhostRowsDontSurviveCompaction) { vector<string> out; IterateInput(input.get(), &out); ASSERT_EQ(out.size(), 10); - EXPECT_EQ("(string key=hello 00000000, int32 val=2, int32 nullable_val=NULL) " - "Undos: [@61(SET val=0, nullable_val=0), @51(DELETE)] " - "Redos: []", out[0]); - EXPECT_EQ("(string key=hello 00000090, int32 val=2, int32 nullable_val=NULL) " - "Undos: [@70(SET val=9, nullable_val=NULL), @60(DELETE)] " - "Redos: []", out[9]); + EXPECT_EQ("RowIdxInBlock: 0; Base: (string key=hello 00000000, int32 val=2, " + "int32 nullable_val=NULL); Undo Mutations: [@61(SET val=0, nullable_val=0), " + "@51(DELETE)]; Redo Mutations: [];", out[0]); + EXPECT_EQ("RowIdxInBlock: 9; Base: (string key=hello 00000090, int32 val=2, " + "int32 nullable_val=NULL); Undo Mutations: [@70(SET val=9, nullable_val=NULL), " + "@60(DELETE)]; Redo Mutations: [];", out[9]); } // Test case which doesn't do any merging -- just compacts @@ -608,10 +602,10 @@ TEST_F(TestCompaction, TestOneToOne) { ASSERT_OK(CompactionInput::Create(*rs, &schema_, MvccSnapshot(mvcc_), &input)); IterateInput(input.get(), &out); ASSERT_EQ(1000, out.size()); - EXPECT_EQ("(string key=hello 00000000, int32 val=1, int32 nullable_val=1) " - "Undos: [@1001(SET val=0, nullable_val=0), @1(DELETE)] " - "Redos: [@2001(SET val=2, nullable_val=NULL), " - "@3001(SET val=3, nullable_val=3)]", out[0]); + EXPECT_EQ("RowIdxInBlock: 0; Base: (string key=hello 00000000, int32 val=1, " + "int32 nullable_val=1); Undo Mutations: [@1001(SET val=0, nullable_val=0), " + "@1(DELETE)]; Redo Mutations: [@2001(SET val=2, nullable_val=NULL), " + "@3001(SET val=3, nullable_val=3)];", out[0]); // And compact (1 input to 1 output) MvccSnapshot snap3(mvcc_); @@ -715,10 +709,12 @@ TEST_F(TestCompaction, TestMergeMRS) { vector<string> out; IterateInput(input.get(), &out); ASSERT_EQ(out.size(), 20); - EXPECT_EQ("(string key=hello 00000000, int32 val=0, int32 nullable_val=0) " - "Undos: [@1(DELETE)] Redos: []", out[0]); - EXPECT_EQ("(string key=hello 00000091, int32 val=9, int32 nullable_val=NULL) " - "Undos: [@20(DELETE)] Redos: []", out[19]); + EXPECT_EQ("RowIdxInBlock: 0; Base: (string key=hello 00000000, int32 val=0, " + "int32 nullable_val=0); Undo Mutations: [@1(DELETE)]; " + "Redo Mutations: [];", out[0]); + EXPECT_EQ("RowIdxInBlock: 9; Base: (string key=hello 00000091, int32 val=9, " + "int32 nullable_val=NULL); Undo Mutations: [@20(DELETE)]; " + "Redo Mutations: [];", out[19]); } #ifdef NDEBUG http://git-wip-us.apache.org/repos/asf/kudu/blob/5abff6d7/src/kudu/tablet/compaction.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/compaction.cc b/src/kudu/tablet/compaction.cc index cfb5fb3..826d5b7 100644 --- a/src/kudu/tablet/compaction.cc +++ b/src/kudu/tablet/compaction.cc @@ -1049,10 +1049,7 @@ Status DebugDumpCompactionInput(CompactionInput *input, vector<string> *lines) { RETURN_NOT_OK(input->PrepareBlock(&rows)); for (const CompactionInputRow &input_row : rows) { - const Schema* schema = input_row.row.schema(); - LOG_STRING(INFO, lines) << schema->DebugRow(input_row.row) << - " Undos: " + Mutation::StringifyMutationList(*schema, input_row.undo_head) << - " Redos: " + Mutation::StringifyMutationList(*schema, input_row.redo_head); + LOG_STRING(INFO, lines) << CompactionInputRowToString(input_row); } RETURN_NOT_OK(input->FinishBlock()); http://git-wip-us.apache.org/repos/asf/kudu/blob/5abff6d7/src/kudu/tablet/tablet_history_gc-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tablet/tablet_history_gc-test.cc b/src/kudu/tablet/tablet_history_gc-test.cc index 02a7b3e..17de070 100644 --- a/src/kudu/tablet/tablet_history_gc-test.cc +++ b/src/kudu/tablet/tablet_history_gc-test.cc @@ -141,7 +141,8 @@ TEST_F(TabletHistoryGcTest, TestNoGenerateUndoOnMajorDeltaCompaction) { // Now, we should have base data = 2 with no other historical values. // Major delta compaction will not remove UNDOs, so we expect a single UNDO DELETE as well. - ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=2\) Undos: \[@[[:digit:]]+\(DELETE\)\] Redos: \[\]$)"); + ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=2\); Undo Mutations: \[@[[:digit:]]+\(DELETE\)\]; )" + R"(Redo Mutations: \[\];$)"); } // Test that major delta compaction works when run on a subset of columns: @@ -182,8 +183,8 @@ TEST_F(TabletHistoryGcTest, TestMajorDeltaCompactionOnSubsetOfColumns) { tablet()->GetHistoryGcOpts())); } - ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=2\) Undos: \[@[[:digit:]]+\(DELETE\)\] )" - R"(Redos: \[@[[:digit:]]+\(SET key_idx=1\)\]$)"); + ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=2\); Undo Mutations: \[@[[:digit:]]+\(DELETE\)\]; )" + R"(Redo Mutations: \[@[[:digit:]]+\(SET key_idx=1\)\];$)"); vector<string> rows; ASSERT_OK(IterateToStringList(&rows)); @@ -239,7 +240,7 @@ TEST_F(TabletHistoryGcTest, TestNoGenerateUndoOnMRSFlush) { ASSERT_EQ(0, rsmd->undo_delta_blocks().size()); } NO_FATALS(VerifyTestRowsWithTimestampAndVerifier(kStartRow, 1, Timestamp(0), kRowsEqual0)); - ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=0\) Undos: \[\] Redos: \[\]$)"); + ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=0\); Undo Mutations: \[\]; Redo Mutations: \[\];$)"); } // Test that undos get GCed on a merge compaction. @@ -261,7 +262,7 @@ TEST_F(TabletHistoryGcTest, TestUndoGCOnMergeCompaction) { // Now the only thing we can see is the base data. NO_FATALS(VerifyTestRowsWithTimestampAndVerifier(kStartRow, TotalNumRows(), time_before_insert, kRowsEqual0)); - ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=0\) Undos: \[\] Redos: \[\]$)"); + ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=0\); Undo Mutations: \[\]; Redo Mutations: \[\];$)"); } // Test that we GC the history and existence of entire deleted rows on a merge compaction. @@ -282,12 +283,14 @@ TEST_F(TabletHistoryGcTest, TestRowRemovalGCOnMergeCompaction) { } ASSERT_OK(tablet()->Flush()); ASSERT_DEBUG_DUMP_ROWS_MATCH( - R"(int32 val=0\) Undos: \[@[[:digit:]]+\(DELETE\)\] Redos: \[@[[:digit:]]+\(DELETE\)\]$)"); + R"(int32 val=0\); Undo Mutations: \[@[[:digit:]]+\(DELETE\)\]; )" + R"(Redo Mutations: \[@[[:digit:]]+\(DELETE\)\];$)"); // Compaction at this time will only remove the initial UNDO records. The // DELETE REDOs are too recent. ASSERT_OK(tablet()->Compact(Tablet::FORCE_COMPACT_ALL)); - ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=0\) Undos: \[\] Redos: \[@[[:digit:]]+\(DELETE\)\]$)"); + ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=0\); Undo Mutations: \[\]; Redo Mutations: )" + R"(\[@[[:digit:]]+\(DELETE\)\];$)"); // Move the AHM so that the delete is now prior to it. NO_FATALS(AddTimeToHybridClock(MonoDelta::FromSeconds(200))); @@ -330,8 +333,8 @@ TEST_F(TabletHistoryGcTest, TestNoUndoGCUntilAncientHistoryMark) { // Still read 0 from the past. NO_FATALS(VerifyTestRowsWithTimestampAndVerifier(kStartRow, TotalNumRows(), prev_time, kRowsEqual0)); - ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=1\) Undos: \[@[[:digit:]]+\(SET val=0\), )" - R"(@[[:digit:]]+\(DELETE\)\] Redos: \[\]$)"); + ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=1\); Undo Mutations: \[@[[:digit:]]+\(SET val=0\), )" + R"(@[[:digit:]]+\(DELETE\)\]; Redo Mutations: \[\];$)"); } // Test that "ghost" rows (deleted on one rowset, reinserted on another) don't @@ -357,7 +360,7 @@ TEST_F(TabletHistoryGcTest, TestGhostRowsNotRevived) { // We should end up with a single row as base data. NO_FATALS(VerifyTestRows(0, 1)); - ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=3\) Undos: \[\] Redos: \[\])"); + ASSERT_DEBUG_DUMP_ROWS_MATCH(R"(int32 val=3\); Undo Mutations: \[\]; Redo Mutations: \[\];)"); } // Test to ensure that nothing bad happens when we partially GC different rows
