Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
in-predicate.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_IN_PREDICATE_H_
17 #define IMPALA_EXPRS_IN_PREDICATE_H_
18 
19 #include <string>
20 #include "exprs/predicate.h"
21 #include "udf/udf.h"
22 
23 namespace impala {
24 
26 //
28 //
32 //
36 //
40 //
42 class InPredicate : public Predicate {
43  public:
47  int num_args, const impala_udf::BooleanVal* args);
48 
51  int num_args, const impala_udf::BooleanVal* args);
52 
55 
58 
61  int num_args, const impala_udf::BooleanVal* args);
62 
65  int num_args, const impala_udf::BooleanVal* args);
66 
69  int num_args, const impala_udf::TinyIntVal* args);
70 
73  int num_args, const impala_udf::TinyIntVal* args);
74 
77 
80 
83  int num_args, const impala_udf::TinyIntVal* args);
84 
87  int num_args, const impala_udf::TinyIntVal* args);
88 
91  int num_args, const impala_udf::SmallIntVal* args);
92 
95  int num_args, const impala_udf::SmallIntVal* args);
96 
99 
102 
105  int num_args, const impala_udf::SmallIntVal* args);
106 
109  int num_args, const impala_udf::SmallIntVal* args);
110 
112  impala_udf::FunctionContext* context, const impala_udf::IntVal& val,
113  int num_args, const impala_udf::IntVal* args);
114 
116  impala_udf::FunctionContext* context, const impala_udf::IntVal& val,
117  int num_args, const impala_udf::IntVal* args);
118 
121 
124 
126  impala_udf::FunctionContext* context, const impala_udf::IntVal& val,
127  int num_args, const impala_udf::IntVal* args);
128 
130  impala_udf::FunctionContext* context, const impala_udf::IntVal& val,
131  int num_args, const impala_udf::IntVal* args);
132 
135  int num_args, const impala_udf::BigIntVal* args);
136 
139  int num_args, const impala_udf::BigIntVal* args);
140 
143 
146 
149  int num_args, const impala_udf::BigIntVal* args);
150 
153  int num_args, const impala_udf::BigIntVal* args);
154 
157  int num_args, const impala_udf::FloatVal* args);
158 
161  int num_args, const impala_udf::FloatVal* args);
162 
165 
168 
171  int num_args, const impala_udf::FloatVal* args);
172 
175  int num_args, const impala_udf::FloatVal* args);
176 
179  int num_args, const impala_udf::DoubleVal* args);
180 
183  int num_args, const impala_udf::DoubleVal* args);
184 
187 
190 
193  int num_args, const impala_udf::DoubleVal* args);
194 
197  int num_args, const impala_udf::DoubleVal* args);
198 
201  int num_args, const impala_udf::StringVal* args);
202 
205  int num_args, const impala_udf::StringVal* args);
206 
209 
212 
215  int num_args, const impala_udf::StringVal* args);
216 
219  int num_args, const impala_udf::StringVal* args);
220 
223  int num_args, const impala_udf::TimestampVal* args);
224 
227  int num_args, const impala_udf::TimestampVal* args);
228 
231 
234 
237  int num_args, const impala_udf::TimestampVal* args);
238 
241  int num_args, const impala_udf::TimestampVal* args);
242 
245  int num_args, const impala_udf::DecimalVal* args);
246 
249  int num_args, const impala_udf::DecimalVal* args);
250 
253 
256 
259  int num_args, const impala_udf::DecimalVal* args);
260 
263  int num_args, const impala_udf::DecimalVal* args);
264 
265  private:
266  friend class InPredicateBenchmark;
267 
268  enum Strategy {
273  };
274 
275  template<typename SetType>
276  struct SetLookupState {
279 
283  std::set<SetType> val_set;
284 
287  };
288 
291  template<typename T, typename SetType, bool not_in, Strategy strategy>
292  static inline impala_udf::BooleanVal TemplatedIn(
293  impala_udf::FunctionContext* context, const T& val, int num_args, const T* args);
294 
296  template<typename T, typename SetType>
297  static void SetLookupPrepare(
299 
300  template<typename SetType>
301  static void SetLookupClose(
303 
305  template<typename T, typename SetType>
306  static BooleanVal SetLookup(SetLookupState<SetType>* state, const T& v);
307 
309  template<typename T>
310  static BooleanVal Iterate(
311  const FunctionContext::TypeDesc* type, const T& val, int num_args, const T* args);
312 };
313 
314 }
315 
316 #endif
const FunctionContext::TypeDesc * type
The type of the arguments.
Definition: in-predicate.h:286
static impala_udf::BooleanVal InIterate(impala_udf::FunctionContext *context, const impala_udf::BooleanVal &val, int num_args, const impala_udf::BooleanVal *args)
Functions for every type.
static void SetLookupClose_int(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupPrepare_timestamp(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupClose_bigint(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupPrepare_bigint(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupClose_float(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static impala_udf::BooleanVal NotInSetLookup(impala_udf::FunctionContext *context, const impala_udf::BooleanVal &val, int num_args, const impala_udf::BooleanVal *args)
static void SetLookupPrepare_boolean(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static BooleanVal Iterate(const FunctionContext::TypeDesc *type, const T &val, int num_args, const T *args)
Iterates through each vararg looking for val. 'type' is the type of 'val' and 'args'.
static void SetLookupPrepare_string(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupPrepare_tinyint(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupPrepare_int(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupClose_string(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupClose_double(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
This object has a compatible storage format with boost::ptime.
Definition: udf.h:495
Indicates we should use Iterate().
Definition: in-predicate.h:272
static BooleanVal SetLookup(SetLookupState< SetType > *state, const T &v)
Looks up v in state->val_set.
static void SetLookupClose_boolean(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupClose_smallint(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupPrepare_double(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupPrepare_decimal(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupClose(FunctionContext *ctx, FunctionContext::FunctionStateScope scope)
static void SetLookupClose_decimal(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
bool contains_null
If true, there is at least one NULL constant in the IN list.
Definition: in-predicate.h:278
static impala_udf::BooleanVal NotInIterate(impala_udf::FunctionContext *context, const impala_udf::BooleanVal &val, int num_args, const impala_udf::BooleanVal *args)
const ColumnType & type() const
Definition: expr.h:145
static void SetLookupClose_tinyint(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
static void SetLookupClose_timestamp(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
Predicate for evaluating expressions of the form "val [NOT] IN (x1, x2, x3...)".
Definition: in-predicate.h:42
static void SetLookupPrepare(FunctionContext *ctx, FunctionContext::FunctionStateScope scope)
Initializes an SetLookupState in ctx.
static impala_udf::BooleanVal InSetLookup(impala_udf::FunctionContext *context, const impala_udf::BooleanVal &val, int num_args, const impala_udf::BooleanVal *args)
static void SetLookupPrepare_smallint(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)
Indicates we should use SetLookUp().
Definition: in-predicate.h:270
static impala_udf::BooleanVal TemplatedIn(impala_udf::FunctionContext *context, const T &val, int num_args, const T *args)
static void SetLookupPrepare_float(impala_udf::FunctionContext *ctx, impala_udf::FunctionContext::FunctionStateScope scope)