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

#include <math-functions.h>

Collaboration diagram for impala::MathFunctions:

Public Member Functions

template<>
DecimalVal Negative (FunctionContext *ctx, const DecimalVal &val)
 

Static Public Member Functions

static DoubleVal Pi (FunctionContext *)
 
static DoubleVal E (FunctionContext *)
 
static BigIntVal Abs (FunctionContext *, const BigIntVal &)
 
static DoubleVal Abs (FunctionContext *, const DoubleVal &)
 
static FloatVal Abs (FunctionContext *, const FloatVal &)
 
static IntVal Abs (FunctionContext *, const IntVal &)
 
static SmallIntVal Abs (FunctionContext *, const SmallIntVal &)
 
static TinyIntVal Abs (FunctionContext *, const TinyIntVal &)
 
static DoubleVal Sin (FunctionContext *, const DoubleVal &)
 
static DoubleVal Asin (FunctionContext *, const DoubleVal &)
 
static DoubleVal Cos (FunctionContext *, const DoubleVal &)
 
static DoubleVal Acos (FunctionContext *, const DoubleVal &)
 
static DoubleVal Tan (FunctionContext *, const DoubleVal &)
 
static DoubleVal Atan (FunctionContext *, const DoubleVal &)
 
static DoubleVal Sqrt (FunctionContext *, const DoubleVal &)
 
static DoubleVal Exp (FunctionContext *, const DoubleVal &)
 
static BigIntVal Ceil (FunctionContext *, const DoubleVal &)
 
static BigIntVal Floor (FunctionContext *, const DoubleVal &)
 
static DoubleVal Ln (FunctionContext *, const DoubleVal &)
 
static DoubleVal Log10 (FunctionContext *, const DoubleVal &)
 
static FloatVal Sign (FunctionContext *, const DoubleVal &)
 
static DoubleVal Radians (FunctionContext *, const DoubleVal &)
 
static DoubleVal Degrees (FunctionContext *, const DoubleVal &)
 
static BigIntVal Round (FunctionContext *, const DoubleVal &)
 
static DoubleVal RoundUpTo (FunctionContext *, const DoubleVal &, const IntVal &)
 
static DoubleVal Log2 (FunctionContext *, const DoubleVal &)
 
static DoubleVal Log (FunctionContext *, const DoubleVal &base, const DoubleVal &val)
 
static DoubleVal Pow (FunctionContext *, const DoubleVal &base, const DoubleVal &val)
 
static void RandPrepare (FunctionContext *, FunctionContext::FunctionStateScope)
 Used for both Rand() and RandSeed() More...
 
static DoubleVal Rand (FunctionContext *)
 
static DoubleVal RandSeed (FunctionContext *, const BigIntVal &seed)
 
static StringVal Bin (FunctionContext *, const BigIntVal &)
 
static StringVal HexInt (FunctionContext *, const BigIntVal &)
 
static StringVal HexString (FunctionContext *, const StringVal &)
 
static StringVal Unhex (FunctionContext *, const StringVal &)
 
static StringVal ConvInt (FunctionContext *, const BigIntVal &n, const TinyIntVal &src_base, const TinyIntVal &dst_base)
 
static StringVal ConvString (FunctionContext *, const StringVal &s, const TinyIntVal &src_base, const TinyIntVal &dst_base)
 
static BigIntVal PmodBigInt (FunctionContext *, const BigIntVal &, const BigIntVal &)
 
static DoubleVal PmodDouble (FunctionContext *, const DoubleVal &, const DoubleVal &)
 
static FloatVal FmodFloat (FunctionContext *, const FloatVal &, const FloatVal &)
 
static DoubleVal FmodDouble (FunctionContext *, const DoubleVal &, const DoubleVal &)
 
template<typename T >
static T Positive (FunctionContext *, const T &)
 
template<typename T >
static T Negative (FunctionContext *, const T &)
 
static BigIntVal QuotientDouble (FunctionContext *, const DoubleVal &, const DoubleVal &)
 
static BigIntVal QuotientBigInt (FunctionContext *, const BigIntVal &, const BigIntVal &)
 
template<typename VAL_TYPE , bool ISLEAST>
static VAL_TYPE LeastGreatest (FunctionContext *, int num_args, const VAL_TYPE *args)
 
template<bool ISLEAST>
static StringVal LeastGreatest (FunctionContext *, int num_args, const StringVal *args)
 
template<bool ISLEAST>
static TimestampVal LeastGreatest (FunctionContext *, int num_args, const TimestampVal *args)
 
template<bool ISLEAST>
static DecimalVal LeastGreatest (FunctionContext *, int num_args, const DecimalVal *args)
 

Static Private Member Functions

static StringVal DecimalToBase (FunctionContext *, int64_t src_num, int8_t dest_base)
 Converts src_num in decimal to dest_base. More...
 
