Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sort-exec-exprs.cc
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 #include "exec/sort-exec-exprs.h"
16 
17 #include "common/names.h"
18 
19 namespace impala {
20 
21 Status SortExecExprs::Init(const TSortInfo& sort_info, ObjectPool* pool) {
22  return Init(sort_info.ordering_exprs,
23  sort_info.__isset.sort_tuple_slot_exprs ? &sort_info.sort_tuple_slot_exprs : NULL,
24  pool);
25 }
26 
27 Status SortExecExprs::Init(const vector<TExpr>& ordering_exprs,
28  const vector<TExpr>* sort_tuple_slot_exprs, ObjectPool* pool) {
30  Expr::CreateExprTrees(pool, ordering_exprs, &lhs_ordering_expr_ctxs_));
31 
32  if (sort_tuple_slot_exprs != NULL) {
33  materialize_tuple_ = true;
34  RETURN_IF_ERROR(Expr::CreateExprTrees(pool, *sort_tuple_slot_exprs,
36  } else {
37  materialize_tuple_ = false;
38  }
39  return Status::OK;
40 }
41 
43  const RowDescriptor& output_row_desc, MemTracker* expr_mem_tracker) {
44  if (materialize_tuple_) {
46  sort_tuple_slot_expr_ctxs_, state, child_row_desc, expr_mem_tracker));
47  }
49  lhs_ordering_expr_ctxs_, state, output_row_desc, expr_mem_tracker));
50  return Status::OK;
51 }
52 
54  if (materialize_tuple_) {
56  }
59  return Status::OK;
60 }
61 
63  if (materialize_tuple_) {
65  }
68 }
69 
70 } //namespace impala
static Status Clone(const std::vector< ExprContext * > &ctxs, RuntimeState *state, std::vector< ExprContext * > *new_ctxs)
Definition: expr.cc:374
static Status Open(const std::vector< ExprContext * > &ctxs, RuntimeState *state)
Convenience function for opening multiple expr trees.
#define RETURN_IF_ERROR(stmt)
some generally useful macros
Definition: status.h:242
Status Open(RuntimeState *state)
Open all expressions used for sorting and tuple materialization.
std::vector< ExprContext * > sort_tuple_slot_expr_ctxs_
static void Close(const std::vector< ExprContext * > &ctxs, RuntimeState *state)
Convenience function for closing multiple expr trees.
std::vector< ExprContext * > rhs_ordering_expr_ctxs_
ObjectPool pool
Status Init(const TSortInfo &sort_info, ObjectPool *pool)
Initialize the expressions from a TSortInfo using the specified pool.
This class is thread-safe.
Definition: mem-tracker.h:61
std::vector< ExprContext * > lhs_ordering_expr_ctxs_
Create two ExprContexts for evaluating over the TupleRows.
static const Status OK
Definition: status.h:87
Status Prepare(RuntimeState *state, const RowDescriptor &child_row_desc, const RowDescriptor &output_row_desc, MemTracker *expr_mem_tracker)
Prepare all expressions used for sorting and tuple materialization.
static Status CreateExprTrees(ObjectPool *pool, const std::vector< TExpr > &texprs, std::vector< ExprContext * > *ctxs)
Definition: expr.cc:149
static Status Prepare(const std::vector< ExprContext * > &ctxs, RuntimeState *state, const RowDescriptor &row_desc, MemTracker *tracker)
void Close(RuntimeState *state)
Close all expressions used for sorting and tuple materialization.