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

getdozer / dozer / 6299724219

25 Sep 2023 12:58PM UTC coverage: 77.81% (+0.5%) from 77.275%
6299724219

push

github

chubei
fix: Add `BINDGEN_EXTRA_CLANG_ARGS` to cross compile rocksdb

50223 of 64546 relevant lines covered (77.81%)

148909.49 hits per line

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

98.41
/dozer-cache/src/cache/expression/mod.rs
1
use dozer_types::serde::{Deserialize, Serialize};
2
use dozer_types::serde_json::Value;
3
mod query_helper;
4
mod query_serde;
5
use dozer_types::constants::DEFAULT_DEFAULT_MAX_NUM_RECORDS;
6
#[cfg(test)]
7
mod tests;
8

9
#[derive(Clone, Debug, Copy, PartialEq)]
6✔
10
pub enum Skip {
11
    Skip(usize),
12
    After(u64),
13
}
14

15
impl Default for Skip {
16
    fn default() -> Self {
692✔
17
        Skip::Skip(0)
692✔
18
    }
692✔
19
}
20

21
#[derive(Clone, Debug, PartialEq)]
6✔
22
pub struct QueryExpression {
23
    pub filter: Option<FilterExpression>,
24
    pub order_by: SortOptions,
25
    pub limit: Option<usize>,
26
    pub skip: Skip,
27
}
28

29
impl QueryExpression {
30
    pub fn with_limit(limit: usize) -> Self {
70✔
31
        Self {
70✔
32
            filter: None,
70✔
33
            order_by: Default::default(),
70✔
34
            limit: Some(limit),
70✔
35
            skip: Default::default(),
70✔
36
        }
70✔
37
    }
70✔
38

39
    pub fn with_no_limit() -> Self {
66✔
40
        Self {
66✔
41
            filter: None,
66✔
42
            order_by: Default::default(),
66✔
43
            limit: None,
66✔
44
            skip: Default::default(),
66✔
45
        }
66✔
46
    }
66✔
47
}
48

49
impl Default for QueryExpression {
50
    fn default() -> Self {
35✔
51
        Self::with_limit(DEFAULT_DEFAULT_MAX_NUM_RECORDS)
35✔
52
    }
35✔
53
}
54

55
impl QueryExpression {
56
    pub fn new(
35✔
57
        filter: Option<FilterExpression>,
35✔
58
        order_by: Vec<SortOption>,
35✔
59
        limit: Option<usize>,
35✔
60
        skip: Skip,
35✔
61
    ) -> Self {
35✔
62
        Self {
35✔
63
            filter,
35✔
64
            order_by: SortOptions(order_by),
35✔
65
            limit,
35✔
66
            skip,
35✔
67
        }
35✔
68
    }
35✔
69
}
70

71
#[derive(Clone, Debug, PartialEq)]
27✔
72
pub enum FilterExpression {
73
    // a = 1, a containts "s", a > 4
74
    Simple(String, Operator, Value),
75
    And(Vec<FilterExpression>),
76
}
77

78
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
4,365✔
79
#[serde(crate = "dozer_types::serde")]
80
pub enum Operator {
81
    #[serde(rename = "$lt")]
82
    LT,
83
    #[serde(rename = "$lte")]
84
    LTE,
85
    #[serde(rename = "$eq")]
86
    EQ,
87
    #[serde(rename = "$gt")]
88
    GT,
89
    #[serde(rename = "$gte")]
90
    GTE,
91
    #[serde(rename = "$contains")]
92
    Contains,
93
    #[serde(rename = "$matches_any")]
94
    MatchesAny,
95
    #[serde(rename = "$matches_all")]
96
    MatchesAll,
97
}
98

99
impl Operator {
100
    pub fn supported_by_sorted_inverted(&self) -> bool {
1,799✔
101
        match self {
1,799✔
102
            Operator::LT | Operator::LTE | Operator::EQ | Operator::GT | Operator::GTE => true,
1,799✔
103
            Operator::Contains | Operator::MatchesAny | Operator::MatchesAll => false,
×
104
        }
105
    }
1,799✔
106

107
    pub fn supported_by_full_text(&self) -> bool {
3,706✔
108
        match self {
3,706✔
109
            Operator::LT | Operator::LTE | Operator::EQ | Operator::GT | Operator::GTE => false,
3,671✔
110
            Operator::Contains | Operator::MatchesAny | Operator::MatchesAll => true,
35✔
111
        }
112
    }
3,706✔
113

114
    pub fn is_range_operator(&self) -> bool {
6,301✔
115
        match self {
6,301✔
116
            Operator::LT | Operator::LTE | Operator::GT | Operator::GTE => true,
2,597✔
117
            Operator::EQ | Operator::Contains | Operator::MatchesAny | Operator::MatchesAll => {
118
                false
3,704✔
119
            }
120
        }
121
    }
6,301✔
122
}
123

124
#[derive(Clone, Debug, PartialEq, Eq)]
4✔
125
pub struct SortOption {
126
    pub field_name: String,
127
    pub direction: SortDirection,
128
}
129

130
impl SortOption {
131
    pub fn new(field_name: String, direction: SortDirection) -> Self {
9✔
132
        Self {
9✔
133
            field_name,
9✔
134
            direction,
9✔
135
        }
9✔
136
    }
9✔
137
}
138

139
/// A wrapper of `Vec<SortOption>`, for customizing the `Serialize` and `Deserialize` implementation.
140
#[derive(Clone, Debug, PartialEq, Eq, Default)]
497✔
141
pub struct SortOptions(pub Vec<SortOption>);
142

143
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
6,269✔
144
#[serde(crate = "dozer_types::serde")]
145
pub enum SortDirection {
146
    #[serde(rename = "asc")]
147
    Ascending,
148
    #[serde(rename = "desc")]
149
    Descending,
150
}
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