1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<?php
class READER_EXTRACTORFilter extends BASEDataFilter implements READER_SIMPLEDataFilter {
var $skip;
var $filters;
var $mappings;
var $cur_indexes;
var $real_indexes;
var $remove;
function __construct(READER $rdr, LOGGROUP $grp, DATAFilter $filter, &$opts = NULL) {
if ($rdr instanceof CACHEReader) $this->skip = true;
else {
$this->skip = false;
$this->filters = array();
foreach ($opts['extractors'] as $ext => &$items) {
$config = &$opts['config'][$ext];
$filter_class = $config['filter'];
ADEI::RequireClass("extractors/$filter_class", true);
$this->filters[$ext] = array();
foreach ($items as $item => $mask) {
$this->filters[$ext][$item] = new $filter_class($mask, $config);
}
}
$this->mappings = $opts['mappings'];
$mask = $filter->GetItemMask();
if (($mask)&&(!$mask->IsFull())) {
$this->check_masked = true;
$this->cur_indexes = array(); $i = 0;
foreach ($mask->ids as $id) {
$this->cur_indexes[$id] = $i++;
}
} else {
$this->check_masked = false;
$this->cur_indexes = range(0, $rdr->GetGroupSize($grp) - 1);
}
if (($opts['mask'])&&(!$opts['mask']->IsFull())) {
$this->real_indexes = array(); $i = 0;
foreach ($opts['mask']->ids as $id) {
$this->real_indexes[$id] = $i++;
}
} else {
$this->real_indexes = range(0, $rdr->GetGroupSize($grp) - 1);
}
$this->remove = sizeof($this->cur_mask) - sizeof($this->real_mask);
if ($this->remove < 0) $this->remove = 0;
}
}
function Start(&$data) {
if ($this->skip) return;
if (($this->check_masked)&&(!$data['masked']))
throw new ADEIException(translate("EXTRACTORFilter can't be executed on unmasked data..."));
}
function ProcessVector(&$data, &$time, &$values) {
if ($this->skip) return false;
$gen = array();
foreach ($this->filters as $ext => &$items) {
$gen[$ext] = array();
foreach ($items as $id => $filter) {
$gen[$ext][$id] = $filter->ExtractItem($data, $time, $id, $values[$this->cur_indexes[$id]]);
}
}
foreach ($this->mappings as $idx => $map) {
$values[$this->real_indexes[$idx]] = $gen[$map[0]][$map[1]][$map[2]];
}
for ($i = 0; $i < $this->remove; $i++) {
array_pop($values);
}
/*
// No dynamic masking
$data['mask'] = $this->real_mask;
*/
return false;
}
}
?>
|