@@ -165,37 +165,36 @@ impl UpscalingRules {
165165 self . rules . is_empty ( )
166166 }
167167
168- pub fn upscale_values ( & self , values : & mut [ i64 ] , labels : & [ Label ] ) -> anyhow:: Result < ( ) > {
169- if !self . is_empty ( ) {
170- // get bylabel rules first (if any)
171- let mut group_of_rules = labels
172- . iter ( )
173- . filter_map ( |label| {
174- self . get ( & (
175- label. get_key ( ) ,
176- match label. get_value ( ) {
177- LabelValue :: Str ( str) => * str,
178- LabelValue :: Num { .. } => StringId :: ZERO ,
179- } ,
180- ) )
181- } )
182- . collect :: < Vec < & Vec < UpscalingRule > > > ( ) ;
183-
184- // get byvalue rules if any
185- if let Some ( byvalue_rules) = self . get ( & ( StringId :: ZERO , StringId :: ZERO ) ) {
186- group_of_rules. push ( byvalue_rules) ;
187- }
168+ pub fn upscale_values ( & self , values : & mut [ i64 ] , labels : & [ Label ] ) {
169+ if self . is_empty ( ) {
170+ return ;
171+ }
172+ // get bylabel rules first (if any)
173+ let mut group_of_rules = labels
174+ . iter ( )
175+ . filter_map ( |label| {
176+ self . get ( & (
177+ label. get_key ( ) ,
178+ match label. get_value ( ) {
179+ LabelValue :: Str ( str) => * str,
180+ LabelValue :: Num { .. } => StringId :: ZERO ,
181+ } ,
182+ ) )
183+ } )
184+ . collect :: < Vec < & Vec < UpscalingRule > > > ( ) ;
188185
189- group_of_rules. iter ( ) . for_each ( |rules| {
190- rules. iter ( ) . for_each ( |rule| {
191- let scale = rule. compute_scale ( values) ;
192- rule. values_offset . iter ( ) . for_each ( |offset| {
193- values[ * offset] = ( values[ * offset] as f64 * scale) . round ( ) as i64
194- } )
195- } )
196- } ) ;
186+ // get byvalue rules if any
187+ if let Some ( byvalue_rules) = self . get ( & ( StringId :: ZERO , StringId :: ZERO ) ) {
188+ group_of_rules. push ( byvalue_rules) ;
197189 }
198190
199- Ok ( ( ) )
191+ group_of_rules. iter ( ) . for_each ( |rules| {
192+ rules. iter ( ) . for_each ( |rule| {
193+ let scale = rule. compute_scale ( values) ;
194+ rule. values_offset . iter ( ) . for_each ( |offset| {
195+ values[ * offset] = ( values[ * offset] as f64 * scale) . round ( ) as i64
196+ } )
197+ } )
198+ } ) ;
200199 }
201200}
0 commit comments