24 using namespace impala_udf;
29 template<
typename T,
typename SetType>
37 return StringValue::FromStringVal(x);
42 return TimestampValue::FromTimestampVal(x);
47 if (type->
precision <= ColumnType::MAX_DECIMAL4_PRECISION) {
49 }
else if (type->
precision <= ColumnType::MAX_DECIMAL8_PRECISION) {
56 template<
typename T,
typename SetType>
57 void InPredicate::SetLookupPrepare(
70 state->
val_set.insert(GetVal<T, SetType>(state->
type, *arg));
76 template<
typename SetType>
77 void InPredicate::SetLookupClose(
85 template<
typename T,
typename SetType,
bool not_in, InPredicate::Strategy strategy>
91 if (strategy == SET_LOOKUP) {
94 DCHECK_NOTNULL(state);
95 found = SetLookup(state, val);
97 DCHECK_EQ(strategy, ITERATE);
98 found = Iterate(ctx->
GetArgType(0), val, num_args, args);
104 template<
typename T,
typename SetType>
107 DCHECK_NOTNULL(state);
108 SetType val = GetVal<T, SetType>(state->
type, v);
118 bool found_null =
false;
119 for (
int i = 0; i < num_args; ++i) {
120 if (args[i].is_null) {
122 }
else if (AnyValUtil::Equals(type, val, args[i])) {
130 #define IN_FUNCTIONS(AnyValType, SetType, type_name) \
131 BooleanVal InPredicate::InSetLookup( \
132 FunctionContext* context, const AnyValType& val, int num_args, \
133 const AnyValType* args) { \
134 return TemplatedIn<AnyValType, SetType, false, SET_LOOKUP>( \
135 context, val, num_args, args); \
138 BooleanVal InPredicate::NotInSetLookup( \
139 FunctionContext* context, const AnyValType& val, int num_args, \
140 const AnyValType* args) { \
141 return TemplatedIn<AnyValType, SetType, true, SET_LOOKUP>( \
142 context, val, num_args, args); \
145 BooleanVal InPredicate::InIterate( \
146 FunctionContext* context, const AnyValType& val, int num_args, \
147 const AnyValType* args) { \
148 return TemplatedIn<AnyValType, SetType, false, ITERATE>( \
149 context, val, num_args, args); \
152 BooleanVal InPredicate::NotInIterate( \
153 FunctionContext* context, const AnyValType& val, int num_args, \
154 const AnyValType* args) { \
155 return TemplatedIn<AnyValType, SetType, true, ITERATE>( \
156 context, val, num_args, args); \
159 void InPredicate::SetLookupPrepare_##type_name( \
160 FunctionContext* ctx, FunctionContext::FunctionStateScope scope) { \
161 SetLookupPrepare<AnyValType, SetType>(ctx, scope); \
164 void InPredicate::SetLookupClose_##type_name( \
165 FunctionContext* ctx, FunctionContext::FunctionStateScope scope) { \
166 SetLookupClose<SetType>(ctx, scope); \
181 template
BooleanVal InPredicate::Iterate<IntVal>(
int precision
Only valid if type == TYPE_DECIMAL.
const FunctionContext::TypeDesc * type
The type of the arguments.
DecimalValue< int128_t > Decimal16Value
Decimal16Value GetVal(const FunctionContext::TypeDesc *type, const DecimalVal &x)
This object has a compatible storage format with boost::ptime.
const TypeDesc * GetArgType(int arg_idx) const
void * GetFunctionState(FunctionStateScope scope) const
bool contains_null
If true, there is at least one NULL constant in the IN list.
bool IsArgConstant(int arg_idx) const
void SetFunctionState(FunctionStateScope scope, void *ptr)
#define IN_FUNCTIONS(AnyValType, SetType, type_name)
std::set< SetType > val_set
AnyVal * GetConstantArg(int arg_idx) const