Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/caliper/reader/QueryProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down
1 change: 0 additions & 1 deletion include/caliper/reader/RecordSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class RecordSelector

public:

RecordSelector(const std::string& filter_string);
RecordSelector(const QuerySpec& spec);
RecordSelector(const QuerySpec::Condition& cond);

Expand Down
2 changes: 1 addition & 1 deletion src/reader/Aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
32 changes: 2 additions & 30 deletions src/reader/Expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ using namespace cali;

struct Expand::ExpandImpl {
std::set<std::string> m_selected;
std::set<std::string> m_deselected;

std::map<std::string, std::string> m_aliases;

Expand All @@ -35,23 +34,6 @@ struct Expand::ExpandImpl {

ExpandImpl(OutputStream& os) : m_os(os) {}

void parse(const std::string& field_string)
{
std::vector<std::string> 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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

{
Expand All @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/reader/Expand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
};

Expand Down
21 changes: 1 addition & 20 deletions src/reader/JsonFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ using namespace cali;

struct JsonFormatter::JsonFormatterImpl {
std::set<std::string> m_selected;
std::set<std::string> m_deselected;

OutputStream m_os;

std::mutex m_os_lock;

unsigned m_num_recs = 0;
Expand All @@ -48,23 +46,6 @@ struct JsonFormatter::JsonFormatterImpl {

JsonFormatterImpl(OutputStream& os) : m_os(os) {}

void parse(const std::string& field_string)
{
std::vector<std::string> 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) {
Expand Down Expand Up @@ -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 "";
Expand Down
5 changes: 0 additions & 5 deletions src/reader/RecordSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 0 additions & 34 deletions src/reader/TableFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> 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();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/reader/TableFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down
6 changes: 5 additions & 1 deletion src/services/validator/validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "caliper/common/Node.h"
#include "caliper/common/OutputStream.h"

#include "caliper/reader/QuerySpec.h"

#include "../../reader/Expand.h"

#include <atomic>
Expand All @@ -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<Entry>(snapshot.view().begin(), snapshot.view().end()));

return os << " }";
Expand Down