static bool DecimalInBaseToDecimal (int64_t src_num, int8_t src_base, int64_t *result)
 
static bool HandleParseResult (int8_t dest_base, int64_t *num, StringParser::ParseResult parse_res)
 

Static Private Attributes

static const int32_t MIN_BASE = 2
 
static const int32_t MAX_BASE = 36
 
static const char * ALPHANUMERIC_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 

Detailed Description

Definition at line 32 of file math-functions.h.

Member Function Documentation

static BigIntVal impala::MathFunctions::Abs ( FunctionContext ,
const BigIntVal  
)
static
static DoubleVal impala::MathFunctions::Abs ( FunctionContext ,
const DoubleVal  
)
static
static FloatVal impala::MathFunctions::Abs ( FunctionContext ,
const FloatVal  
)
static
static IntVal impala::MathFunctions::Abs ( FunctionContext ,
const IntVal  
)
static
static SmallIntVal impala::MathFunctions::Abs ( FunctionContext ,
const SmallIntVal  
)
static
static TinyIntVal impala::MathFunctions::Abs ( FunctionContext ,
const TinyIntVal  
)
static
static DoubleVal impala::MathFunctions::Acos ( FunctionContext ,
const DoubleVal  
)
static
static DoubleVal impala::MathFunctions::Asin ( FunctionContext ,
const DoubleVal  
)
static
static DoubleVal impala::MathFunctions::Atan ( FunctionContext ,
const DoubleVal  
)
static
StringVal impala::MathFunctions::Bin ( FunctionContext ctx,
const BigIntVal v 
)
static
static BigIntVal impala::MathFunctions::Ceil ( FunctionContext ,
const DoubleVal  
)
static
StringVal impala::MathFunctions::ConvString ( FunctionContext ctx,
const StringVal s,
const TinyIntVal src_base,
const TinyIntVal dst_base 
)
static
static DoubleVal impala::MathFunctions::Cos ( FunctionContext ,
const DoubleVal  
)
static
bool impala::MathFunctions::DecimalInBaseToDecimal ( int64_t  src_num,
int8_t  src_base,
int64_t *  result 
)
staticprivate

Converts src_num representing a number in src_base but encoded in decimal into its actual decimal number. For example, if src_num is 21 and src_base is 5, then this function sets *result to 2*5^1 + 1*5^0 = 11. Returns false if overflow occurred, true upon success.

Definition at line 328 of file math-functions.cc.

References impala::abs(), and UNLIKELY.

Referenced by ConvInt().

StringVal impala::MathFunctions::DecimalToBase ( FunctionContext ctx,
int64_t  src_num,
int8_t  dest_base 
)
staticprivate

Converts src_num in decimal to dest_base.

Definition at line 297 of file math-functions.cc.

References impala::abs(), ALPHANUMERIC_CHARS, and impala::AnyValUtil::FromBuffer().

Referenced by ConvInt(), and ConvString().

DoubleVal impala::MathFunctions::Degrees ( FunctionContext ctx,
const DoubleVal v 
)
static

Definition at line 82 of file math-functions.cc.

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

DoubleVal impala::MathFunctions::E ( FunctionContext ctx)
static

Definition at line 42 of file math-functions.cc.

static DoubleVal impala::MathFunctions::Exp ( FunctionContext ,
const DoubleVal  
)
static
static BigIntVal impala::MathFunctions::Floor ( FunctionContext ,
const DoubleVal  
)
static
DoubleVal impala::MathFunctions::FmodDouble ( FunctionContext ctx,
const DoubleVal a,
const DoubleVal b 
)
static

Definition at line 388 of file math-functions.cc.

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

FloatVal impala::MathFunctions::FmodFloat ( FunctionContext ctx,
const FloatVal a,
const FloatVal b 
)
static

Definition at line 382 of file math-functions.cc.

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

bool impala::MathFunctions::HandleParseResult ( int8_t  dest_base,
int64_t *  num,
StringParser::ParseResult  parse_res 
)
staticprivate

Helper function used in Conv to implement behavior consistent with MySQL and Hive in case of numeric overflow during Conv. Inspects parse_res, and in case of overflow sets num to MAXINT64 if dest_base is positive, otherwise to -1. Returns true if no parse_res == PARSE_SUCCESS || parse_res == PARSE_OVERFLOW. Returns false otherwise, indicating some other error condition.

Definition at line 353 of file math-functions.cc.

References impala::StringParser::PARSE_FAILURE, and impala::StringParser::PARSE_OVERFLOW.

Referenced by ConvInt(), and ConvString().

StringVal impala::MathFunctions::HexInt ( FunctionContext ctx,
const BigIntVal v 
)
static
StringVal impala::MathFunctions::HexString ( FunctionContext ctx,
const StringVal s 
)
static
template<typename VAL_TYPE , bool ISLEAST>
VAL_TYPE impala::MathFunctions::LeastGreatest ( FunctionContext ctx,
int  num_args,
const VAL_TYPE *  args 
)
static

