Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
case-expr.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_EXPRS_CASE_EXPR_H_
17 #define IMPALA_EXPRS_CASE_EXPR_H_
18 
19 #include <string>
20 #include "expr.h"
21 
22 using namespace impala_udf;
23 
24 namespace impala {
25 
26 class TExprNode;
27 
28 class CaseExpr: public Expr {
29  public:
30  virtual Status GetCodegendComputeFn(RuntimeState* state, llvm::Function** fn);
31 
32  virtual BooleanVal GetBooleanVal(ExprContext* ctx, TupleRow* row);
33  virtual TinyIntVal GetTinyIntVal(ExprContext* ctx, TupleRow* row);
34  virtual SmallIntVal GetSmallIntVal(ExprContext* ctx, TupleRow* row);
35  virtual IntVal GetIntVal(ExprContext* ctx, TupleRow* row);
36  virtual BigIntVal GetBigIntVal(ExprContext* ctx, TupleRow* row);
37  virtual FloatVal GetFloatVal(ExprContext* ctx, TupleRow* row);
38  virtual DoubleVal GetDoubleVal(ExprContext* ctx, TupleRow* row);
39  virtual StringVal GetStringVal(ExprContext* ctx, TupleRow* row);
40  virtual TimestampVal GetTimestampVal(ExprContext* ctx, TupleRow* row);
41  virtual DecimalVal GetDecimalVal(ExprContext* ctx, TupleRow* row);
42 
43  protected:
44  friend class Expr;
45  friend class ComputeFunctions;
46  friend class ConditionalFunctions;
47  friend class DecimalOperators;
48 
49  CaseExpr(const TExprNode& node);
50  virtual Status Prepare(RuntimeState* state, const RowDescriptor& row_desc,
51  ExprContext* context);
52  virtual Status Open(RuntimeState* state, ExprContext* context,
54  virtual void Close(RuntimeState* state, ExprContext* context,
56 
57  virtual std::string DebugString() const;
58 
59  bool has_case_expr() { return has_case_expr_; }
60  bool has_else_expr() { return has_else_expr_; }
61 
62  private:
63  const bool has_case_expr_;
64  const bool has_else_expr_;
65 
68  void GetChildVal(int child_idx, ExprContext* ctx, TupleRow* row, AnyVal* dst);
69 
71  bool AnyValEq(const ColumnType& type, const AnyVal* v1, const AnyVal* v2);
72 };
73 
74 }
75 
76 #endif
bool has_else_expr()
Definition: case-expr.h:60
const bool has_case_expr_
Definition: case-expr.h:63
This object has a compatible storage format with boost::ptime.
Definition: udf.h:495
const bool has_else_expr_
Definition: case-expr.h:64
Conditional functions that can be expressed as UDFs.
std::string DebugString(const T &val)
Definition: udf-debug.h:27
bool has_case_expr()
Definition: case-expr.h:59
This is the superclass of all expr evaluation nodes.
Definition: expr.h:116
const RowDescriptor & row_desc() const