| 99 | } |
| 100 | |
| 101 | std::string TraceEventToJson(const TraceEvent& event) { |
| 102 | ostringstream buf; |
| 103 | kudu::JsonWriter jw(&buf, kudu::JsonWriter::COMPACT); |
| 104 | |
| 105 | jw.StartObject(); |
| 106 | jw.String("ts"); |
| 107 | jw.Double(event.timestamp); |
| 108 | jw.String("s"); |
| 109 | jw.String(EventTypeToString(event.type)); |
| 110 | jw.String("f"); |
| 111 | jw.String(event.filename); |
| 112 | jw.String("m"); |
| 113 | jw.Int64(event.mtime); |
| 114 | jw.String("o"); |
| 115 | jw.Int64(event.offset); |
| 116 | |
| 117 | if (event.lookup_length != -1) { |
| 118 | jw.String("lLen"); |
| 119 | jw.Int64(event.lookup_length); |
| 120 | } |
| 121 | if (event.entry_length != -1) { |
| 122 | jw.String("eLen"); |
| 123 | jw.Int64(event.entry_length); |
| 124 | } |
| 125 | jw.EndObject(); |
| 126 | |
| 127 | return buf.str(); |
| 128 | } |
| 129 | |
| 130 | Status TraceFileIterator::Init() { |
| 131 | boost::filesystem::path file_path(filename_); |