Definition at line 433 of file math-functions.cc.

template<bool ISLEAST>
StringVal impala::MathFunctions::LeastGreatest ( FunctionContext ctx,
int  num_args,
const StringVal args 
)
static
template<bool ISLEAST>
TimestampVal impala::MathFunctions::LeastGreatest ( FunctionContext ctx,
int  num_args,
const TimestampVal args 
)
static
template<bool ISLEAST>
DecimalVal impala::MathFunctions::LeastGreatest ( FunctionContext ctx,
int  num_args,
const DecimalVal args 
)
static
static DoubleVal impala::MathFunctions::Ln ( FunctionContext ,
const DoubleVal  
)
static
DoubleVal impala::MathFunctions::Log ( FunctionContext ctx,
const DoubleVal base,
const DoubleVal val 
)
static

Definition at line 103 of file math-functions.cc.

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

static DoubleVal impala::MathFunctions::Log10 ( FunctionContext ,
const DoubleVal  
)
static
DoubleVal impala::MathFunctions::Log2 ( FunctionContext ctx,
const DoubleVal v 
)
static

Definition at line 98 of file math-functions.cc.

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

template<typename T >
T impala::MathFunctions::Negative ( FunctionContext ctx,
const T &  val 
)
static

Definition at line 398 of file math-functions.cc.

DoubleVal impala::MathFunctions::Pi ( FunctionContext ctx)
static

Definition at line 38 of file math-functions.cc.

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

BigIntVal impala::MathFunctions::PmodBigInt ( FunctionContext ctx,
const BigIntVal a,
const BigIntVal b 
)
static

Definition at line 370 of file math-functions.cc.

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

DoubleVal impala::MathFunctions::PmodDouble ( FunctionContext ctx,
const DoubleVal a,
const DoubleVal b 
)
static

Definition at line 376 of file math-functions.cc.

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

template<typename T >
template DecimalVal impala::MathFunctions::Positive< DecimalVal > ( FunctionContext ,
const T &   
)
static

Definition at line 394 of file math-functions.cc.

DoubleVal impala::MathFunctions::Pow ( FunctionContext ctx,
const DoubleVal base,
const DoubleVal val 
)
static

Definition at line 109 of file math-functions.cc.

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

BigIntVal impala::MathFunctions::QuotientBigInt ( FunctionContext ctx,
const BigIntVal x,
const BigIntVal y 
)
static
BigIntVal impala::MathFunctions::QuotientDouble ( FunctionContext ctx,
const DoubleVal x,
const DoubleVal y 
)
static

Definition at line 420 of file math-functions.cc.

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

DoubleVal impala::MathFunctions::Radians ( FunctionContext ctx,
const DoubleVal v 
)
static

Definition at line 77 of file math-functions.cc.

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

DoubleVal impala::MathFunctions::Rand ( FunctionContext ctx)
static

Definition at line 142 of file math-functions.cc.

References impala_udf::FunctionContext::GetFunctionState().

Referenced by RandSeed().

DoubleVal impala::MathFunctions::RandSeed ( FunctionContext ctx,
const BigIntVal seed 
)
static

Definition at line 151 of file math-functions.cc.

References impala_udf::AnyVal::is_null, and Rand().

BigIntVal impala::MathFunctions::Round ( FunctionContext ctx,
const DoubleVal v 
)
static

Definition at line 87 of file math-functions.cc.

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

DoubleVal impala::MathFunctions::RoundUpTo ( FunctionContext ctx,
const DoubleVal v,
const IntVal scale 
)
static
FloatVal impala::MathFunctions::Sign ( FunctionContext ctx,
const DoubleVal v 
)
static

Definition at line 72 of file math-functions.cc.

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

static DoubleVal impala::MathFunctions::Sin ( FunctionContext ,
const DoubleVal  
)
static
static DoubleVal impala::MathFunctions::Sqrt ( FunctionContext ,
const DoubleVal  
)
static
static DoubleVal impala::MathFunctions::Tan ( FunctionContext ,
const DoubleVal  
)
static
StringVal impala::MathFunctions::Unhex ( FunctionContext ctx,
const StringVal s 
)
static

Member Data Documentation

const char * impala::MathFunctions::ALPHANUMERIC_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
staticprivate

Definition at line 99 of file math-functions.h.

Referenced by DecimalToBase().

const int32_t impala::MathFunctions::MAX_BASE = 36
staticprivate

Definition at line 98 of file math-functions.h.

Referenced by ConvInt(), and ConvString().

const int32_t impala::MathFunctions::MIN_BASE = 2
staticprivate

Definition at line 97 of file math-functions.h.

Referenced by ConvInt(), and ConvString().


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