Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
data-sink.h
Go to the documentation of this file.
1 // Copyright 2012 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_SINK_H
17 #define IMPALA_EXEC_DATA_SINK_H
18 
19 #include <boost/scoped_ptr.hpp>
20 #include <vector>
21 
22 #include "common/status.h"
23 #include "runtime/runtime-state.h"
24 #include "gen-cpp/DataSinks_types.h"
25 #include "gen-cpp/Exprs_types.h"
26 
27 namespace impala {
28 
29 class ObjectPool;
30 class RowBatch;
31 class RuntimeProfile;
32 class RuntimeState;
33 class TPlanExecRequest;
34 class TPlanExecParams;
35 class TPlanFragmentExecParams;
36 class RowDescriptor;
37 
39 class DataSink {
40  public:
41  DataSink() : closed_(false) { }
42  virtual ~DataSink() {}
43 
46  virtual Status Prepare(RuntimeState* state);
47 
49  virtual Status Open(RuntimeState* state) = 0;
50 
53  virtual Status Send(RuntimeState* state, RowBatch* batch, bool eos) = 0;
54 
59  virtual void Close(RuntimeState* state) = 0;
60 
64  const TDataSink& thrift_sink, const std::vector<TExpr>& output_exprs,
65  const TPlanFragmentExecParams& params,
66  const RowDescriptor& row_desc, boost::scoped_ptr<DataSink>* sink);
67 
69  virtual RuntimeProfile* profile() = 0;
70 
73  static void MergeInsertStats(const TInsertStats& src_stats,
74  TInsertStats* dst_stats);
75 
77  static std::string OutputInsertStats(const PartitionStatusMap& stats,
78  const std::string& prefix = "");
79 
80  protected:
83  bool closed_;
84 
85  boost::scoped_ptr<MemTracker> expr_mem_tracker_;
86 
87 };
88 
89 } // namespace impala
90 #endif
boost::scoped_ptr< MemTracker > expr_mem_tracker_
Definition: data-sink.h:85
virtual void Close(RuntimeState *state)=0
virtual RuntimeProfile * profile()=0
Returns the runtime profile for the sink.
virtual ~DataSink()
Definition: data-sink.h:42
virtual Status Open(RuntimeState *state)=0
Call before Send() or Close().
Superclass of all data sinks.
Definition: data-sink.h:39
std::map< std::string, TInsertPartitionStatus > PartitionStatusMap
Definition: runtime-state.h:51
ObjectPool pool
static std::string OutputInsertStats(const PartitionStatusMap &stats, const std::string &prefix="")
Outputs the insert stats contained in the map of insert partition updates to a string.
Definition: data-sink.cc:103
static void MergeInsertStats(const TInsertStats &src_stats, TInsertStats *dst_stats)
Definition: data-sink.cc:90
const RowDescriptor & row_desc() const
virtual Status Prepare(RuntimeState *state)
Definition: data-sink.cc:136
virtual Status Send(RuntimeState *state, RowBatch *batch, bool eos)=0
static Status CreateDataSink(ObjectPool *pool, const TDataSink &thrift_sink, const std::vector< TExpr > &output_exprs, const TPlanFragmentExecParams &params, const RowDescriptor &row_desc, boost::scoped_ptr< DataSink > *sink)
Definition: data-sink.cc:34