4
missing - maximal empty interval (without data). It's precise up to existing
5
caching levels and should be used only to make decision if there anything
6
missing in the data or not. No support for subresolution data.
10
var $items, $n, $missing;
15
function __construct($items) {
16
$this->min = array(); $this->max = array();
17
$this->mean = array();
21
$this->items = $items;
23
$this->missing_counter = 0;
26
function Push(DATA &$v, $width) {
28
$this->missing_counter += $width;
33
if ($items != $this->items)
34
throw new ADEIException(translate("Number of items in the group have changed from %u to %u (Data::Push)", $this->items, $items));
37
for ($i = 0; $i < $items; $i++) {
38
if ($v->min[$i] < $this->min[$i]) $this->min[$i] = $v->min[$i];
39
if ($v->max[$i] > $this->max[$i]) $this->max[$i] = $v->max[$i];
41
$this->mean[$i] = ($this->mean[$i] * $this->n + $v->mean[$i] * $v->n) / ($this->n + $v->n);
44
if ($this->missing_counter) {
45
if ($this->missing_counter > $this->missing) $this->missing = $this->missing_counter;
46
$this->missing_counter = 0;
47
} else if ($v->missing > $this->missing) $this->missing = $v->missing;
49
for ($i=0; $i < $items; $i++) {
50
$this->min[$i] = $v->min[$i];
51
$this->max[$i] = $v->max[$i];
52
$this->mean[$i] = $v->mean[$i];
55
if ($this->missing_counter) {
56
$this->missing = $this->missing_counter;
57
$this->missing_counter = 0;
58
} else $this->missing = $v->missing;
64
// Row from CACHE table (non 0)
65
function PushRow(&$v, $width) {
69
$this->missing_counter += $width;
74
$items = (count($v) - 3) / 3;
76
if ($items != $this->items)
77
throw new ADEIException(translate("Number of items in the group have changed from %u to %u (Data::PushRow)", $this->items, $items));
80
for ($i = 0, $j = 2; $i < $items; $i++) {
81
if ($v[++$j] < $this->min[$i]) $this->min[$i] = $v[$j];
82
if ($v[++$j] > $this->max[$i]) $this->max[$i] = $v[$j];
83
$this->mean[$i] = ($this->mean[$i] * $this->n + $n * $v[++$j]) / ($this->n + $n);
86
if ($this->missing_counter) {
87
if ($this->missing_counter > $this->missing) $this->missing = $this->missing_counter;
88
$this->missing_counter = 0;
89
} elseif ($missing > $this->missing) $this->missing = $missing;
91
for ($i=0, $j = 2; $i < $items; $i++) {
92
$this->min[$i] = $v[++$j];
93
$this->max[$i] = $v[++$j];
94
$this->mean[$i] = $v[++$j];
97
if ($this->missing_counter) {
98
$this->missing = $this->missing_counter;
99
$this->missing_counter = 0;
100
} else $this->missing = $missing;
107
function PushValue(&$v, $gap) {
111
if ($items != $this->items)
112
throw new ADEIException(translate("Number of items in the group have changed from %u to %u (Data::PushValue)", $this->items, $items));
115
for ($i = 0; $i < $items; $i++) {
116
if ($v[$i] < $this->min[$i]) $this->min[$i] = $v[$i];
117
if ($v[$i] > $this->max[$i]) $this->max[$i] = $v[$i];
118
$this->mean[$i] = ($this->mean[$i] * $this->n + $v[$i]) / ($this->n + 1);
121
for ($i=0; $i < $items; $i++) {
122
$this->min[$i] = $v[$i];
123
$this->max[$i] = $v[$i];
124
$this->mean[$i] = $v[$i];
128
if ($gap > $this->missing) $this->missing = $gap;
133
function Finalize($gap = 0) {
134
if ($gap > $this->missing) $this->missing = $gap;
135
if (is_float($this->missing)) $this->missing = (int)floor($this->missing);
137
if ($this->missing_counter > $this->missing) $this->missing = $this->missing_counter;
b'\\ No newline at end of file'