unival *scratch,
int current_cf,
rrd_value_t pdp_temp_val,
- unsigned long elapsed_pdp_st,
unsigned long start_pdp_offset,
unsigned long pdp_cnt);
int cdp_idx,
enum cf_en current_cf);
-static rrd_value_t initialize_average_carry_over(
+static rrd_value_t initialize_carry_over(
rrd_value_t pdp_temp_val,
+ int current_cf,
unsigned long elapsed_pdp_st,
unsigned long start_pdp_offset,
unsigned long pdp_cnt);
if (*cdp_unkn_pdp_cnt > pdp_cnt * xff) {
*cdp_primary_val = DNAN;
- if (current_cf == CF_AVERAGE) {
- *cdp_val =
- initialize_average_carry_over(pdp_temp_val,
- elapsed_pdp_st,
- start_pdp_offset, pdp_cnt);
- } else {
- *cdp_val = pdp_temp_val;
- }
} else {
initialize_cdp_val(scratch, current_cf, pdp_temp_val,
- elapsed_pdp_st, start_pdp_offset, pdp_cnt);
- } /* endif meets xff value requirement for a valid value */
+ start_pdp_offset, pdp_cnt);
+ }
+ *cdp_val =
+ initialize_carry_over(pdp_temp_val,current_cf,
+ elapsed_pdp_st,
+ start_pdp_offset, pdp_cnt);
+ /* endif meets xff value requirement for a valid value */
/* initialize carry over CDP_unkn_pdp_cnt, this must after CDP_primary_val
* is set because CDP_unkn_pdp_cnt is required to compute that value. */
if (isnan(pdp_temp_val))
unival *scratch,
int current_cf,
rrd_value_t pdp_temp_val,
- unsigned long elapsed_pdp_st,
unsigned long start_pdp_offset,
unsigned long pdp_cnt)
{
scratch[CDP_primary_val].u_val =
(cum_val + cur_val * start_pdp_offset) /
(pdp_cnt - scratch[CDP_unkn_pdp_cnt].u_cnt);
- scratch[CDP_val].u_val =
- initialize_average_carry_over(pdp_temp_val, elapsed_pdp_st,
- start_pdp_offset, pdp_cnt);
break;
- case CF_MAXIMUM:
+ case CF_MAXIMUM:
cum_val = IFDNAN(scratch[CDP_val].u_val, -DINF);
cur_val = IFDNAN(pdp_temp_val, -DINF);
+
#if 0
#ifdef DEBUG
if (isnan(scratch[CDP_val].u_val) && isnan(pdp_temp)) {
scratch[CDP_primary_val].u_val = cur_val;
else
scratch[CDP_primary_val].u_val = cum_val;
- /* initialize carry over value */
- scratch[CDP_val].u_val = pdp_temp_val;
break;
case CF_MINIMUM:
cum_val = IFDNAN(scratch[CDP_val].u_val, DINF);
scratch[CDP_primary_val].u_val = cur_val;
else
scratch[CDP_primary_val].u_val = cum_val;
- /* initialize carry over value */
- scratch[CDP_val].u_val = pdp_temp_val;
break;
case CF_LAST:
default:
scratch[CDP_primary_val].u_val = pdp_temp_val;
- /* initialize carry over value */
- scratch[CDP_val].u_val = pdp_temp_val;
break;
}
}
}
}
-static rrd_value_t initialize_average_carry_over(
+static rrd_value_t initialize_carry_over(
rrd_value_t pdp_temp_val,
+ int current_cf,
unsigned long elapsed_pdp_st,
unsigned long start_pdp_offset,
unsigned long pdp_cnt)
{
- /* initialize carry over value */
- if (isnan(pdp_temp_val)) {
- return DNAN;
- }
- return pdp_temp_val * ((elapsed_pdp_st - start_pdp_offset) % pdp_cnt);
+ unsigned long pdp_into_cdp_cnt = ((elapsed_pdp_st - start_pdp_offset) % pdp_cnt);
+ if ( pdp_into_cdp_cnt == 0 || isnan(pdp_temp_val)){
+ switch (current_cf) {
+ case CF_MAXIMUM:
+ return -DINF;
+ case CF_MINIMUM:
+ return DINF;
+ case CF_AVERAGE:
+ return 0;
+ default:
+ return DNAN;
+ }
+ }
+ else {
+ switch (current_cf) {
+ case CF_AVERAGE:
+ return pdp_temp_val * pdp_into_cdp_cnt ;
+ default:
+ return pdp_temp_val;
+ }
+ }
}
/*