Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
blocking-join-node.h
Go to the documentation of this file.
1 // Copyright 2013 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_EXEC_BLOCKING_JOIN_NODE_H
17 #define IMPALA_EXEC_BLOCKING_JOIN_NODE_H
18 
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/thread.hpp>
21 #include <string>
22 
23 #include "exec/exec-node.h"
24 #include "util/promise.h"
25 
26 #include "gen-cpp/PlanNodes_types.h" // for TJoinOp
27 
28 namespace impala {
29 
30 class MemPool;
31 class RowBatch;
32 class TupleRow;
33 
36 class BlockingJoinNode : public ExecNode {
37  public:
38  BlockingJoinNode(const std::string& node_name, const TJoinOp::type join_op,
39  ObjectPool* pool, const TPlanNode& tnode, const DescriptorTbl& descs);
40 
41  virtual ~BlockingJoinNode();
42 
45  virtual Status Init(const TPlanNode& tnode);
46 
49  virtual Status Prepare(RuntimeState* state);
50 
54  virtual Status Open(RuntimeState* state);
55 
58  virtual Status Reset(RuntimeState* state);
59 
62  virtual void Close(RuntimeState* state);
63 
64  static const char* LLVM_CLASS_NAME;
65 
66  protected:
67  const std::string node_name_;
68  TJoinOp::type join_op_;
69  bool eos_; // if true, nothing left to return in GetNext()
70  boost::scoped_ptr<MemPool> build_pool_; // holds everything referenced from build side
71 
75  boost::scoped_ptr<RowBatch> probe_batch_;
76 
77  bool probe_side_eos_; // if true, left child has no more rows to process
78 
81  int probe_batch_pos_; // current scan pos in probe_batch_
82  TupleRow* current_probe_row_; // The row currently being probed
83  bool matched_probe_; // if true, the current probe row is matched
84 
90 
95 
99 
100  RuntimeProfile::Counter* build_timer_; // time to prepare build side
101  RuntimeProfile::Counter* probe_timer_; // time to process the probe (left child) batch
103  RuntimeProfile::Counter* probe_row_counter_; // num probe (left child) rows
104 
108  virtual Status InitGetNext(TupleRow* first_left_child_row) = 0;
109 
113  virtual Status ConstructBuildSide(RuntimeState* state) = 0;
114 
117  virtual void AddToDebugString(int indentation_level, std::stringstream* out) const {
118  }
119 
121  virtual void DebugString(int indentation_level, std::stringstream* out) const;
122 
129  std::string GetLeftChildRowString(TupleRow* row);
130 
134  void CreateOutputRow(TupleRow* out_row, TupleRow* probe_row, TupleRow* build_row);
135 
136  private:
139  void BuildSideThread(RuntimeState* state, Promise<Status>* status);
140 };
141 
142 }
143 
144 #endif
virtual void AddToDebugString(int indentation_level, std::stringstream *out) const
void CreateOutputRow(TupleRow *out_row, TupleRow *probe_row, TupleRow *build_row)
virtual Status Prepare(RuntimeState *state)
BlockingJoinNode(const std::string &node_name, const TJoinOp::type join_op, ObjectPool *pool, const TPlanNode &tnode, const DescriptorTbl &descs)
virtual void Close(RuntimeState *state)
virtual Status Init(const TPlanNode &tnode)
RuntimeProfile::Counter * build_timer_
void BuildSideThread(RuntimeState *state, Promise< Status > *status)
RuntimeProfile::Counter * probe_timer_
boost::scoped_ptr< MemPool > build_pool_
std::string DebugString() const
Returns a string representation in DFS order of the plan rooted at this.
Definition: exec-node.cc:345
RuntimeProfile::Counter * probe_row_counter_
ObjectPool pool
virtual Status ConstructBuildSide(RuntimeState *state)=0
virtual Status Reset(RuntimeState *state)
virtual Status Open(RuntimeState *state)
const std::string node_name_
std::string GetLeftChildRowString(TupleRow *row)
static const char * LLVM_CLASS_NAME
RuntimeProfile::Counter * build_row_counter_
boost::scoped_ptr< RowBatch > probe_batch_
virtual Status InitGetNext(TupleRow *first_left_child_row)=0