Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::UdfBuiltins Class Reference

#include <udf-builtins.h>

Collaboration diagram for impala::UdfBuiltins:

Static Public Member Functions

static DoubleVal Abs (FunctionContext *context, const DoubleVal &val)
 
static DoubleVal Pi (FunctionContext *context)
 
static StringVal Lower (FunctionContext *context, const StringVal &str)
 
static IntVal MaxInt (FunctionContext *context)
 
static TinyIntVal MaxTinyInt (FunctionContext *context)
 
static SmallIntVal MaxSmallInt (FunctionContext *context)
 
static BigIntVal MaxBigInt (FunctionContext *context)
 
static IntVal MinInt (FunctionContext *context)
 
static TinyIntVal MinTinyInt (FunctionContext *context)
 
static SmallIntVal MinSmallInt (FunctionContext *context)
 
static BigIntVal MinBigInt (FunctionContext *context)
 
static BooleanVal IsNan (FunctionContext *context, const DoubleVal &val)
 
static BooleanVal IsInf (FunctionContext *context, const DoubleVal &val)
 
static TimestampVal Trunc (FunctionContext *context, const TimestampVal &date, const StringVal &unit_str)
 
static void TruncPrepare (FunctionContext *context, FunctionContext::FunctionStateScope scope)
 
static void TruncClose (FunctionContext *context, FunctionContext::FunctionStateScope scope)
 
static IntVal Extract (FunctionContext *context, const StringVal &field_str, const TimestampVal &date)
 This is used by the DATE_PART function. More...
 
static IntVal Extract (FunctionContext *context, const TimestampVal &date, const StringVal &field_str)
 
static void ExtractPrepare (FunctionContext *context, FunctionContext::FunctionStateScope scope)
 This is used by the DATE_PART function. More...
 
static void SwappedExtractPrepare (FunctionContext *context, FunctionContext::FunctionStateScope scope)
 
static void ExtractClose (FunctionContext *context, FunctionContext::FunctionStateScope scope)
 This is used by both EXTRACT and DATE_PART. More...
 
static StringVal ToVector (FunctionContext *context, int n, const DoubleVal *values)
 
static StringVal PrintVector (FunctionContext *context, const StringVal &arr)
 Converts a double[] stored as a StringVal into a human readable string. More...
 
static DoubleVal VectorGet (FunctionContext *context, const BigIntVal &n, const StringVal &arr)
 Returns the n-th (0-indexed) element of a double[] stored as a StringVal. More...
 
static StringVal EncodeVector (FunctionContext *context, const StringVal &arr)
 
static StringVal DecodeVector (FunctionContext *context, const StringVal &arr)
 Converts a printable ascii encoding of a vector to a double[] stored as a StringVal. More...
 

Static Private Member Functions

static void ExtractPrepare (FunctionContext *context, FunctionContext::FunctionStateScope scope, int unit_idx)
 

Detailed Description

Builtins written against the UDF interface. The builtins in the other files should be replaced to the UDF interface as well. This is just to illustrate how builtins against the UDF interface will be implemented.

Definition at line 28 of file udf-builtins.h.

Member Function Documentation

DoubleVal UdfBuiltins::Abs ( FunctionContext context,
const DoubleVal val 
)
static

Definition at line 37 of file udf-builtins.cc.

References impala_udf::AnyVal::is_null, and impala_udf::DoubleVal::val.

StringVal UdfBuiltins::DecodeVector ( FunctionContext context,
const StringVal arr 
)
static

Converts a printable ascii encoding of a vector to a double[] stored as a StringVal.

Definition at line 555 of file udf-builtins.cc.

References InplaceDoubleDecode(), impala_udf::AnyVal::is_null, impala_udf::StringVal::len, and impala_udf::StringVal::ptr.

StringVal UdfBuiltins::EncodeVector ( FunctionContext context,
const StringVal arr 
)
static

Converts a double[] stored as a StringVal to an printable ascii encoding MADlib operates on binary strings but the Impala shell is not friendly to binary data. We offer these functions to the user to allow them to copy-paste vectors to/from the impala shell. Note: this loses precision (converts from double to float)

Definition at line 545 of file udf-builtins.cc.

References InplaceDoubleEncode(), impala_udf::AnyVal::is_null, impala_udf::StringVal::len, and impala_udf::StringVal::ptr.

IntVal UdfBuiltins::Extract ( FunctionContext context,
const StringVal field_str,
const TimestampVal date 
)
static
IntVal UdfBuiltins::Extract ( FunctionContext context,
const TimestampVal date,
const StringVal field_str 
)
static

This is for the EXTRACT(Timestamp, String) and EXTRACT(Timeunit FROM Timestamp) functions.

Definition at line 420 of file udf-builtins.cc.

void UdfBuiltins::ExtractClose ( FunctionContext context,
FunctionContext::FunctionStateScope  scope 
)
static
void UdfBuiltins::ExtractPrepare ( FunctionContext context,
FunctionContext::FunctionStateScope  scope 
)
static

This is used by the DATE_PART function.

Definition at line 443 of file udf-builtins.cc.

void UdfBuiltins::ExtractPrepare ( FunctionContext context,
FunctionContext::FunctionStateScope  scope,
int  unit_idx 
)
staticprivate

Does the preparation for EXTRACT. The unit_idx parameter should indicate which parameter of the EXTRACT call is the time unit param. DATE_PART will also use this with a different unit_idx than EXTRACT.

Definition at line 425 of file udf-builtins.cc.

