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

llnl / dftracer-utils / 29787659139

20 Jul 2026 11:34PM UTC coverage: 51.578% (-1.1%) from 52.66%
29787659139

Pull #99

github

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

34832 of 86278 branches covered (40.37%)

Branch coverage included in aggregate %.

1034 of 1319 new or added lines in 30 files covered. (78.39%)

5193 existing lines in 197 files now uncovered.

35349 of 49791 relevant lines covered (70.99%)

9765.54 hits per line

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

76.03
/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:
11
            return "==";
3✔
12
        case CompareOp::NE:
13
            return "!=";
×
14
        case CompareOp::GT:
15
            return ">";
1✔
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) {
6✔
31
    switch (op) {
6!
32
        case MatchOp::LIKE:
33
            return negated ? "not like" : "like";
2✔
34
        case MatchOp::ILIKE:
35
            return negated ? "not ilike" : "ilike";
1✔
36
        case MatchOp::REGEX:
37
            return negated ? "!~" : "~";
2✔
38
        case MatchOp::IREGEX:
39
            return negated ? "!~*" : "~*";
1✔
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) {
17✔
47
    std::visit(
17✔
48
        [&os](auto&& v) {
34✔
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
    }
13✔
71
    os << ']';
10✔
72
}
10✔
73

74
void node_to_string(std::ostringstream& os, const QueryNode& node) {
24✔
75
    std::visit(
24✔
76
        [&os](auto&& n) {
48✔
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 {
2✔
92
                    os << n.field.path << ' ' << match_op_str(n.op, n.negated)
6✔
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,
488✔
117
                         dftracer::utils::StringViewSet& out) {
118
    std::visit(
488✔
119
        [&out](auto&& n) {
977✔
120
            using T = std::decay_t<decltype(n)>;
121
            if constexpr (std::is_same_v<T, CompareNode>) {
122
                out.insert(n.field.path);
340✔
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);
49✔
131
                collect_fields_impl(*n.right, out);
49✔
132
            } else if constexpr (std::is_same_v<T, OrNode>) {
133
                collect_fields_impl(*n.left, out);
50✔
134
                collect_fields_impl(*n.right, out);
50✔
135
            } else if constexpr (std::is_same_v<T, NotNode>) {
136
                collect_fields_impl(*n.operand, out);
2✔
137
            }
138
        },
489✔
139
        node.data);
488✔
140
}
488✔
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();
20!
148
}
20✔
149

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