Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
udf-builtins.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 #ifndef IMPALA_EXPRS_UDF_BUILTINS_H
16 #define IMPALA_EXPRS_UDF_BUILTINS_H
17 
18 #include "udf/udf.h"
19 
20 using namespace impala_udf;
21 
22 namespace impala {
23 
28 class UdfBuiltins {
29  public:
30  static DoubleVal Abs(FunctionContext* context, const DoubleVal& val);
31  static DoubleVal Pi(FunctionContext* context);
32  static StringVal Lower(FunctionContext* context, const StringVal& str);
33 
34  static IntVal MaxInt(FunctionContext* context);
35  static TinyIntVal MaxTinyInt(FunctionContext* context);
36  static SmallIntVal MaxSmallInt(FunctionContext* context);
37  static BigIntVal MaxBigInt(FunctionContext* context);
38  static IntVal MinInt(FunctionContext* context);
39  static TinyIntVal MinTinyInt(FunctionContext* context);
40  static SmallIntVal MinSmallInt(FunctionContext* context);
41  static BigIntVal MinBigInt(FunctionContext* context);
42 
43  static BooleanVal IsNan(FunctionContext* context, const DoubleVal& val);
44  static BooleanVal IsInf(FunctionContext* context, const DoubleVal& val);
45 
59  //
62  static TimestampVal Trunc(FunctionContext* context, const TimestampVal& date,
63  const StringVal& unit_str);
64  static void TruncPrepare(FunctionContext* context,
66  static void TruncClose(FunctionContext* context,
68 
74  //
76  static IntVal Extract(FunctionContext* context, const StringVal& field_str,
77  const TimestampVal& date);
78 
81  static IntVal Extract(FunctionContext* context, const TimestampVal& date,
82  const StringVal& field_str);
84  static void ExtractPrepare(FunctionContext* context,
86 
89  static void SwappedExtractPrepare(FunctionContext* context,
92  static void ExtractClose(FunctionContext* context,
94 
98  static StringVal ToVector(FunctionContext* context, int n, const DoubleVal* values);
99 
101  static StringVal PrintVector(FunctionContext* context, const StringVal& arr);
102 
104  static DoubleVal VectorGet(FunctionContext* context, const BigIntVal& n,
105  const StringVal& arr);
106 
112  static StringVal EncodeVector(FunctionContext* context, const StringVal& arr);
113 
115  static StringVal DecodeVector(FunctionContext* context, const StringVal& arr);
116 
117  private:
121  static void ExtractPrepare(FunctionContext* context,
122  FunctionContext::FunctionStateScope scope, int unit_idx);
123 };
124 
125 } // namespace impala
126 #endif
This object has a compatible storage format with boost::ptime.
Definition: udf.h:495