OoOJoin  0.0.1
The next generation of out-of-order join operator
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 OoOJoin {
36 class NPJ_thread : public AbstractC20Thread {
37  private:
38  NPJTuplePtr *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  struct timeval timeBaseStruct;
46  //tsType timeStep = 1;
47  protected:
52  void inlineMain();
53  public:
54  NPJ_thread() {};
55  ~NPJ_thread() {};
56 
61  void syncTimeStruct(struct timeval tv) {
62  timeBaseStruct = tv;
63  }
64  /*void setTimeStep(tsType _timeStep) {
65  timeStep = _timeStep;
66  }*/
77  void init(NPJTuplePtr *_ts,
78  NPJTuplePtr *_tr,
79  size_t _sLen,
80  size_t _rLen,
81  int _cpu,
82  MultiThreadHashTablePtr _table,
83  BarrierPtr bar) {
84  ts = _ts;
85  tr = _tr;
86  sLen = _sLen;
87  rLen = _rLen;
88  cpu = _cpu;
89  table = _table;
90  buildBar = bar;
91  }
92 
93  size_t getResult() {
94  return result;
95  }
96  void waitBuildBar(void) {
97  if (buildBar) {
98  buildBar->arrive_and_wait();
99  }
100  }
101 };
102 
107 class NPJ : public AbstractJoinAlgo {
108 
109  private:
110  std::vector<NPJ_thread> workers;
111  public:
112  NPJ() {
113  setAlgoName("NPJ");
114  }
115  ~NPJ() {}
123  virtual size_t join(C20Buffer<OoOJoin::TrackTuplePtr> windS,
125  int threads = 1);
126 
127 };
132 typedef std::shared_ptr<NPJ> NPJPtr;
137 #define newNPJ std::make_shared<NPJ>
138 
143 class NPJSingle : public AbstractJoinAlgo {
144 
145  private:
146 
147  public:
148  NPJSingle() {
149  setAlgoName("NPJSingle");
150  }
151  ~NPJSingle() {}
159  virtual size_t join(C20Buffer<OoOJoin::TrackTuplePtr> windS,
161  int threads = 1);
162 
163 };
168 typedef std::shared_ptr<NPJSingle> NPJSinglePtr;
173 #define newNPJSingle std::make_shared<NPJSingle>
174 /***
175  * @}
176  */
177 }
178 #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.hpp:29
The abstraction to describe a join algorithm, providing virtual function of join.
Definition: AbstractJoinAlgo.h:36
void setAlgoName(std::string name)
set the name of algorithm
Definition: AbstractJoinAlgo.h:68
The top class package of single threadNPJ, providing a "join function".
Definition: NPJ.h:143
The thread used by NPJ.
Definition: NPJ.h:36
The top class package of NPJ, providing a "join function".
Definition: NPJ.h:107
std::shared_ptr< NPJSingle > NPJSinglePtr
The class to describe a shared pointer to NPJSingle.
Definition: NPJ.h:168
void inlineMain()
The 'main' function of NPJ thread.
Definition: NPJ.cpp:8
virtual size_t join(C20Buffer< OoOJoin::TrackTuplePtr > windS, C20Buffer< OoOJoin::TrackTuplePtr > windR, int threads=1)
The function to execute join,.
Definition: NPJ.cpp:33
void syncTimeStruct(struct timeval tv)
Synchronize the time structure with outside setting.
Definition: NPJ.h:61
void init(NPJTuplePtr *_ts, NPJTuplePtr *_tr, size_t _sLen, size_t _rLen, int _cpu, MultiThreadHashTablePtr _table, BarrierPtr bar)
THe init function.
Definition: NPJ.h:77
std::shared_ptr< NPJ > NPJPtr
The class to describe a shared pointer to NPJ.
Definition: NPJ.h:132
virtual size_t join(C20Buffer< OoOJoin::TrackTuplePtr > windS, C20Buffer< OoOJoin::TrackTuplePtr > windR, int threads=1)
The function to execute join,.
Definition: NPJ.cpp:83
Definition: OperatorTable.cpp:7