1 | #include "ternary_arithmetic_filter.hpp" |
---|
2 | #include "workflow_graph.hpp" |
---|
3 | #include "yacc_var.hpp" |
---|
4 | #include "file.hpp" |
---|
5 | |
---|
6 | namespace xios |
---|
7 | { |
---|
8 | CScalarScalarFieldArithmeticFilter::CScalarScalarFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value1, double value2) |
---|
9 | : CFilter(gc, 1, this) |
---|
10 | , op(operatorExpr.getOpScalarScalarField(op)) |
---|
11 | , value1(value1) |
---|
12 | , value2(value2) |
---|
13 | { |
---|
14 | /* Nothing to do */ |
---|
15 | }; |
---|
16 | |
---|
17 | std::tuple<int, int, int> CScalarScalarFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) |
---|
18 | { |
---|
19 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
20 | int unique_filter_id; |
---|
21 | bool firstround; |
---|
22 | |
---|
23 | if(building_graph) |
---|
24 | { |
---|
25 | CWorkflowGraph::allocNodeEdge(); |
---|
26 | |
---|
27 | size_t filterhash = std::hash<StdString>{}(this->field->content+to_string(data[0]->timestamp)+this->field->getId()); |
---|
28 | |
---|
29 | // first round |
---|
30 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
31 | { |
---|
32 | firstround = true; |
---|
33 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
34 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
35 | |
---|
36 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+this->field->content+")", 3, 1, 0, data[0]); |
---|
37 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
38 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; |
---|
39 | |
---|
40 | |
---|
41 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); |
---|
42 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); |
---|
43 | |
---|
44 | |
---|
45 | if(CWorkflowGraph::build_begin) |
---|
46 | { |
---|
47 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
48 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
49 | |
---|
50 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
51 | } |
---|
52 | else CWorkflowGraph::build_begin = true; |
---|
53 | |
---|
54 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
55 | unique_filter_id = this->filterID; |
---|
56 | } |
---|
57 | // not first round |
---|
58 | else |
---|
59 | { |
---|
60 | firstround=false; |
---|
61 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
62 | if(data[0]->src_filterID != unique_filter_id) |
---|
63 | { |
---|
64 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
65 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
66 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
67 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | return std::make_tuple(building_graph, firstround, unique_filter_id); |
---|
73 | } |
---|
74 | |
---|
75 | CDataPacketPtr CScalarScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
76 | { |
---|
77 | CDataPacketPtr packet(new CDataPacket); |
---|
78 | packet->date = data[0]->date; |
---|
79 | packet->timestamp = data[0]->timestamp; |
---|
80 | packet->status = data[0]->status; |
---|
81 | |
---|
82 | std::tuple<int, int, int> graph = buildGraph(data); |
---|
83 | |
---|
84 | if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph); |
---|
85 | if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1; |
---|
86 | if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance; |
---|
87 | |
---|
88 | packet->field = this->field; |
---|
89 | |
---|
90 | if (packet->status == CDataPacket::NO_ERROR) |
---|
91 | packet->data.reference(op(value1,value2, data[0]->data)); |
---|
92 | |
---|
93 | return packet; |
---|
94 | } |
---|
95 | |
---|
96 | CScalarFieldScalarArithmeticFilter::CScalarFieldScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value1, double value2) |
---|
97 | : CFilter(gc, 1, this) |
---|
98 | , op(operatorExpr.getOpScalarFieldScalar(op)) |
---|
99 | , value1(value1) |
---|
100 | , value2(value2) |
---|
101 | { |
---|
102 | /* Nothing to do */ |
---|
103 | }; |
---|
104 | |
---|
105 | std::tuple<int, int, int> CScalarFieldScalarArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) |
---|
106 | { |
---|
107 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
108 | int unique_filter_id; |
---|
109 | bool firstround; |
---|
110 | |
---|
111 | if(building_graph) |
---|
112 | { |
---|
113 | CWorkflowGraph::allocNodeEdge(); |
---|
114 | |
---|
115 | size_t filterhash = std::hash<StdString>{}(this->field->content+to_string(data[0]->timestamp)+this->field->getId()); |
---|
116 | |
---|
117 | // first round |
---|
118 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
119 | { |
---|
120 | firstround = true; |
---|
121 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
122 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
123 | |
---|
124 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+this->field->content+")", 3, 1, 0, data[0]); |
---|
125 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
126 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; |
---|
127 | |
---|
128 | |
---|
129 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); |
---|
130 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); |
---|
131 | |
---|
132 | |
---|
133 | if(CWorkflowGraph::build_begin) |
---|
134 | { |
---|
135 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
136 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
137 | |
---|
138 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
139 | } |
---|
140 | else CWorkflowGraph::build_begin = true; |
---|
141 | |
---|
142 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
143 | unique_filter_id = this->filterID; |
---|
144 | } |
---|
145 | // not first round |
---|
146 | else |
---|
147 | { |
---|
148 | firstround=false; |
---|
149 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
150 | if(data[0]->src_filterID != unique_filter_id) |
---|
151 | { |
---|
152 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
153 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
154 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
155 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
156 | } |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | return std::make_tuple(building_graph, firstround, unique_filter_id); |
---|
161 | } |
---|
162 | |
---|
163 | CDataPacketPtr CScalarFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
164 | { |
---|
165 | CDataPacketPtr packet(new CDataPacket); |
---|
166 | packet->date = data[0]->date; |
---|
167 | packet->timestamp = data[0]->timestamp; |
---|
168 | packet->status = data[0]->status; |
---|
169 | |
---|
170 | std::tuple<int, int, int> graph = buildGraph(data); |
---|
171 | |
---|
172 | if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph); |
---|
173 | if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1; |
---|
174 | if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance; |
---|
175 | |
---|
176 | packet->field = this->field; |
---|
177 | |
---|
178 | if (packet->status == CDataPacket::NO_ERROR) |
---|
179 | packet->data.reference(op(value1, data[0]->data,value2)); |
---|
180 | |
---|
181 | return packet; |
---|
182 | } |
---|
183 | |
---|
184 | CScalarFieldFieldArithmeticFilter::CScalarFieldFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value) |
---|
185 | : CFilter(gc, 2, this) |
---|
186 | , op(operatorExpr.getOpScalarFieldField(op)) |
---|
187 | , value(value) |
---|
188 | { |
---|
189 | /* Nothing to do */ |
---|
190 | }; |
---|
191 | |
---|
192 | std::tuple<int, int, int> CScalarFieldFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) |
---|
193 | { |
---|
194 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
195 | int unique_filter_id; |
---|
196 | |
---|
197 | bool firstround; |
---|
198 | |
---|
199 | if(building_graph) |
---|
200 | { |
---|
201 | CWorkflowGraph::allocNodeEdge(); |
---|
202 | |
---|
203 | size_t filterhash = std::hash<StdString>{}(this->field->content+to_string(data[0]->timestamp)+this->field->getId()); |
---|
204 | |
---|
205 | // first round |
---|
206 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
207 | { |
---|
208 | firstround = true; |
---|
209 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
210 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
211 | |
---|
212 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+this->field->content+")", 3, 1, 0, data[0]); |
---|
213 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); |
---|
214 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; |
---|
215 | |
---|
216 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); |
---|
217 | |
---|
218 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
219 | if(CWorkflowGraph::build_begin) |
---|
220 | { |
---|
221 | |
---|
222 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
223 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
224 | |
---|
225 | edgeID = InvalidableObject::edgeIdGenerator++; |
---|
226 | |
---|
227 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); |
---|
228 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
229 | |
---|
230 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
231 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
232 | } |
---|
233 | CWorkflowGraph::build_begin = true; |
---|
234 | |
---|
235 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
236 | unique_filter_id = this->filterID; |
---|
237 | |
---|
238 | } |
---|
239 | // not first round |
---|
240 | else |
---|
241 | { |
---|
242 | firstround = false; |
---|
243 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
244 | if(data[0]->src_filterID != unique_filter_id) |
---|
245 | { |
---|
246 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
247 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
248 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
249 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
250 | } |
---|
251 | if(data[1]->src_filterID != unique_filter_id) |
---|
252 | { |
---|
253 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
254 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); |
---|
255 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
256 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
257 | } |
---|
258 | |
---|
259 | } |
---|
260 | } |
---|
261 | |
---|
262 | return std::make_tuple(building_graph, firstround, unique_filter_id); |
---|
263 | } |
---|
264 | |
---|
265 | CDataPacketPtr CScalarFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
266 | { |
---|
267 | CDataPacketPtr packet(new CDataPacket); |
---|
268 | packet->date = data[0]->date; |
---|
269 | packet->timestamp = data[0]->timestamp; |
---|
270 | packet->status = data[0]->status; |
---|
271 | |
---|
272 | std::tuple<int, int, int> graph = buildGraph(data); |
---|
273 | |
---|
274 | if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph); |
---|
275 | if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1; |
---|
276 | if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance; |
---|
277 | |
---|
278 | packet->field = this->field; |
---|
279 | |
---|
280 | if (data[0]->status != CDataPacket::NO_ERROR) |
---|
281 | packet->status = data[0]->status; |
---|
282 | else if (data[1]->status != CDataPacket::NO_ERROR) |
---|
283 | packet->status = data[1]->status; |
---|
284 | else |
---|
285 | { |
---|
286 | packet->status = CDataPacket::NO_ERROR; |
---|
287 | packet->data.reference(op(value, data[0]->data, data[1]->data)); |
---|
288 | } |
---|
289 | return packet; |
---|
290 | |
---|
291 | } |
---|
292 | |
---|
293 | |
---|
294 | CFieldScalarScalarArithmeticFilter::CFieldScalarScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value1, double value2) |
---|
295 | : CFilter(gc, 1, this) |
---|
296 | , op(operatorExpr.getOpFieldScalarScalar(op)) |
---|
297 | , value1(value1) |
---|
298 | , value2(value2) |
---|
299 | { |
---|
300 | /* Nothing to do */ |
---|
301 | }; |
---|
302 | |
---|
303 | std::tuple<int, int, int> CFieldScalarScalarArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) |
---|
304 | { |
---|
305 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
306 | int unique_filter_id; |
---|
307 | bool firstround; |
---|
308 | |
---|
309 | if(building_graph) |
---|
310 | { |
---|
311 | CWorkflowGraph::allocNodeEdge(); |
---|
312 | |
---|
313 | size_t filterhash = std::hash<StdString>{}(this->field->content+to_string(data[0]->timestamp)+this->field->getId()); |
---|
314 | |
---|
315 | // first round |
---|
316 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
317 | { |
---|
318 | firstround = true; |
---|
319 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
320 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
321 | |
---|
322 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+this->field->content+")", 3, 1, 0, data[0]); |
---|
323 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
324 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; |
---|
325 | |
---|
326 | |
---|
327 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); |
---|
328 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); |
---|
329 | |
---|
330 | |
---|
331 | if(CWorkflowGraph::build_begin) |
---|
332 | { |
---|
333 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
334 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
335 | |
---|
336 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
337 | } |
---|
338 | else CWorkflowGraph::build_begin = true; |
---|
339 | |
---|
340 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
341 | unique_filter_id = this->filterID; |
---|
342 | } |
---|
343 | // not first round |
---|
344 | else |
---|
345 | { |
---|
346 | firstround=false; |
---|
347 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
348 | if(data[0]->src_filterID != unique_filter_id) |
---|
349 | { |
---|
350 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
351 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
352 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
353 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | |
---|
358 | return std::make_tuple(building_graph, firstround, unique_filter_id); |
---|
359 | } |
---|
360 | |
---|
361 | CDataPacketPtr CFieldScalarScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
362 | { |
---|
363 | CDataPacketPtr packet(new CDataPacket); |
---|
364 | packet->date = data[0]->date; |
---|
365 | packet->timestamp = data[0]->timestamp; |
---|
366 | packet->status = data[0]->status; |
---|
367 | |
---|
368 | std::tuple<int, int, int> graph = buildGraph(data); |
---|
369 | |
---|
370 | if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph); |
---|
371 | if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1; |
---|
372 | if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance; |
---|
373 | |
---|
374 | packet->field = this->field; |
---|
375 | |
---|
376 | if (packet->status == CDataPacket::NO_ERROR) |
---|
377 | packet->data.reference(op(data[0]->data, value1, value2)); |
---|
378 | |
---|
379 | return packet; |
---|
380 | } |
---|
381 | |
---|
382 | |
---|
383 | CFieldScalarFieldArithmeticFilter::CFieldScalarFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value) |
---|
384 | : CFilter(gc, 2, this) |
---|
385 | , op(operatorExpr.getOpFieldScalarField(op)) |
---|
386 | , value(value) |
---|
387 | { |
---|
388 | /* Nothing to do */ |
---|
389 | }; |
---|
390 | |
---|
391 | std::tuple<int, int, int> CFieldScalarFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) |
---|
392 | { |
---|
393 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
394 | int unique_filter_id; |
---|
395 | |
---|
396 | bool firstround; |
---|
397 | |
---|
398 | if(building_graph) |
---|
399 | { |
---|
400 | CWorkflowGraph::allocNodeEdge(); |
---|
401 | |
---|
402 | size_t filterhash = std::hash<StdString>{}(this->field->content+to_string(data[0]->timestamp)+this->field->getId()); |
---|
403 | |
---|
404 | // first round |
---|
405 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
406 | { |
---|
407 | firstround = true; |
---|
408 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
409 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
410 | |
---|
411 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+this->field->content+")", 3, 1, 0, data[0]); |
---|
412 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); |
---|
413 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; |
---|
414 | |
---|
415 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); |
---|
416 | |
---|
417 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
418 | if(CWorkflowGraph::build_begin) |
---|
419 | { |
---|
420 | |
---|
421 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
422 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
423 | |
---|
424 | edgeID = InvalidableObject::edgeIdGenerator++; |
---|
425 | |
---|
426 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); |
---|
427 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
428 | |
---|
429 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
430 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
431 | } |
---|
432 | CWorkflowGraph::build_begin = true; |
---|
433 | |
---|
434 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
435 | unique_filter_id = this->filterID; |
---|
436 | |
---|
437 | } |
---|
438 | // not first round |
---|
439 | else |
---|
440 | { |
---|
441 | firstround = false; |
---|
442 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
443 | if(data[0]->src_filterID != unique_filter_id) |
---|
444 | { |
---|
445 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
446 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
447 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
448 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
449 | } |
---|
450 | if(data[1]->src_filterID != unique_filter_id) |
---|
451 | { |
---|
452 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
453 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); |
---|
454 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
455 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
456 | } |
---|
457 | |
---|
458 | } |
---|
459 | } |
---|
460 | |
---|
461 | return std::make_tuple(building_graph, firstround, unique_filter_id); |
---|
462 | } |
---|
463 | |
---|
464 | CDataPacketPtr CFieldScalarFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
465 | { |
---|
466 | CDataPacketPtr packet(new CDataPacket); |
---|
467 | packet->date = data[0]->date; |
---|
468 | packet->timestamp = data[0]->timestamp; |
---|
469 | packet->status = data[0]->status; |
---|
470 | |
---|
471 | std::tuple<int, int, int> graph = buildGraph(data); |
---|
472 | |
---|
473 | if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph); |
---|
474 | if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1; |
---|
475 | if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance; |
---|
476 | |
---|
477 | packet->field = this->field; |
---|
478 | |
---|
479 | if (data[0]->status != CDataPacket::NO_ERROR) |
---|
480 | packet->status = data[0]->status; |
---|
481 | else if (data[1]->status != CDataPacket::NO_ERROR) |
---|
482 | packet->status = data[1]->status; |
---|
483 | else |
---|
484 | { |
---|
485 | packet->status = CDataPacket::NO_ERROR; |
---|
486 | packet->data.reference(op(data[0]->data, value, data[1]->data)); |
---|
487 | } |
---|
488 | return packet; |
---|
489 | } |
---|
490 | |
---|
491 | CFieldFieldScalarArithmeticFilter::CFieldFieldScalarArithmeticFilter(CGarbageCollector& gc, const std::string& op, double value) |
---|
492 | : CFilter(gc, 2, this) |
---|
493 | , op(operatorExpr.getOpFieldFieldScalar(op)) |
---|
494 | , value(value) |
---|
495 | { |
---|
496 | /* Nothing to do */ |
---|
497 | }; |
---|
498 | |
---|
499 | std::tuple<int, int, int> CFieldFieldScalarArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) |
---|
500 | { |
---|
501 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
502 | int unique_filter_id; |
---|
503 | |
---|
504 | bool firstround; |
---|
505 | |
---|
506 | if(building_graph) |
---|
507 | { |
---|
508 | CWorkflowGraph::allocNodeEdge(); |
---|
509 | |
---|
510 | size_t filterhash = std::hash<StdString>{}(this->field->content+to_string(data[0]->timestamp)+this->field->getId()); |
---|
511 | |
---|
512 | // first round |
---|
513 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
514 | { |
---|
515 | firstround = true; |
---|
516 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
517 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
518 | |
---|
519 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+this->field->content+")", 3, 1, 0, data[0]); |
---|
520 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); |
---|
521 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; |
---|
522 | |
---|
523 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); |
---|
524 | |
---|
525 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
526 | if(CWorkflowGraph::build_begin) |
---|
527 | { |
---|
528 | |
---|
529 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
530 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
531 | |
---|
532 | edgeID = InvalidableObject::edgeIdGenerator++; |
---|
533 | |
---|
534 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); |
---|
535 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
536 | |
---|
537 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
538 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
539 | } |
---|
540 | CWorkflowGraph::build_begin = true; |
---|
541 | |
---|
542 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
543 | unique_filter_id = this->filterID; |
---|
544 | |
---|
545 | } |
---|
546 | // not first round |
---|
547 | else |
---|
548 | { |
---|
549 | firstround = false; |
---|
550 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
551 | if(data[0]->src_filterID != unique_filter_id) |
---|
552 | { |
---|
553 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
554 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
555 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
556 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
557 | } |
---|
558 | if(data[1]->src_filterID != unique_filter_id) |
---|
559 | { |
---|
560 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
561 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); |
---|
562 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
563 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
564 | } |
---|
565 | |
---|
566 | } |
---|
567 | } |
---|
568 | |
---|
569 | return std::make_tuple(building_graph, firstround, unique_filter_id); |
---|
570 | } |
---|
571 | |
---|
572 | CDataPacketPtr CFieldFieldScalarArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
573 | { |
---|
574 | CDataPacketPtr packet(new CDataPacket); |
---|
575 | packet->date = data[0]->date; |
---|
576 | packet->timestamp = data[0]->timestamp; |
---|
577 | packet->status = data[0]->status; |
---|
578 | |
---|
579 | std::tuple<int, int, int> graph = buildGraph(data); |
---|
580 | |
---|
581 | if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph); |
---|
582 | if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1; |
---|
583 | if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance; |
---|
584 | |
---|
585 | packet->field = this->field; |
---|
586 | |
---|
587 | if (data[0]->status != CDataPacket::NO_ERROR) |
---|
588 | packet->status = data[0]->status; |
---|
589 | else if (data[1]->status != CDataPacket::NO_ERROR) |
---|
590 | packet->status = data[1]->status; |
---|
591 | else |
---|
592 | { |
---|
593 | packet->status = CDataPacket::NO_ERROR; |
---|
594 | packet->data.reference(op(data[0]->data, data[1]->data, value)); |
---|
595 | } |
---|
596 | return packet; |
---|
597 | } |
---|
598 | |
---|
599 | |
---|
600 | CFieldFieldFieldArithmeticFilter::CFieldFieldFieldArithmeticFilter(CGarbageCollector& gc, const std::string& op) |
---|
601 | : CFilter(gc, 3, this) |
---|
602 | , op(operatorExpr.getOpFieldFieldField(op)) |
---|
603 | { |
---|
604 | /* Nothing to do */ |
---|
605 | }; |
---|
606 | |
---|
607 | std::tuple<int, int, int> CFieldFieldFieldArithmeticFilter::buildGraph(std::vector<CDataPacketPtr> data) |
---|
608 | { |
---|
609 | bool building_graph = this->tag ? data[0]->timestamp >= this->start_graph && data[0]->timestamp <= this->end_graph : false; |
---|
610 | int unique_filter_id; |
---|
611 | |
---|
612 | bool firstround; |
---|
613 | |
---|
614 | if(building_graph) |
---|
615 | { |
---|
616 | CWorkflowGraph::allocNodeEdge(); |
---|
617 | |
---|
618 | size_t filterhash = std::hash<StdString>{}(this->field->content+to_string(data[0]->timestamp)+this->field->getId()); |
---|
619 | |
---|
620 | // first round |
---|
621 | if(CWorkflowGraph::mapHashFilterID_ptr->find(filterhash) == CWorkflowGraph::mapHashFilterID_ptr->end()) |
---|
622 | { |
---|
623 | firstround = true; |
---|
624 | this->filterID = InvalidableObject::filterIdGenerator++; |
---|
625 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
626 | |
---|
627 | CWorkflowGraph::addNode(this->filterID, "Arithmetic Filter\\n("+this->field->content+")", 3, 1, 0, data[0]); |
---|
628 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes = this->field->record4graphXiosAttributes(); |
---|
629 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].distance = data[0]->distance+1; |
---|
630 | |
---|
631 | if(this->field->file) (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].attributes += "</br>file attributes : </br>" +this->field->file->record4graphXiosAttributes(); |
---|
632 | |
---|
633 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].filter_tag = this->tag; |
---|
634 | if(CWorkflowGraph::build_begin) |
---|
635 | { |
---|
636 | |
---|
637 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[0]); |
---|
638 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
639 | |
---|
640 | edgeID = InvalidableObject::edgeIdGenerator++; |
---|
641 | |
---|
642 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[1]); |
---|
643 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
644 | |
---|
645 | edgeID = InvalidableObject::edgeIdGenerator++; |
---|
646 | |
---|
647 | CWorkflowGraph::addEdge(edgeID, this->filterID, data[2]); |
---|
648 | (*CWorkflowGraph::mapFilters_ptr_with_info)[this->filterID].expected_entry_nb ++; |
---|
649 | |
---|
650 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
651 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
652 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[2]->src_filterID].filter_filled = 0 ; |
---|
653 | } |
---|
654 | CWorkflowGraph::build_begin = true; |
---|
655 | |
---|
656 | (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash] = this->filterID; |
---|
657 | unique_filter_id = this->filterID; |
---|
658 | |
---|
659 | } |
---|
660 | // not first round |
---|
661 | else |
---|
662 | { |
---|
663 | firstround = false; |
---|
664 | unique_filter_id = (*CWorkflowGraph::mapHashFilterID_ptr)[filterhash]; |
---|
665 | if(data[0]->src_filterID != unique_filter_id) |
---|
666 | { |
---|
667 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
668 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[0]); |
---|
669 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[0]->src_filterID].filter_filled = 0 ; |
---|
670 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
671 | } |
---|
672 | if(data[1]->src_filterID != unique_filter_id) |
---|
673 | { |
---|
674 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
675 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[1]); |
---|
676 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[1]->src_filterID].filter_filled = 0 ; |
---|
677 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
678 | } |
---|
679 | if(data[2]->src_filterID != unique_filter_id) |
---|
680 | { |
---|
681 | int edgeID = InvalidableObject::edgeIdGenerator++; |
---|
682 | CWorkflowGraph::addEdge(edgeID, unique_filter_id, data[2]); |
---|
683 | (*CWorkflowGraph::mapFilters_ptr_with_info)[data[2]->src_filterID].filter_filled = 0 ; |
---|
684 | (*CWorkflowGraph::mapFilters_ptr_with_info)[unique_filter_id].expected_entry_nb ++; |
---|
685 | } |
---|
686 | |
---|
687 | } |
---|
688 | } |
---|
689 | |
---|
690 | return std::make_tuple(building_graph, firstround, unique_filter_id); |
---|
691 | } |
---|
692 | |
---|
693 | CDataPacketPtr CFieldFieldFieldArithmeticFilter::apply(std::vector<CDataPacketPtr> data) |
---|
694 | { |
---|
695 | CDataPacketPtr packet(new CDataPacket); |
---|
696 | packet->date = data[0]->date; |
---|
697 | packet->timestamp = data[0]->timestamp; |
---|
698 | packet->status = data[0]->status; |
---|
699 | |
---|
700 | std::tuple<int, int, int> graph = buildGraph(data); |
---|
701 | |
---|
702 | if(std::get<0>(graph)) packet->src_filterID = std::get<2>(graph); |
---|
703 | if(std::get<0>(graph) && std::get<1>(graph)) packet->distance = data[0]->distance+1; |
---|
704 | if(std::get<0>(graph) && !std::get<1>(graph)) packet->distance = data[0]->distance; |
---|
705 | |
---|
706 | packet->field = this->field; |
---|
707 | |
---|
708 | if (data[0]->status != CDataPacket::NO_ERROR) |
---|
709 | packet->status = data[0]->status; |
---|
710 | else if (data[1]->status != CDataPacket::NO_ERROR) |
---|
711 | packet->status = data[1]->status; |
---|
712 | else if (data[2]->status != CDataPacket::NO_ERROR) |
---|
713 | packet->status = data[2]->status; |
---|
714 | else |
---|
715 | { |
---|
716 | packet->status = CDataPacket::NO_ERROR; |
---|
717 | packet->data.reference(op(data[0]->data, data[1]->data, data[2]->data)); |
---|
718 | } |
---|
719 | return packet; |
---|
720 | } |
---|
721 | |
---|
722 | } // namespace xios |
---|
723 | |
---|