• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl / dftracer-utils / 30069185152

24 Jul 2026 05:20AM UTC coverage: 50.687% (-2.0%) from 52.66%
30069185152

Pull #99

github

web-flow
Merge 47af36077 into 06bc84ec9
Pull Request #99: Support CM time_metric (NS/MS/SEC/US) across reader and viz

18062 of 48203 branches covered (37.47%)

Branch coverage included in aggregate %.

1510 of 2205 new or added lines in 59 files covered. (68.48%)

742 existing lines in 114 files now uncovered.

23711 of 34210 relevant lines covered (69.31%)

39853.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.23
/src/dftracer/utils/utilities/common/query/ast.cpp
1
#include <dftracer/utils/utilities/common/query/ast.h>
2

3
#include <sstream>
4
#include <string>
5

6
namespace dftracer::utils::utilities::common::query {
7

8
const char* compare_op_str(CompareOp op) {
4✔
9
    switch (op) {
4!
10
        case CompareOp::EQ:
3✔
11
            return "==";
3✔
UNCOV
12
        case CompareOp::NE:
×
13
            return "!=";
×
14
        case CompareOp::GT:
1✔
15
            return ">";
1✔
UNCOV
16
        case CompareOp::LT:
×
17
            return "<";
×
UNCOV
18
        case CompareOp::GE:
×
19
            return ">=";
×
UNCOV
20
        case CompareOp::LE:
×
21
            return "<=";
×
22
    }
23
    return "??";
×
24
}
25

26
namespace {
27

28
// Operator keyword for a like/regex MatchNode ("in" is handled separately
29
// since its serialization is literal-first).
30
const char* match_op_str(MatchOp op, bool negated) {
6✔
31
    switch (op) {
6!
32
        case MatchOp::LIKE:
2✔
33
            return negated ? "not like" : "like";
2✔
34
        case MatchOp::ILIKE:
1✔
35
            return negated ? "not ilike" : "ilike";
1!
36
        case MatchOp::REGEX:
2✔
37
            return negated ? "!~" : "~";
2✔
38
        case MatchOp::IREGEX:
1✔
39
            return negated ? "!~*" : "~*";
1!
NEW
40
        case MatchOp::ICONTAINS:
×
NEW
41
            break;
×
42
    }
NEW
43
    return "??";
×
44
}
45

46
void literal_to_string(std::ostringstream& os, const LiteralNode& lit) {
17✔
47
    std::visit(
34✔
48
        [&os](auto&& v) {
17✔
49
            using T = std::decay_t<decltype(v)>;
50
            if constexpr (std::is_same_v<T, std::string>) {
51
                os << '"' << v << '"';
16✔
52
            } else if constexpr (std::is_same_v<T, bool>) {
53
                os << (v ? "true" : "false");
×
54
            } else if constexpr (std::is_same_v<T, int64_t>) {
55
                os << v;
×
56
            } else if constexpr (std::is_same_v<T, uint64_t>) {
57
                os << v;
1✔
58
            } else if constexpr (std::is_same_v<T, double>) {
59
                os << v;
×
60
            }
61
        },
17✔
62
        lit.value);
17!
63
}
17✔
64

65
void array_to_string(std::ostringstream& os, const ArrayNode& arr) {
10✔
66
    os << '[';
10✔
67
    for (std::size_t i = 0; i < arr.elements.size(); ++i) {
23✔
68
        if (i > 0) os << ", ";
13✔
69
        literal_to_string(os, arr.elements[i]);
13✔
70
    }
71
    os << ']';
10✔
72
}
10✔
73

74
void node_to_string(std::ostringstream& os, const QueryNode& node) {
24✔
75
    std::visit(
48✔
76
        [&os](auto&& n) {
54✔
77
            using T = std::decay_t<decltype(n)>;
78
            if constexpr (std::is_same_v<T, CompareNode>) {
79
                os << n.field.path << ' ' << compare_op_str(n.op) << ' ';
4✔
80
                literal_to_string(os, n.value);
4✔
81
            } else if constexpr (std::is_same_v<T, InNode>) {
82
                os << n.field.path << " in ";
8✔
83
                array_to_string(os, n.values);
8✔
84
            } else if constexpr (std::is_same_v<T, NotInNode>) {
85
                os << n.field.path << " not in ";
2✔
86
                array_to_string(os, n.values);
2✔
87
            } else if constexpr (std::is_same_v<T, MatchNode>) {
88
                if (n.op == MatchOp::ICONTAINS) {
8✔
89
                    os << '"' << n.pattern
2✔
90
                       << (n.negated ? "\" not in " : "\" in ") << n.field.path;
2✔
91
                } else {
92
                    os << n.field.path << ' ' << match_op_str(n.op, n.negated)
12✔
93
                       << " \"" << n.pattern << '"';
6✔
94
                }
95
            } else if constexpr (std::is_same_v<T, AndNode>) {
96
                os << '(';
2✔
97
                node_to_string(os, *n.left);
2✔
98
                os << " and ";
2✔
99
                node_to_string(os, *n.right);
2✔
100
                os << ')';
2✔
101
            } else if constexpr (std::is_same_v<T, OrNode>) {
102
                os << '(';
×
103
                node_to_string(os, *n.left);
×
104
                os << " or ";
×
105
                node_to_string(os, *n.right);
×
106
                os << ')';
×
107
            } else if constexpr (std::is_same_v<T, NotNode>) {
108
                os << "not (";
×
109
                node_to_string(os, *n.operand);
×
110
                os << ')';
×
111
            }
112
        },
24✔
113
        node.data);
24!
114
}
24✔
115

116
void collect_fields_impl(const QueryNode& node,
428✔
117
                         dftracer::utils::StringViewSet& out) {
118
    std::visit(
856✔
119
        [&out](auto&& n) {
509✔
120
            using T = std::decay_t<decltype(n)>;
121
            if constexpr (std::is_same_v<T, CompareNode>) {
122
                out.insert(n.field.path);
297✔
123
            } else if constexpr (std::is_same_v<T, InNode>) {
124
                out.insert(n.field.path);
24✔
125
            } else if constexpr (std::is_same_v<T, NotInNode>) {
126
                out.insert(n.field.path);
4✔
127
            } else if constexpr (std::is_same_v<T, MatchNode>) {
128
                out.insert(n.field.path);
20✔
129
            } else if constexpr (std::is_same_v<T, AndNode>) {
130
                collect_fields_impl(*n.left, out);
55✔
131
                collect_fields_impl(*n.right, out);
55✔
132
            } else if constexpr (std::is_same_v<T, OrNode>) {
133
                collect_fields_impl(*n.left, out);
26✔
134
                collect_fields_impl(*n.right, out);
26✔
135
            } else if constexpr (std::is_same_v<T, NotNode>) {
136
                collect_fields_impl(*n.operand, out);
2✔
137
            }
138
        },
428✔
139
        node.data);
428!
140
}
428✔
141

142
}  // namespace
143

144
std::string to_string(const QueryNode& node) {
20✔
145
    std::ostringstream os;
20!
146
    node_to_string(os, node);
20!
147
    return os.str();
40!
148
}
20✔
149

150
dftracer::utils::StringViewSet collect_fields(const QueryNode& node) {
264✔
151
    dftracer::utils::StringViewSet fields;
264✔
152
    collect_fields_impl(node, fields);
264!
153
    return fields;
264✔
UNCOV
154
}
×
155

156
}  // namespace dftracer::utils::utilities::common::query
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc