MCPcopy Create free account
hub / github.com/comnik/declarative-dataflow / count

Function count

tests/aggregation_test.rs:118–174  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116
117#[test]
118fn count() {
119 let (e, amount) = (1, 2);
120 let data = vec![
121 TxData::add(1, ":amount", Number(5)),
122 TxData::add(2, ":amount", Number(10)),
123 TxData::add(2, ":amount", Number(10)),
124 TxData::add(1, ":amount", Number(2)),
125 TxData::add(1, ":amount", Number(4)),
126 TxData::add(1, ":amount", Number(6)),
127 ];
128
129 run_cases(vec![
130 Case {
131 description: "[:find (count ?amount) :where [?e :amount ?amount]]",
132 plan: Plan::Aggregate(Aggregate {
133 variables: vec![amount],
134 plan: Box::new(Plan::Project(Project {
135 variables: vec![amount],
136 plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)),
137 })),
138 aggregation_fns: vec![AggregationFn::COUNT],
139 key_variables: vec![],
140 aggregation_variables: vec![amount],
141 with_variables: vec![],
142 }),
143 transactions: vec![data.clone()],
144 expectations: vec![vec![(vec![Number(6)], 0, 1)]],
145 // set-semantics
146 // expectations: vec![
147 // vec![(vec![Number(5)], 0, 1)],
148 // ],
149 },
150 Case {
151 description: "[:find ?e (count ?amount) :where [?e :amount ?amount]]",
152 plan: Plan::Aggregate(Aggregate {
153 variables: vec![e, amount],
154 plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)),
155 aggregation_fns: vec![AggregationFn::COUNT],
156 key_variables: vec![e],
157 aggregation_variables: vec![amount],
158 with_variables: vec![],
159 }),
160 transactions: vec![data.clone()],
161 expectations: vec![vec![
162 (vec![Eid(1), Number(4)], 0, 1),
163 (vec![Eid(2), Number(2)], 0, 1),
164 ]],
165 // set-semantics
166 // expectations: vec![
167 // vec![
168 // (vec![Eid(1), Number(4)], 0, 1),
169 // (vec![Eid(2), Number(1)], 0, 1),
170 // ],
171 // ],
172 },
173 ]);
174}
175

Callers

nothing calls this directly

Calls 1

run_casesFunction · 0.70

Tested by

no test coverage detected