@@ -118,9 +118,9 @@ impl AggAccum {
118118 use nodedb_query:: msgpack_scan:: aggregate_helpers as ah;
119119 match self {
120120 AggAccum :: Count { n } => {
121- if agg. field == "*" && agg. expr . is_none ( ) {
122- * n += 1 ;
123- } else if ah :: extract_non_null ( doc , & agg . field , agg . expr . as_ref ( ) ) . is_some ( ) {
121+ if ( agg. field == "*" && agg. expr . is_none ( ) )
122+ || ah :: extract_non_null ( doc , & agg . field , agg . expr . as_ref ( ) ) . is_some ( )
123+ {
124124 * n += 1 ;
125125 }
126126 }
@@ -168,10 +168,10 @@ impl AggAccum {
168168 }
169169 }
170170 AggAccum :: CountDistinct { seen } => {
171- if let Some ( bytes) = ah:: extract_bytes ( doc, & agg. field , agg. expr . as_ref ( ) ) {
172- if bytes != [ 0xc0u8 ] {
173- seen . insert ( bytes ) ;
174- }
171+ if let Some ( bytes) = ah:: extract_bytes ( doc, & agg. field , agg. expr . as_ref ( ) )
172+ && bytes != [ 0xc0u8 ]
173+ {
174+ seen . insert ( bytes ) ;
175175 }
176176 }
177177 AggAccum :: Welford { n, mean, m2 } => {
@@ -184,10 +184,10 @@ impl AggAccum {
184184 }
185185 }
186186 AggAccum :: Hll { hll } => {
187- if let Some ( bytes) = ah:: extract_bytes ( doc, & agg. field , agg. expr . as_ref ( ) ) {
188- if bytes != [ 0xc0u8 ] {
189- hll . add ( fnv1a ( & bytes ) ) ;
190- }
187+ if let Some ( bytes) = ah:: extract_bytes ( doc, & agg. field , agg. expr . as_ref ( ) )
188+ && bytes != [ 0xc0u8 ]
189+ {
190+ hll . add ( fnv1a ( & bytes ) ) ;
191191 }
192192 }
193193 AggAccum :: TDigest { digest } => {
@@ -198,45 +198,43 @@ impl AggAccum {
198198 }
199199 AggAccum :: TopK { ss, .. } => {
200200 let actual = field_after_colon ( & agg. field ) ;
201- if let Some ( bytes) = ah:: extract_bytes ( doc, actual, agg. expr . as_ref ( ) ) {
202- if bytes != [ 0xc0u8 ] {
203- ss . add ( fnv1a ( & bytes ) ) ;
204- }
201+ if let Some ( bytes) = ah:: extract_bytes ( doc, actual, agg. expr . as_ref ( ) )
202+ && bytes != [ 0xc0u8 ]
203+ {
204+ ss . add ( fnv1a ( & bytes ) ) ;
205205 }
206206 }
207207 AggAccum :: ArrayAgg { values } => {
208- if values. len ( ) < ARRAY_AGG_CAP {
209- if let Some ( v) = ah:: extract_value ( doc, & agg. field , agg. expr . as_ref ( ) ) {
210- if !v. is_null ( ) {
211- values. push ( v) ;
212- }
213- }
208+ if values. len ( ) < ARRAY_AGG_CAP
209+ && let Some ( v) = ah:: extract_value ( doc, & agg. field , agg. expr . as_ref ( ) )
210+ && !v. is_null ( )
211+ {
212+ values. push ( v) ;
214213 }
215214 }
216215 AggAccum :: ArrayAggDistinct { seen, values } => {
217- if values. len ( ) < ARRAY_AGG_CAP {
218- if let Some ( bytes) = ah:: extract_bytes ( doc, & agg. field , agg. expr . as_ref ( ) ) {
219- if bytes != [ 0xc0u8 ] && seen. insert ( bytes) {
220- if let Some ( v) = ah:: extract_value ( doc, & agg. field , agg. expr . as_ref ( ) ) {
221- values. push ( v) ;
222- }
223- }
224- }
216+ if values. len ( ) < ARRAY_AGG_CAP
217+ && let Some ( bytes) = ah:: extract_bytes ( doc, & agg. field , agg. expr . as_ref ( ) )
218+ && bytes != [ 0xc0u8 ]
219+ && seen. insert ( bytes)
220+ && let Some ( v) = ah:: extract_value ( doc, & agg. field , agg. expr . as_ref ( ) )
221+ {
222+ values. push ( v) ;
225223 }
226224 }
227225 AggAccum :: PercentileCont { values, .. } => {
228- if values . len ( ) < ARRAY_AGG_CAP {
229- let actual = field_after_colon ( & agg . field ) ;
230- if let Some ( v) = ah:: extract_f64 ( doc, actual, agg. expr . as_ref ( ) ) {
231- values . push ( v ) ;
232- }
226+ let actual = field_after_colon ( & agg . field ) ;
227+ if values . len ( ) < ARRAY_AGG_CAP
228+ && let Some ( v) = ah:: extract_f64 ( doc, actual, agg. expr . as_ref ( ) )
229+ {
230+ values . push ( v ) ;
233231 }
234232 }
235233 AggAccum :: StringAgg { parts } => {
236- if parts. len ( ) < ARRAY_AGG_CAP {
237- if let Some ( s) = ah:: extract_str ( doc, & agg. field , agg. expr . as_ref ( ) ) {
238- parts . push ( s ) ;
239- }
234+ if parts. len ( ) < ARRAY_AGG_CAP
235+ && let Some ( s) = ah:: extract_str ( doc, & agg. field , agg. expr . as_ref ( ) )
236+ {
237+ parts . push ( s ) ;
240238 }
241239 }
242240 }
0 commit comments