References impala_udf::FunctionContext::Allocate(), impala_udf::FunctionContext::GetConstantArg(), impala_udf::FunctionContext::IsArgConstant(), impala_udf::StringVal::len, impala_udf::StringVal::ptr, impala_udf::FunctionContext::SetError(), impala_udf::FunctionContext::SetFunctionState(), and StrToExtractField().

BooleanVal UdfBuiltins::IsInf ( FunctionContext context,
const DoubleVal val 
)
static

Definition at line 92 of file udf-builtins.cc.

References impala_udf::AnyVal::is_null, and impala_udf::DoubleVal::val.

BooleanVal UdfBuiltins::IsNan ( FunctionContext context,
const DoubleVal val 
)
static

Definition at line 87 of file udf-builtins.cc.

References impala_udf::AnyVal::is_null, and impala_udf::DoubleVal::val.

StringVal UdfBuiltins::Lower ( FunctionContext context,
const StringVal str 
)
static
BigIntVal UdfBuiltins::MaxBigInt ( FunctionContext context)
static

Definition at line 67 of file udf-builtins.cc.

IntVal UdfBuiltins::MaxInt ( FunctionContext context)
static

Definition at line 55 of file udf-builtins.cc.

SmallIntVal UdfBuiltins::MaxSmallInt ( FunctionContext context)
static

Definition at line 63 of file udf-builtins.cc.

TinyIntVal UdfBuiltins::MaxTinyInt ( FunctionContext context)
static

Definition at line 59 of file udf-builtins.cc.

BigIntVal UdfBuiltins::MinBigInt ( FunctionContext context)
static

Definition at line 83 of file udf-builtins.cc.

IntVal UdfBuiltins::MinInt ( FunctionContext context)
static

Definition at line 71 of file udf-builtins.cc.

SmallIntVal UdfBuiltins::MinSmallInt ( FunctionContext context)
static

Definition at line 79 of file udf-builtins.cc.

TinyIntVal UdfBuiltins::MinTinyInt ( FunctionContext context)
static

Definition at line 75 of file udf-builtins.cc.

DoubleVal UdfBuiltins::Pi ( FunctionContext context)
static

Definition at line 42 of file udf-builtins.cc.

Referenced by impala::Expr::InitBuiltinsDummy().

StringVal UdfBuiltins::PrintVector ( FunctionContext context,
const StringVal arr 
)
static

Converts a double[] stored as a StringVal into a human readable string.

Definition at line 488 of file udf-builtins.cc.

References impala_udf::StringVal::len, impala_udf::StringVal::ptr, and ValidateMADlibVector().

void UdfBuiltins::SwappedExtractPrepare ( FunctionContext context,
FunctionContext::FunctionStateScope  scope 
)
static

This is for the EXTRACT(Timestamp, String) and EXTRACT(Timeunit FROM Timestamp) functions.

Definition at line 448 of file udf-builtins.cc.

StringVal UdfBuiltins::ToVector ( FunctionContext context,
int  n,
const DoubleVal values 
)
static

Converts a set of doubles to double[] stored as a StringVal Stored as a StringVal with each double value encoded in IEEE back to back The returned StringVal ptr can be casted to a double*

Definition at line 475 of file udf-builtins.cc.

References impala_udf::StringVal::ptr, impala_udf::FunctionContext::SetError(), and impala_udf::DoubleVal::val.

TimestampVal UdfBuiltins::Trunc ( FunctionContext context,
const TimestampVal date,
const StringVal unit_str 
)
static

Rounds (truncating down) a Timestamp to the specified unit. Units: CC, SCC : One greater than the first two digits of a four-digit year SYYYY, YYYY, YEAR, SYEAR, YYY, YY, Y : Current Year Q : Quarter MONTH, MON, MM, RM : Month WW : Same day of the week as the first day of the year W : Same day of the week as the first day of the month DDD, DD, J : Day DAY, DY, D : Starting day of the week HH, HH12, HH24 : Hour MI : Minute Reference: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions201.htm

Definition at line 220 of file udf-builtins.cc.

References impala::TimestampValue::date(), TruncUnit::DAY, TruncUnit::DAY_OF_WEEK, impala::TimestampValue::FromTimestampVal(), impala_udf::FunctionContext::GetFunctionState(), TruncUnit::HOUR, impala_udf::AnyVal::is_null, impala_udf::StringVal::len, TruncUnit::MINUTE, TruncUnit::MONTH, impala_udf::StringVal::ptr, TruncUnit::QUARTER, impala_udf::FunctionContext::SetError(), StrToTruncUnit(), impala::TimestampValue::time(), impala::TimestampValue::ToTimestampVal(), TruncDay(), TruncDayOfWeek(), TruncHour(), TruncMinute(), TruncMonth(), TruncQuarter(), TruncW(), TruncWW(), TruncYear(), TruncUnit::UNIT_INVALID, TruncUnit::W, TruncUnit::WW, and TruncUnit::YEAR.

DoubleVal UdfBuiltins::VectorGet ( FunctionContext context,
const BigIntVal n,
const StringVal arr 
)
static

Returns the n-th (0-indexed) element of a double[] stored as a StringVal.

Definition at line 505 of file udf-builtins.cc.

References impala_udf::AnyVal::is_null, impala_udf::StringVal::len, impala_udf::StringVal::ptr, impala_udf::BigIntVal::val, and ValidateMADlibVector().


The documentation for this class was generated from the following files: