fix query min-max, again... (#4495)
Costa Tsaousis committed
Oct 26, 2018 at 02:53 UTC
cdf57a00e1f1d8600bc0b90bf8f446ac475aef35
1 file changed
+9
-3
web/api/queries/query.c
+9
-3
@@ -408,7 +408,7 @@ static inline void do_dimension(
408
RRDR_VALUE_FLAGS
409
group_value_flags = RRDR_VALUE_NOTHING;
410
411
- calculated_number min = NAN, max = NAN;
411
+ calculated_number min = r->min, max = r->max;
412
size_t db_points_read = 0;
413
for( ; points_added < points_wanted ; now += dt, slot++ ) {
414
if(unlikely(slot >= entries)) slot = 0;
@@ -466,12 +466,18 @@ static inline void do_dimension(
466
calculated_number value = r->internal.grouping_flush(r, rrdr_value_options_ptr);
467
r->v[rrdr_line * r->d + dim_id_in_rrdr] = value;
468
469
- if(likely(points_added)) {
469
+ if(likely(points_added || dim_id_in_rrdr)) {
470
+ // find the min/max across all dimensions
471
+
472
if(unlikely(value < min)) min = value;
473
if(unlikely(value > max)) max = value;
474
+
475
}
473
- else
476
+ else {
477
+ // runs only when dim_id_in_rrdr == 0 && points_added == 0
478
+ // so, on the first point added for the query.
479
min = max = value;
480
+ }
481
482
points_added++;
483
values_in_group = 0;