| 737 | |
| 738 | Status Visit(const StructType& t) { |
| 739 | struct StructImpl { |
| 740 | explicit StructImpl(std::vector<Formatter> f) : field_formatters_(std::move(f)) {} |
| 741 | |
| 742 | void operator()(const Array& array, int64_t index, std::ostream* os) { |
| 743 | const auto& struct_array = checked_cast<const StructArray&>(array); |
| 744 | *os << "{"; |
| 745 | for (int i = 0, printed = 0; i < struct_array.num_fields(); ++i) { |
| 746 | if (printed != 0) { |
| 747 | *os << ", "; |
| 748 | } |
| 749 | if (struct_array.field(i)->IsNull(index)) { |
| 750 | continue; |
| 751 | } |
| 752 | ++printed; |
| 753 | *os << struct_array.struct_type()->field(i)->name() << ": "; |
| 754 | field_formatters_[i](*struct_array.field(i), index, os); |
| 755 | } |
| 756 | *os << "}"; |
| 757 | } |
| 758 | |
| 759 | std::vector<Formatter> field_formatters_; |
| 760 | }; |
| 761 | |
| 762 | std::vector<Formatter> field_formatters(t.num_fields()); |
| 763 | for (int i = 0; i < t.num_fields(); ++i) { |