@@ -22,6 +22,8 @@ using std::set;
2222using ceph::bufferlist;
2323using ceph::Formatter;
2424
25+ using namespace std ::literals;
26+
2527void ECSubWrite::encode (bufferlist &bl) const
2628{
2729 ENCODE_START (4 , 1 , bl);
@@ -242,32 +244,28 @@ std::ostream &operator<<(
242244
243245void ECSubRead::dump (Formatter *f) const
244246{
247+ using extent_t = boost::tuple<uint64_t , uint64_t , uint32_t >;
248+
245249 f->dump_stream (" from" ) << from;
246250 f->dump_unsigned (" tid" , tid);
247- f->open_array_section (" objects" );
248- for (auto i = to_read.cbegin (); i != to_read.cend (); ++i) {
249- f->open_object_section (" object" );
250- f->dump_stream (" oid" ) << i->first ;
251- f->open_array_section (" extents" );
252- for (auto j = i->second .cbegin (); j != i->second .cend (); ++j) {
253- f->open_object_section (" extent" );
254- f->dump_unsigned (" off" , j->get <0 >());
255- f->dump_unsigned (" len" , j->get <1 >());
256- f->dump_unsigned (" flags" , j->get <2 >());
257- f->close_section ();
258- }
259- f->close_section ();
260- f->close_section ();
261- }
262- f->close_section ();
263251
264- f->open_array_section (" object_attrs_requested" );
265- for (auto i = attrs_to_read.cbegin (); i != attrs_to_read.cend (); ++i) {
266- f->open_object_section (" object" );
267- f->dump_stream (" oid" ) << *i;
268- f->close_section ();
269- }
270- f->close_section ();
252+ // 'to_read' (map<hobject_t, list<tuple<offset, length, flags>>>)
253+ f->with_obj_array_section (
254+ " object" sv, to_read,
255+ [](Formatter& f, const hobject_t & oid, const list<extent_t >& extents) {
256+ f.dump_stream (" oid" ) << oid;
257+ f.with_obj_array_section (
258+ " extent" , extents, [](Formatter& f, const extent_t & extent) {
259+ f.dump_unsigned (" off" , extent.get <0 >());
260+ f.dump_unsigned (" len" , extent.get <1 >());
261+ f.dump_unsigned (" flags" , extent.get <2 >());
262+ });
263+ });
264+
265+ // 'object_attrs_requested': 'attrs_to_read' (set<hobject_t>)
266+ f->with_obj_array_section (
267+ " object_attrs_requested" sv, attrs_to_read,
268+ [](Formatter& f, const hobject_t & oid) { f.dump_stream (" oid" ) << oid; });
271269}
272270
273271void ECSubRead::generate_test_instances (list<ECSubRead*>& o)
@@ -321,50 +319,51 @@ std::ostream &operator<<(
321319 << " )" ;
322320}
323321
324- void ECSubReadReply::dump (Formatter *f) const
322+
323+ void ECSubReadReply::dump (Formatter* f) const
325324{
325+ using offset_pair_t = pair<uint64_t , bufferlist>;
326+ using extents_list_t = list<offset_pair_t >;
327+
326328 f->dump_stream (" from" ) << from;
327329 f->dump_unsigned (" tid" , tid);
328- f->open_array_section (" buffers_read" );
329- for (auto i = buffers_read.cbegin (); i != buffers_read.cend (); ++i) {
330- f->open_object_section (" object" );
331- f->dump_stream (" oid" ) << i->first ;
332- f->open_array_section (" data" );
333- for (auto j = i->second .cbegin (); j != i->second .cend (); ++j) {
334- f->open_object_section (" extent" );
335- f->dump_unsigned (" off" , j->first );
336- f->dump_unsigned (" buf_len" , j->second .length ());
337- f->close_section ();
338- }
339- f->close_section ();
340- f->close_section ();
341- }
342- f->close_section ();
343-
344- f->open_array_section (" attrs_returned" );
345- for (auto i = attrs_read.cbegin (); i != attrs_read.cend (); ++i) {
346- f->open_object_section (" object_attrs" );
347- f->dump_stream (" oid" ) << i->first ;
348- f->open_array_section (" attrs" );
349- for (auto j = i->second .cbegin (); j != i->second .cend (); ++j) {
350- f->open_object_section (" attr" );
351- f->dump_string (" attr" , j->first );
352- f->dump_unsigned (" val_len" , j->second .length ());
353- f->close_section ();
354- }
355- f->close_section ();
356- f->close_section ();
357- }
358- f->close_section ();
359-
360- f->open_array_section (" errors" );
361- for (auto i = errors.cbegin (); i != errors.cend (); ++i) {
362- f->open_object_section (" error_pair" );
363- f->dump_stream (" oid" ) << i->first ;
364- f->dump_int (" error" , i->second );
365- f->close_section ();
366- }
367- f->close_section ();
330+
331+ // 'buffers_read' (map<hobject_t, list<pair<uint64_t, bufferlist>>>)
332+ f->with_obj_array_section (
333+ " object" sv, buffers_read,
334+ [](Formatter& f, const hobject_t & oid, const extents_list_t & l) {
335+ f.dump_stream (" oid" ) << oid;
336+ f.with_obj_array_section (
337+ " extent" , l,
338+ [](Formatter& f, const offset_pair_t & offset_n_bl) {
339+ const auto & [off, bl] = offset_n_bl;
340+ f.dump_unsigned (" off" , off);
341+ f.dump_unsigned (" buf_len" , bl.length ());
342+ });
343+ });
344+
345+ // "attrs_returned" (mapping hobject_t to a <string to bl> table)
346+ f->with_obj_array_section (
347+ " object_attrs" sv, attrs_read,
348+ [](Formatter& f, const hobject_t & oid,
349+ const std::map<std::string, ceph::buffer::list, std::less<>>& m) {
350+ f.dump_stream (" oid" ) << oid;
351+ f.with_obj_array_section (
352+ " attr" , m,
353+ [](Formatter& f, const std::string& attr,
354+ const ceph::buffer::list& bl) {
355+ f.dump_string (" attr" , attr);
356+ f.dump_unsigned (" val_len" , bl.length ());
357+ });
358+ });
359+
360+ // "errors": map<hobject_t, int>
361+ f->with_obj_array_section (
362+ " error_pair" sv, errors,
363+ [](Formatter& f, const hobject_t & oid, int err) {
364+ f.dump_stream (" oid" ) << oid;
365+ f.dump_int (" error" , err);
366+ });
368367}
369368
370369void ECSubReadReply::generate_test_instances (list<ECSubReadReply*>& o)
0 commit comments