Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
scalar-fn-call.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_SCALAR_FN_CALL_H_
17 #define IMPALA_EXPRS_SCALAR_FN_CALL_H_
18 
19 #include <string>
20 
21 #include "exprs/expr.h"
22 #include "udf/udf.h"
23 
24 using namespace impala_udf;
25 
26 namespace impala {
27 
28 class TExprNode;
29 
35 //
41 //
48 class ScalarFnCall: public Expr {
49  public:
50  virtual std::string DebugString() const;
51 
52  protected:
53  friend class Expr;
54 
55  ScalarFnCall(const TExprNode& node);
56  virtual Status Prepare(RuntimeState* state, const RowDescriptor& desc,
57  ExprContext* context);
58  virtual Status Open(RuntimeState* state, ExprContext* context,
60  virtual Status GetCodegendComputeFn(RuntimeState* state, llvm::Function** fn);
61  virtual void Close(RuntimeState* state, ExprContext* context,
63 
64  virtual bool IsConstant() const;
65 
66  virtual BooleanVal GetBooleanVal(ExprContext* context, TupleRow*);
67  virtual TinyIntVal GetTinyIntVal(ExprContext* context, TupleRow*);
68  virtual SmallIntVal GetSmallIntVal(ExprContext* context, TupleRow*);
69  virtual IntVal GetIntVal(ExprContext* context, TupleRow*);
70  virtual BigIntVal GetBigIntVal(ExprContext* context, TupleRow*);
71  virtual FloatVal GetFloatVal(ExprContext* context, TupleRow*);
72  virtual DoubleVal GetDoubleVal(ExprContext* context, TupleRow*);
73  virtual StringVal GetStringVal(ExprContext* context, TupleRow*);
74  virtual TimestampVal GetTimestampVal(ExprContext* context, TupleRow*);
75  virtual DecimalVal GetDecimalVal(ExprContext* context, TupleRow*);
76 
77  private:
82 
87 
92 
96 
99  void* scalar_fn_;
100 
102  int NumFixedArgs() const {
103  return vararg_start_idx_ >= 0 ? vararg_start_idx_ : children_.size();
104  }
105 
107  Status GetUdf(RuntimeState* state, llvm::Function** udf);
108 
112  Status GetFunction(RuntimeState* state, const std::string& symbol, void** fn);
113 
116  void EvaluateChildren(ExprContext* context, TupleRow* row,
117  std::vector<impala_udf::AnyVal*>* input_vals);
118 
120  template<typename RETURN_TYPE>
121  RETURN_TYPE InterpretEval(ExprContext* context, TupleRow* row);
122 };
123 
124 }
125 
126 #endif
void(* UdfClose)(FunctionContext *context, FunctionContext::FunctionStateScope scope)
Definition: udf.h:288
int NumFixedArgs() const
Returns the number of non-vararg arguments.
void(* UdfPrepare)(FunctionContext *context, FunctionContext::FunctionStateScope scope)
Definition: udf.h:275
This object has a compatible storage format with boost::ptime.
Definition: udf.h:495
std::string DebugString(const T &val)
Definition: udf-debug.h:27
This is the superclass of all expr evaluation nodes.
Definition: expr.h:116