diff --git a/include/caliper/reader/QueryProcessor.h b/include/caliper/reader/QueryProcessor.h index 2f6b46e5..4a088ca2 100644 --- a/include/caliper/reader/QueryProcessor.h +++ b/include/caliper/reader/QueryProcessor.h @@ -27,7 +27,7 @@ class QueryProcessor public: - QueryProcessor(const QuerySpec&, OutputStream& stream); + QueryProcessor(const QuerySpec&, OutputStream&); void process_record(CaliperMetadataAccessInterface&, const EntryList&); void flush(CaliperMetadataAccessInterface&); diff --git a/include/caliper/reader/RecordSelector.h b/include/caliper/reader/RecordSelector.h index 86ea5fd5..1c0e0316 100644 --- a/include/caliper/reader/RecordSelector.h +++ b/include/caliper/reader/RecordSelector.h @@ -27,7 +27,6 @@ class RecordSelector public: - RecordSelector(const std::string& filter_string); RecordSelector(const QuerySpec& spec); RecordSelector(const QuerySpec::Condition& cond); diff --git a/src/reader/Aggregator.cpp b/src/reader/Aggregator.cpp index c6b75998..6b0ae8ab 100644 --- a/src/reader/Aggregator.cpp +++ b/src/reader/Aggregator.cpp @@ -1045,7 +1045,7 @@ struct Aggregator::AggregatorImpl { kernels.emplace_back(k_cfg->make_kernel()); size_t idx = m_entries.size(); - m_entries.emplace_back(new AggregateEntry { std::move(key), std::move(kernels), m_hashmap[hash] }); + m_entries.emplace_back(new AggregateEntry { key, std::move(kernels), m_hashmap[hash] }); m_hashmap[hash] = idx; return m_entries[idx].get(); diff --git a/src/reader/Expand.cpp b/src/reader/Expand.cpp index 67918bbb..885898e5 100644 --- a/src/reader/Expand.cpp +++ b/src/reader/Expand.cpp @@ -25,7 +25,6 @@ using namespace cali; struct Expand::ExpandImpl { std::set m_selected; - std::set m_deselected; std::map m_aliases; @@ -35,23 +34,6 @@ struct Expand::ExpandImpl { ExpandImpl(OutputStream& os) : m_os(os) {} - void parse(const std::string& field_string) - { - std::vector fields; - - util::split(field_string, ':', std::back_inserter(fields)); - - for (const std::string& s : fields) { - if (s.size() == 0) - continue; - - if (s[0] == '-') - m_deselected.insert(s.substr(1, std::string::npos)); - else - m_selected.insert(s); - } - } - void configure(const QuerySpec& spec) { switch (spec.select.selection) { @@ -83,7 +65,7 @@ struct Expand::ExpandImpl { for (const Node* node = e.node(); node && node->attribute() != CALI_INV_ID; node = node->parent()) { std::string name = db.get_attribute(node->attribute()).name(); - if ((!m_selected.empty() && m_selected.count(name) == 0) || m_deselected.count(name)) + if ((!m_selected.empty() && m_selected.count(name) == 0)) continue; nodes.push_back(node); @@ -118,7 +100,7 @@ struct Expand::ExpandImpl { } else if (e.is_immediate()) { std::string name = db.get_attribute(e.attribute()).name(); - if ((!m_selected.empty() && m_selected.count(name) == 0) || m_deselected.count(name)) + if ((!m_selected.empty() && m_selected.count(name) == 0)) continue; { @@ -139,21 +121,11 @@ struct Expand::ExpandImpl { } }; -Expand::Expand(OutputStream& os, const std::string& field_string) : mP { new ExpandImpl(os) } -{ - mP->parse(field_string); -} - Expand::Expand(OutputStream& os, const QuerySpec& spec) : mP { new ExpandImpl(os) } { mP->configure(spec); } -void Expand::operator() (CaliperMetadataAccessInterface& db, const EntryList& list) const -{ - mP->print(db, list); -} - void Expand::process_record(CaliperMetadataAccessInterface& db, const EntryList& list) { mP->print(db, list); diff --git a/src/reader/Expand.h b/src/reader/Expand.h index 63f5a55a..3fd2b6bc 100644 --- a/src/reader/Expand.h +++ b/src/reader/Expand.h @@ -28,11 +28,8 @@ class Expand : public Formatter public: - Expand(OutputStream& os, const std::string& filter_string); Expand(OutputStream& os, const QuerySpec& spec); - void operator() (CaliperMetadataAccessInterface&, const EntryList&) const; - void process_record(CaliperMetadataAccessInterface&, const EntryList&); }; diff --git a/src/reader/JsonFormatter.cpp b/src/reader/JsonFormatter.cpp index 4f7e655e..23207285 100644 --- a/src/reader/JsonFormatter.cpp +++ b/src/reader/JsonFormatter.cpp @@ -27,10 +27,8 @@ using namespace cali; struct JsonFormatter::JsonFormatterImpl { std::set m_selected; - std::set m_deselected; OutputStream m_os; - std::mutex m_os_lock; unsigned m_num_recs = 0; @@ -48,23 +46,6 @@ struct JsonFormatter::JsonFormatterImpl { JsonFormatterImpl(OutputStream& os) : m_os(os) {} - void parse(const std::string& field_string) - { - std::vector fields; - - util::split(field_string, ':', std::back_inserter(fields)); - - for (const std::string& s : fields) { - if (s.size() == 0) - continue; - - if (s[0] == '-') - m_deselected.insert(s.substr(1, std::string::npos)); - else - m_selected.insert(s); - } - } - void configure(const QuerySpec& spec) { for (auto p : spec.format.kwargs) { @@ -102,7 +83,7 @@ struct JsonFormatter::JsonFormatterImpl { { std::string name = attr.name(); - bool selected = m_selected.count(name) > 0 && !(m_deselected.count(name) > 0); + bool selected = m_selected.count(name) > 0; if (!selected && (!m_selected.empty() || attr.is_hidden() || attr.is_global())) return ""; diff --git a/src/reader/RecordSelector.cpp b/src/reader/RecordSelector.cpp index 14161e33..7fd9c9a1 100644 --- a/src/reader/RecordSelector.cpp +++ b/src/reader/RecordSelector.cpp @@ -247,11 +247,6 @@ struct RecordSelector::RecordSelectorImpl { } }; // RecordSelectorImpl -RecordSelector::RecordSelector(const std::string& filter_string) : mP { new RecordSelectorImpl } -{ - mP->m_filters = parse(filter_string); -} - RecordSelector::RecordSelector(const QuerySpec& spec) : mP { new RecordSelectorImpl } { mP->configure(spec); diff --git a/src/reader/TableFormatter.cpp b/src/reader/TableFormatter.cpp index 2726707c..9fb7beef 100644 --- a/src/reader/TableFormatter.cpp +++ b/src/reader/TableFormatter.cpp @@ -67,35 +67,6 @@ struct TableFormatter::TableImpl { return std::max(m_max_column_width > 0 ? std::min(base, m_max_column_width) : base, 4); } - void parse(const std::string& field_string, const std::string& sort_string) - { - std::vector fields; - - // fill sort columns - - util::split(sort_string, ':', std::back_inserter(fields)); - - for (const std::string& s : fields) - if (s.size() > 0) - m_cols.emplace_back(s, s, s.size(), Attribute(), false); - - fields.clear(); - - // fill print columns - - if (field_string.empty()) { - m_auto_column = true; - return; - } else - m_auto_column = false; - - util::split(field_string, ':', std::back_inserter(fields)); - - for (const std::string& s : fields) - if (s.size() > 0) - m_cols.emplace_back(s, s, s.size(), Attribute(), true); - } - void configure(const QuerySpec& spec) { m_cols.clear(); @@ -345,11 +316,6 @@ struct TableFormatter::TableImpl { TableImpl() : m_max_column_width(60), m_print_globals(false) {} }; -TableFormatter::TableFormatter(const std::string& fields, const std::string& sort_fields) : mP { new TableImpl } -{ - mP->parse(fields, sort_fields); -} - TableFormatter::TableFormatter(const QuerySpec& spec) : mP { new TableImpl } { mP->configure(spec); diff --git a/src/reader/TableFormatter.h b/src/reader/TableFormatter.h index 18884c1f..3acfd806 100644 --- a/src/reader/TableFormatter.h +++ b/src/reader/TableFormatter.h @@ -28,7 +28,6 @@ class TableFormatter : public Formatter public: - TableFormatter(const std::string& fields, const std::string& sort_fields); TableFormatter(const QuerySpec& spec); void process_record(CaliperMetadataAccessInterface&, const EntryList&); diff --git a/src/services/validator/validator.cpp b/src/services/validator/validator.cpp index 025a45c6..9d86b017 100644 --- a/src/services/validator/validator.cpp +++ b/src/services/validator/validator.cpp @@ -15,6 +15,8 @@ #include "caliper/common/Node.h" #include "caliper/common/OutputStream.h" +#include "caliper/reader/QuerySpec.h" + #include "../../reader/Expand.h" #include @@ -39,8 +41,10 @@ std::ostream& print_snapshot(Caliper* c, std::ostream& os) OutputStream stream; stream.set_stream(&os); + QuerySpec spec; + spec.select.selection = QuerySpec::AttributeSelection::Default; - cali::Expand exp(stream, ""); + cali::Expand exp(stream, spec); exp.process_record(*c, std::vector(snapshot.view().begin(), snapshot.view().end())); return os << " }";