Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
data-source-scan-node.h
Go to the documentation of this file.
1 // Copyright 2014 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_DATA_SOURCE_SCAN_NODE_H_
17 #define IMPALA_EXEC_DATA_SOURCE_SCAN_NODE_H_
18 
19 #include <string>
20 #include <boost/scoped_ptr.hpp>
21 
22 #include "exec/scan-node.h"
24 #include "runtime/descriptors.h"
25 #include "runtime/mem-pool.h"
26 
27 #include "gen-cpp/ExternalDataSource_types.h"
28 
29 namespace impala {
30 
31 class Tuple;
32 
38 class DataSourceScanNode : public ScanNode {
39  public:
40  DataSourceScanNode(ObjectPool* pool, const TPlanNode& tnode, const DescriptorTbl& descs);
41 
43 
45  virtual Status Prepare(RuntimeState* state);
46 
48  virtual Status Open(RuntimeState* state);
49 
51  virtual Status GetNext(RuntimeState* state, RowBatch* row_batch, bool* eos);
52 
54  virtual Status Reset(RuntimeState* state);
55 
57  virtual void Close(RuntimeState* state);
58 
59  protected:
61  virtual void DebugString(int indentation_level, std::stringstream* out) const;
62 
63  private:
65  boost::scoped_ptr<ExternalDataSourceExecutor> data_source_executor_;
66 
68  const TDataSourceScanNode data_src_node_;
69 
72 
75 
78 
82  std::vector<SlotDescriptor*> materialized_slots_;
83 
85  std::string scan_handle_;
86 
89  boost::scoped_ptr<extdatasource::TGetNextResult> input_batch_;
90 
93  int num_rows_;
94 
97  size_t next_row_idx_;
98 
102  std::vector<int> cols_next_val_idx_;
103 
105  Status MaterializeNextRow(MemPool* mem_pool);
106 
109 
113 
116  if (!input_batch_->__isset.rows) return false;
117  return next_row_idx_ < num_rows_;
118  }
119 };
120 
121 }
122 
123 #endif
std::string scan_handle_
The opaque handle returned by the data source for the scan.
bool InputBatchHasNext()
True if input_batch_ has more rows.
DataSourceScanNode(ObjectPool *pool, const TPlanNode &tnode, const DescriptorTbl &descs)
virtual void Close(RuntimeState *state)
Close the scanner, and report errors.
A tuple with 0 materialised slots is represented as NULL.
Definition: tuple.h:48
virtual Status Open(RuntimeState *state)
Open the data source and initialize the first row batch.
int tuple_idx_
Tuple index in tuple row.
Status MaterializeNextRow(MemPool *mem_pool)
Materializes the next row (next_row_idx_) into tuple_.
boost::scoped_ptr< ExternalDataSourceExecutor > data_source_executor_
Used to call the external data source.
std::vector< int > cols_next_val_idx_
virtual Status Reset(RuntimeState *state)
NYI.
std::vector< SlotDescriptor * > materialized_slots_
std::string DebugString() const
Returns a string representation in DFS order of the plan rooted at this.
Definition: exec-node.cc:345
const TDataSourceScanNode data_src_node_
Thrift structure describing the data source scan node.
virtual Status GetNext(RuntimeState *state, RowBatch *row_batch, bool *eos)
Fill the next row batch, calls GetNext() on the external scanner.
ObjectPool pool
Tuple * tuple_
Current tuple.
Abstract base class of all scan nodes; introduces SetScanRange().
Definition: scan-node.h:77
boost::scoped_ptr< extdatasource::TGetNextResult > input_batch_
Status GetNextInputBatch()
Gets the next batch from the data source, stored in input_batch_.
const TupleDescriptor * tuple_desc_
Descriptor of tuples read.
virtual Status Prepare(RuntimeState *state)
Load the data source library and create the ExternalDataSourceExecutor.