include/simdb/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
20 / 24
83.3%
Branches:
16 / 20
80.0%
Functions:
2 / 2
100.0%

sqlite/Constraints.hpp
Line Branch Exec Source
1 // <Constraints.hpp> -*- C++ -*-
2
3 #pragma once
4
5 #include <iostream>
6
7 namespace simdb {
8
9 /// This enum holds all the comparators for WHERE clauses in queries (scalar
10 /// target values).
11 enum class Constraints {
12 // WHERE val = 5
13 EQUAL,
14 // WHERE val != 5
15 NOT_EQUAL,
16 // WHERE val < 5
17 LESS,
18 // WHERE val <= 5
19 LESS_EQUAL,
20 // WHERE val > 5
21 GREATER,
22 // WHERE val >= 5
23 GREATER_EQUAL,
24 // For internal use only
25 __NUM_CONSTRAINTS__
26 };
27
28 /// This enum holds all the comparators for WHERE clauses in queries (multiple
29 /// target values).
30 enum class SetConstraints {
31 // WHERE val IN (4,5,6)
32 IN_SET = (int)simdb::Constraints::__NUM_CONSTRAINTS__,
33 // WHERE val NOT IN (4,5,6)
34 NOT_IN_SET,
35 // For internal use only
36 __NUM_CONSTRAINTS__
37 };
38
39 /// This enum holds all the comparators for WHERE clauses in queries (string
40 /// target values).
41 enum class QueryOperator { AND, OR, __NUM_CONSTRAINTS__ };
42
43 /// Stringifier for the Constraints enum
44 19471 inline std::string stringify(const simdb::Constraints constraint)
45 {
46
6/7
✓ Branch 2 → 3 taken 19450 times.
✓ Branch 2 → 8 taken 9 times.
✓ Branch 2 → 13 taken 2 times.
✓ Branch 2 → 18 taken 3 times.
✓ Branch 2 → 23 taken 3 times.
✓ Branch 2 → 28 taken 4 times.
✗ Branch 2 → 33 not taken.
19471 switch (constraint)
47 {
48 19450 case simdb::Constraints::EQUAL:
49
1/1
✓ Branch 5 → 6 taken 19450 times.
38900 return " = ";
50 9 case simdb::Constraints::NOT_EQUAL:
51
1/1
✓ Branch 10 → 11 taken 9 times.
18 return " != ";
52 2 case simdb::Constraints::LESS:
53
1/1
✓ Branch 15 → 16 taken 2 times.
4 return " < ";
54 3 case simdb::Constraints::LESS_EQUAL:
55
1/1
✓ Branch 20 → 21 taken 3 times.
6 return " <= ";
56 3 case simdb::Constraints::GREATER:
57
1/1
✓ Branch 25 → 26 taken 3 times.
6 return " > ";
58 4 case simdb::Constraints::GREATER_EQUAL:
59
1/1
✓ Branch 30 → 31 taken 4 times.
8 return " >= ";
60 ✗ default:
61
0/1
✗ Branch 35 → 36 not taken.
✗ return "INVALID";
62 }
63 }
64
65 /// Stringifier for the SetConstraints enum
66 22 inline std::string stringify(const simdb::SetConstraints constraint)
67 {
68
2/3
✓ Branch 2 → 3 taken 9 times.
✓ Branch 2 → 8 taken 13 times.
✗ Branch 2 → 13 not taken.
22 switch (constraint)
69 {
70 9 case simdb::SetConstraints::IN_SET:
71
1/1
✓ Branch 5 → 6 taken 9 times.
18 return " IN ";
72 13 case simdb::SetConstraints::NOT_IN_SET:
73
1/1
✓ Branch 10 → 11 taken 13 times.
26 return " NOT IN ";
74 ✗ default:
75
0/1
✗ Branch 15 → 16 not taken.
✗ return "INVALID";
76 }
77 }
78
79 } // namespace simdb
80