| 773 | explicit UnionImpl(std::vector<Formatter> f) : field_formatters_(std::move(f)) {} |
| 774 | |
| 775 | void DoFormat(const UnionArray& array, int64_t index, int64_t child_index, |
| 776 | std::ostream* os) { |
| 777 | auto type_code = array.raw_type_codes()[index]; |
| 778 | auto child = array.field(array.child_id(index)); |
| 779 | |
| 780 | *os << "{" << static_cast<int16_t>(type_code) << ": "; |
| 781 | if (child->IsNull(child_index)) { |
| 782 | *os << "null"; |
| 783 | } else { |
| 784 | field_formatters_[type_code](*child, child_index, os); |
| 785 | } |
| 786 | *os << "}"; |
| 787 | } |
| 788 | |
| 789 | std::vector<Formatter> field_formatters_; |
| 790 | }; |