AllianceDB  0.0.1
AllianceDB is an open-source suite, including benchmarks and libs for evaluating and improving stream operation algorithms on modern hardwares.
NPJ.h
Go to the documentation of this file.
1 
2 //
3 // Created by tony on 04/03/22.
4 //
5 
6 #ifndef _JOINALGO_NPJ_NPJ_H_
7 #define _JOINALGO_NPJ_NPJ_H_
10 #include <barrier>
12 namespace INTELLI {
36 class NPJ_thread : public AbstractC20Thread {
37  private:
38  TuplePtr *ts, *tr;
39  size_t sLen = 0, rLen = 0;
40  int cpu = -1;
41  MultiThreadHashTablePtr table = nullptr;
42  size_t result = 0;
43  BarrierPtr buildBar = nullptr;
44  std::shared_ptr<std::thread> threadPtr;
45  protected:
50  void inlineMain();
51  public:
52  NPJ_thread() {};
53  ~NPJ_thread() {};
64  void init(TuplePtr *_ts,
65  TuplePtr *_tr,
66  size_t _sLen,
67  size_t _rLen,
68  int _cpu,
69  MultiThreadHashTablePtr _table,
70  BarrierPtr bar) {
71  ts = _ts;
72  tr = _tr;
73  sLen = _sLen;
74  rLen = _rLen;
75  cpu = _cpu;
76  table = _table;
77  buildBar = bar;
78  }
79 
80  size_t getResult() {
81  return result;
82  }
83  void waitBuildBar(void) {
84  if (buildBar) {
85  buildBar->arrive_and_wait();
86  }
87  }
88 };
89 
94 class NPJ : public AbstractJoinAlgo {
95 
96  private:
97  vector<NPJ_thread> workers;
98  public:
99  NPJ() {
100  setAlgoName("NPJ");
101  }
102  ~NPJ() {}
111  virtual size_t join(TuplePtrQueue ts, TuplePtrQueue tr, int threads = 1);
122  virtual size_t join(TuplePtr *ts, TuplePtr *tr, size_t tsLen, size_t trLen, int threads = 1);
132  virtual size_t join(TuplePtr *ts, TuplePtr tr, size_t tsLen, int threads = 1);
133 
141  virtual size_t join(TuplePtrQueue ts, TuplePtr tr, int threads = 1);
142 
143 };
144 
145 typedef std::shared_ptr<NPJ> NPJPtr;
146 #define newNPJ() make_shared<NPJ>()
147 
152 class NPJSingle : public AbstractJoinAlgo {
153 
154  private:
155 
156  public:
157  NPJSingle() {
158  setAlgoName("NPJSingle");
159  }
160  ~NPJSingle() {}
169  virtual size_t join(TuplePtrQueue ts, TuplePtrQueue tr, int threads = 1);
180  virtual size_t join(TuplePtr *ts, TuplePtr *tr, size_t tsLen, size_t trLen, int threads = 1);
190  virtual size_t join(TuplePtr *ts, TuplePtr tr, size_t tsLen, int threads = 1);
191 
199  virtual size_t join(TuplePtrQueue ts, TuplePtr tr, int threads = 1);
200 
201 };
202 
203 typedef std::shared_ptr<NPJSingle> NPJSinglePtr;
204 #define newNPJSingle() make_shared<NPJSingle>()
205 /***
206  * @}
207  */
208 }
209 #endif //ALIANCEDB_INCLUDE_JOINALGO_NPJ_NPJ_H_
The base class and abstraction of C++20 thread, and it can be derived into other threads.
Definition: AbstractC20Thread.h:28
The abstraction to describe a join algorithm, providing virtual function of join.
Definition: AbstractJoinAlgo.h:28
void setAlgoName(string name)
set the name of algorithm
Definition: AbstractJoinAlgo.h:101
The top class package of single threadNPJ, providing a "join function".
Definition: NPJ.h:152
The thread used by NPJ.
Definition: NPJ.h:36
The top class package of NPJ, providing a "join function".
Definition: NPJ.h:94
std::shared_ptr< class Tuple > TuplePtr
The class to describe a shared pointer to Tuple.
Definition: Types.h:150
std::shared_ptr< INTELLI::SPSCQueue< INTELLI::TuplePtr > > TuplePtrQueue
To describe a queue of TuplePtr under SPSCQueue.
Definition: Types.h:228
virtual size_t join(TuplePtrQueue ts, TuplePtrQueue tr, int threads=1)
The function to execute join.
void inlineMain()
The 'main' function of NPJ thread.
virtual size_t join(TuplePtrQueue ts, TuplePtr tr, int threads=1)
The function to execute join, batch of one, tuple of another.
virtual size_t join(TuplePtr *ts, TuplePtr tr, size_t tsLen, int threads=1)
The function to execute join, batch of one, tuple of another.
virtual size_t join(TuplePtr *ts, TuplePtr *tr, size_t tsLen, size_t trLen, int threads=1)
The function to execute join, legacy way.
virtual size_t join(TuplePtrQueue ts, TuplePtrQueue tr, int threads=1)
The function to execute join.
virtual size_t join(TuplePtr *ts, TuplePtr *tr, size_t tsLen, size_t trLen, int threads=1)
The function to execute join, legacy way.
void init(TuplePtr *_ts, TuplePtr *_tr, size_t _sLen, size_t _rLen, int _cpu, MultiThreadHashTablePtr _table, BarrierPtr bar)
THe init function.
Definition: NPJ.h:64
virtual size_t join(TuplePtrQueue ts, TuplePtr tr, int threads=1)
The function to execute join, batch of one, tuple of another.
virtual size_t join(TuplePtr *ts, TuplePtr tr, size_t tsLen, int threads=1)
The function to execute join, batch of one, tuple of another.
Definition: DatasetTool.h:10