Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
string-functions.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_STRING_FUNCTIONS_H
17 #define IMPALA_EXPRS_STRING_FUNCTIONS_H
18 
19 #include "runtime/string-value.h"
20 #include "runtime/string-search.h"
21 
22 using namespace impala_udf;
23 
24 namespace impala {
25 
26 class Expr;
27 class OpcodeRegistry;
28 class TupleRow;
29 
31  public:
32  static StringVal Substring(FunctionContext*, const StringVal& str, const BigIntVal& pos,
33  const BigIntVal& len);
34  static StringVal Substring(FunctionContext*, const StringVal& str, const BigIntVal& pos);
35  static StringVal Left(FunctionContext*, const StringVal& str, const BigIntVal& len);
36  static StringVal Right(FunctionContext*, const StringVal& str, const BigIntVal& len);
37  static StringVal Space(FunctionContext*, const BigIntVal& len);
38  static StringVal Repeat(FunctionContext*, const StringVal& str, const BigIntVal& n);
39  static StringVal Lpad(FunctionContext*, const StringVal& str, const BigIntVal& len,
40  const StringVal& pad);
41  static StringVal Rpad(FunctionContext*, const StringVal& str, const BigIntVal&,
42  const StringVal& pad);
43  static IntVal Length(FunctionContext*, const StringVal& str);
44  static IntVal CharLength(FunctionContext*, const StringVal& str);
45  static StringVal Lower(FunctionContext*, const StringVal& str);
46  static StringVal Upper(FunctionContext*, const StringVal& str);
47  static StringVal InitCap(FunctionContext*, const StringVal& str);
48  static StringVal Reverse(FunctionContext*, const StringVal& str);
49  static StringVal Translate(FunctionContext*, const StringVal& str, const StringVal& src,
50  const StringVal& dst);
51  static StringVal Trim(FunctionContext*, const StringVal& str);
52  static StringVal Ltrim(FunctionContext*, const StringVal& str);
53  static StringVal Rtrim(FunctionContext*, const StringVal& str);
54  static IntVal Ascii(FunctionContext*, const StringVal& str);
55  static IntVal Instr(FunctionContext*, const StringVal& str, const StringVal& substr);
56  static IntVal Locate(FunctionContext*, const StringVal& substr, const StringVal& str);
57  static IntVal LocatePos(FunctionContext*, const StringVal& substr, const StringVal& str,
58  const BigIntVal& start_pos);
59 
60  static void RegexpPrepare(FunctionContext*, FunctionContext::FunctionStateScope);
61  static void RegexpClose(FunctionContext*, FunctionContext::FunctionStateScope);
62  static StringVal RegexpExtract(FunctionContext*, const StringVal& str,
63  const StringVal& pattern, const BigIntVal& index);
64  static StringVal RegexpReplace(FunctionContext*, const StringVal& str,
65  const StringVal& pattern, const StringVal& replace);
66 
67  static StringVal Concat(FunctionContext*, int num_children, const StringVal* strs);
68  static StringVal ConcatWs(FunctionContext*, const StringVal& sep, int num_children,
69  const StringVal* strs);
70  static IntVal FindInSet(FunctionContext*, const StringVal& str,
71  const StringVal& str_set);
72 
73  static void ParseUrlPrepare(FunctionContext*, FunctionContext::FunctionStateScope);
74  static StringVal ParseUrl(FunctionContext*, const StringVal& url, const StringVal& part);
75  static StringVal ParseUrlKey(FunctionContext*, const StringVal& url,
76  const StringVal& key, const StringVal& part);
77  static void ParseUrlClose(FunctionContext*, FunctionContext::FunctionStateScope);
78 };
79 
80 }
81 #endif
StringVal Concat(FunctionContext *context, int n, const StringVal *args)
Definition: udf-test.cc:84