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

llnl / dftracer-utils / 28496595030

01 Jul 2026 05:50AM UTC coverage: 50.727% (-1.6%) from 52.278%
28496595030

Pull #83

github

web-flow
Merge 8f1ff4df5 into 2efed6649
Pull Request #83: refactor and improve code QoL

31872 of 80367 branches covered (39.66%)

Branch coverage included in aggregate %.

770 of 1591 new or added lines in 85 files covered. (48.4%)

5070 existing lines in 182 files now uncovered.

32742 of 47009 relevant lines covered (69.65%)

9887.52 hits per line

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

57.73
/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) {
3✔
9
    switch (op) {
3!
10
        case CompareOp::EQ:
11
            return "==";
2✔
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
}
3✔
25

26
namespace {
27

28
void literal_to_string(std::ostringstream& os, const LiteralNode& lit) {
3✔
29
    std::visit(
3✔
30
        [&os](auto&& v) {
6✔
31
            using T = std::decay_t<decltype(v)>;
32
            if constexpr (std::is_same_v<T, std::string>) {
33
                os << '"' << v << '"';
2✔
34
            } else if constexpr (std::is_same_v<T, bool>) {
35
                os << (v ? "true" : "false");
×
36
            } else if constexpr (std::is_same_v<T, int64_t>) {
37
                os << v;
×
38
            } else if constexpr (std::is_same_v<T, uint64_t>) {
39
                os << v;
1✔
40
            } else if constexpr (std::is_same_v<T, double>) {
41
                os << v;
×
42
            }
43
        },
3✔
44
        lit.value);
3✔
45
}
3✔
46

47
void array_to_string(std::ostringstream& os, const ArrayNode& arr) {
×
48
    os << '[';
×
49
    for (std::size_t i = 0; i < arr.elements.size(); ++i) {
×
50
        if (i > 0) os << ", ";
×
51
        literal_to_string(os, arr.elements[i]);
×
UNCOV
52
    }
×
53
    os << ']';
×
54
}
×
55

56
void node_to_string(std::ostringstream& os, const QueryNode& node) {
4✔
57
    std::visit(
4✔
58
        [&os](auto&& n) {
8✔
59
            using T = std::decay_t<decltype(n)>;
60
            if constexpr (std::is_same_v<T, CompareNode>) {
61
                os << n.field.path << ' ' << compare_op_str(n.op) << ' ';
3✔
62
                literal_to_string(os, n.value);
3✔
63
            } else if constexpr (std::is_same_v<T, InNode>) {
64
                os << n.field.path << " in ";
×
65
                array_to_string(os, n.values);
×
66
            } else if constexpr (std::is_same_v<T, NotInNode>) {
67
                os << n.field.path << " not in ";
×
68
                array_to_string(os, n.values);
×
69
            } else if constexpr (std::is_same_v<T, AndNode>) {
70
                os << '(';
1✔
71
                node_to_string(os, *n.left);
1✔
72
                os << " and ";
1✔
73
                node_to_string(os, *n.right);
1✔
74
                os << ')';
1✔
75
            } else if constexpr (std::is_same_v<T, OrNode>) {
76
                os << '(';
×
77
                node_to_string(os, *n.left);
×
78
                os << " or ";
×
79
                node_to_string(os, *n.right);
×
80
                os << ')';
×
81
            } else if constexpr (std::is_same_v<T, NotNode>) {
82
                os << "not (";
×
83
                node_to_string(os, *n.operand);
×
84
                os << ')';
×
85
            }
86
        },
4✔
87
        node.data);
4✔
88
}
4✔
89

90
void collect_fields_impl(const QueryNode& node,
406✔
91
                         dftracer::utils::StringViewSet& out) {
92
    std::visit(
406✔
93
        [&out](auto&& n) {
812✔
94
            using T = std::decay_t<decltype(n)>;
95
            if constexpr (std::is_same_v<T, CompareNode>) {
96
                out.insert(n.field.path);
301✔
97
            } else if constexpr (std::is_same_v<T, InNode>) {
98
                out.insert(n.field.path);
16✔
99
            } else if constexpr (std::is_same_v<T, NotInNode>) {
100
                out.insert(n.field.path);
2✔
101
            } else if constexpr (std::is_same_v<T, AndNode>) {
102
                collect_fields_impl(*n.left, out);
36✔
103
                collect_fields_impl(*n.right, out);
36✔
104
            } else if constexpr (std::is_same_v<T, OrNode>) {
105
                collect_fields_impl(*n.left, out);
49✔
106
                collect_fields_impl(*n.right, out);
49✔
107
            } else if constexpr (std::is_same_v<T, NotNode>) {
108
                collect_fields_impl(*n.operand, out);
2✔
109
            }
110
        },
406✔
111
        node.data);
406✔
112
}
406✔
113

114
}  // namespace
115

116
std::string to_string(const QueryNode& node) {
2✔
117
    std::ostringstream os;
2✔
118
    node_to_string(os, node);
2!
119
    return os.str();
2!
120
}
2✔
121

122
dftracer::utils::StringViewSet collect_fields(const QueryNode& node) {
234✔
123
    dftracer::utils::StringViewSet fields;
234✔
124
    collect_fields_impl(node, fields);
234!
125
    return fields;
234✔
126
}
234!
127

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

© 2026 Coveralls, Inc