diff --git a/schema.cc b/schema.cc index 4b96d6e069..b0a1888e41 100644 --- a/schema.cc +++ b/schema.cc @@ -88,6 +88,23 @@ get_column_types(const Sequence& column_definitions) { return result; } +std::ostream& operator<<(std::ostream& out, const column_mapping& cm) { + column_id n_static = cm.n_static(); + column_id n_regular = cm.columns().size() - n_static; + + auto pr_entry = [] (column_id i, const column_mapping_entry& e) { + // Without schema we don't know if name is UTF8. If we had schema we could use + // s->regular_column_name_type()->to_string(e.name()). + return sprint("{id=%s, name=0x%s, type=%s}", i, e.name(), e.type()->name()); + }; + + return out << "{static=[" << ::join(", ", boost::irange(0, n_static) | + boost::adaptors::transformed([&] (column_id i) { return pr_entry(i, cm.static_column_at(i)); })) + << "], regular=[" << ::join(", ", boost::irange(0, n_regular) | + boost::adaptors::transformed([&] (column_id i) { return pr_entry(i, cm.regular_column_at(i)); })) + << "]}"; +} + ::shared_ptr schema::make_column_specification(const column_definition& def) { auto id = ::make_shared(def.name(), column_name_type(def)); diff --git a/schema.hh b/schema.hh index 633bfe7514..d843335282 100644 --- a/schema.hh +++ b/schema.hh @@ -335,6 +335,7 @@ public: } return _columns[id + _n_static]; } + friend std::ostream& operator<<(std::ostream& out, const column_mapping& cm); }; /*