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

llnl / dftracer-utils / 30002033718

23 Jul 2026 11:08AM UTC coverage: 52.742% (+0.08%) from 52.66%
30002033718

Pull #99

github

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

41941 of 102829 branches covered (40.79%)

Branch coverage included in aggregate %.

2221 of 2839 new or added lines in 58 files covered. (78.23%)

137 existing lines in 13 files now uncovered.

37042 of 46924 relevant lines covered (78.94%)

59523.07 hits per line

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

74.83
/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) {
8✔
9
    switch (op) {
8!
10
        case CompareOp::EQ:
3✔
11
            return "==";
6✔
12
        case CompareOp::NE:
13
            return "!=";
×
14
        case CompareOp::GT:
1✔
15
            return ">";
2✔
16
        case CompareOp::LT:
17
            return "<";
×
18
        case CompareOp::GE:
19
            return ">=";
×
20
        case CompareOp::LE:
21
            return "<=";
×
22
    }
23
    return "??";
×
24
}
4✔
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) {
12✔
31
    switch (op) {
12!
32
        case MatchOp::LIKE:
2✔
33
            return negated ? "not like" : "like";
4✔
34
        case MatchOp::ILIKE:
1✔
35
            return negated ? "not ilike" : "ilike";
2!
36
        case MatchOp::REGEX:
2✔
37
            return negated ? "!~" : "~";
4✔
38
        case MatchOp::IREGEX:
1✔
39
            return negated ? "!~*" : "~*";
2!
40
        case MatchOp::ICONTAINS:
NEW
41
            break;
×
42
    }
NEW
43
    return "??";
×
44
}
6✔
45

46
void literal_to_string(std::ostringstream& os, const LiteralNode& lit) {
34✔
47
    std::visit(
51✔
48
        [&os](auto&& v) {
51✔
49
            using T = std::decay_t<decltype(v)>;
50
            if constexpr (std::is_same_v<T, std::string>) {
51
                os << '"' << v << '"';
32✔
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;
2✔
58
            } else if constexpr (std::is_same_v<T, double>) {
59
                os << v;
×
60
            }
61
        },
34✔
62
        lit.value);
34!
63
}
34✔
64

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

74
void node_to_string(std::ostringstream& os, const QueryNode& node) {
48✔
75
    std::visit(
72✔
76
        [&os](auto&& n) {
102✔
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) << ' ';
8✔
80
                literal_to_string(os, n.value);
8✔
81
            } else if constexpr (std::is_same_v<T, InNode>) {
82
                os << n.field.path << " in ";
16✔
83
                array_to_string(os, n.values);
16✔
84
            } else if constexpr (std::is_same_v<T, NotInNode>) {
85
                os << n.field.path << " not in ";
4✔
86
                array_to_string(os, n.values);
4✔
87
            } else if constexpr (std::is_same_v<T, MatchNode>) {
88
                if (n.op == MatchOp::ICONTAINS) {
16✔
89
                    os << '"' << n.pattern
4✔
90
                       << (n.negated ? "\" not in " : "\" in ") << n.field.path;
4✔
91
                } else {
2✔
92
                    os << n.field.path << ' ' << match_op_str(n.op, n.negated)
18✔
93
                       << " \"" << n.pattern << '"';
12✔
94
                }
95
            } else if constexpr (std::is_same_v<T, AndNode>) {
96
                os << '(';
4✔
97
                node_to_string(os, *n.left);
4✔
98
                os << " and ";
4✔
99
                node_to_string(os, *n.right);
4✔
100
                os << ')';
4✔
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
        },
48✔
113
        node.data);
48!
114
}
48✔
115

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

142
}  // namespace
143

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

150
dftracer::utils::StringViewSet collect_fields(const QueryNode& node) {
576✔
151
    dftracer::utils::StringViewSet fields;
576✔
152
    collect_fields_impl(node, fields);
576!
153
    return fields;
576✔
154
}
288!
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