Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/17808 )
Change subject: [tool] Support to dump and edit pbc in JSON pretty format ...................................................................... Patch Set 1: (2 comments) http://gerrit.cloudera.org:8080/#/c/17808/1/src/kudu/tools/kudu-tool-test.cc File src/kudu/tools/kudu-tool-test.cc: http://gerrit.cloudera.org:8080/#/c/17808/1/src/kudu/tools/kudu-tool-test.cc@1498 PS1, Line 1498: TEST_F(ToolTest, TestPbcTools) { Could you also add a test that edits and dumps a log block container metadata file that contains multiple blocks? AFAICT that's the only instance in which a PBC has multiple records. http://gerrit.cloudera.org:8080/#/c/17808/1/src/kudu/tools/tool_action_pbc.cc File src/kudu/tools/tool_action_pbc.cc: http://gerrit.cloudera.org:8080/#/c/17808/1/src/kudu/tools/tool_action_pbc.cc@216 PS1, Line 216: char read_buffer[65536]; : rapidjson::FileReadStream in_stream(fp, read_buffer, sizeof(read_buffer)); : : JsonParseOptions opts; : opts.case_insensitive_enum_parsing = true; : do { : rapidjson::Document document; : document.ParseStream<rapidjson::kParseStopWhenDoneFlag>(in_stream); : if (document.HasParseError()) { : auto code = document.GetParseError(); : if (code != rapidjson::kParseErrorDocumentEmpty) { : return Status::Corruption("JSON text is corrupt", : rapidjson::GetParseError_En(code)); : } : break; : } : : rapidjson::StringBuffer buffer; : rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); : document.Accept(writer); : : m->Clear(); : auto str = buffer.GetString(); : const auto& google_status = JsonStringToMessage(str, m.get(), opts); : if (!google_status.ok()) { : return Status::InvalidArgument( : Substitute("Unable to parse JSON text: $0", str), : google_status.error_message().ToString()); : } : RETURN_NOT_OK_PREPEND(pb_writer.Append(*m), "unable to append PB to output"); : } while (true); : RETURN_NOT_OK_PREPEND(pb_writer.Sync(), "failed to sync output"); : RETURN_NOT_OK_PREPEND(pb_writer.Close(), "failed to close output"); : } > Can you explain the motivation behind this change to read the document at o Seems like when we were printing compact json, Kudu emitted one message on each line. Now that's no longer the case, so we need to parse through a stream to get valid json messages. I agree, a comment would be nice. -- To view, visit http://gerrit.cloudera.org:8080/17808 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: kudu Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I6d404e6cd487a644fa848513670c4945bf789578 Gerrit-Change-Number: 17808 Gerrit-PatchSet: 1 Gerrit-Owner: Yingchun Lai <[email protected]> Gerrit-Reviewer: Andrew Wong <[email protected]> Gerrit-Reviewer: Bankim Bhavsar <[email protected]> Gerrit-Reviewer: Kudu Jenkins (120) Gerrit-Comment-Date: Tue, 24 Aug 2021 23:16:49 +0000 Gerrit-HasComments: Yes
