Akumuli
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
filterbyid.h
1 #pragma once
2 
3 #include <memory>
4 
5 #include "../queryprocessor_framework.h"
6 #include "../util.h" // for panic
7 
8 namespace Akumuli {
9 namespace QP {
10 
14 template <class Predicate>
15 struct FilterByIdNode : std::enable_shared_from_this<FilterByIdNode<Predicate>>, Node {
17  Predicate op_;
18  std::shared_ptr<Node> next_;
19 
20  FilterByIdNode(Predicate pred, std::shared_ptr<Node> next)
21  : op_(pred)
22  , next_(next) {}
23 
24  virtual void complete() { next_->complete(); }
25 
26  virtual bool put(const aku_Sample& sample) {
27  if (sample.payload.type > aku_PData::MARGIN) {
28  return next_->put(sample);
29  }
30  return op_(sample.paramid) ? next_->put(sample) : true;
31  }
32 
33  void set_error(aku_Status status) {
34  if (!next_) {
35  AKU_PANIC("bad query processor node, next not set");
36  }
37  next_->set_error(status);
38  }
39 
40  virtual int get_requirements() const { return EMPTY; }
41 };
42 }
43 } // namespace
Predicate op_
Id matching predicate.
Definition: filterbyid.h:17
Definition: queryprocessor_framework.h:28
virtual int get_requirements() const
Definition: filterbyid.h:40
Definition: filterbyid.h:15
virtual bool put(const aku_Sample &sample)
Definition: filterbyid.h:26
virtual void complete()
Complete adding values.
Definition: filterbyid.h:24