Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
decimal-operators.cc File Reference
#include "exprs/decimal-operators.h"
#include <iomanip>
#include <sstream>
#include <math.h>
#include "exprs/anyval-util.h"
#include "exprs/case-expr.h"
#include "exprs/expr.h"
#include "runtime/tuple-row.h"
#include "util/decimal-util.h"
#include "util/string-parser.h"
#include "common/names.h"
Include dependency graph for decimal-operators.cc:

Go to the source code of this file.

Namespaces

 impala
 This file contains type definitions that are used throughout the code base.
 

Macros

#define RETURN_IF_OVERFLOW(context, overflow)
 
#define CAST_INT_TO_DECIMAL(from_type)
 
#define CAST_FLOAT_TO_DECIMAL(from_type)
 
#define CAST_DECIMAL_TO_INT(to_type)
 
#define CAST_DECIMAL_TO_FLOAT(to_type)
 
#define DECIMAL_ARITHMETIC_OP(FN_NAME, OP_FN)
 
#define DECIMAL_ARITHMETIC_OP_CHECK_NAN(FN_NAME, OP_FN)
 
#define DECIMAL_BINARY_OP(FN_NAME, OP_FN)
 

Functions

static Decimal4Value impala::GetDecimal4Value (const DecimalVal &val, const ColumnType &type, bool *overflow)
 
static Decimal8Value impala::GetDecimal8Value (const DecimalVal &val, const ColumnType &type, bool *overflow)
 
static Decimal16Value impala::GetDecimal16Value (const DecimalVal &val, const ColumnType &type, bool *overflow)
 

Macro Definition Documentation

#define CAST_DECIMAL_TO_FLOAT (   to_type)
Value:
to_type DecimalOperators::CastTo##to_type( \
FunctionContext* context, const DecimalVal& val) { \
if (val.is_null) return to_type::null(); \
ColumnType type = AnyValUtil::TypeDescToColumnType(*context->GetArgType(0)); \
switch (type.GetByteSize()) { \
case 4: { \
Decimal4Value dv(val.val4); \
return to_type(dv.ToDouble(type)); \
} \
case 8: { \
Decimal8Value dv(val.val8); \
return to_type(dv.ToDouble(type)); \
} \
case 16: { \
return to_type(dv.ToDouble(type)); \
} \
default:\
DCHECK(false); \
return to_type::null(); \
} \
}
__int128_t val16
Definition: udf.h:572
DecimalValue< int128_t > Decimal16Value
bool is_null
Definition: udf.h:359
DecimalValue< int64_t > Decimal8Value
DecimalValue< int32_t > Decimal4Value

Definition at line 268 of file decimal-operators.cc.

#define CAST_DECIMAL_TO_INT (   to_type)
Value:
to_type DecimalOperators::CastTo##to_type( \
FunctionContext* context, const DecimalVal& val) { \
if (val.is_null) return to_type::null(); \
ColumnType type = AnyValUtil::TypeDescToColumnType(*context->GetArgType(0)); \
switch (type.GetByteSize()) { \
case 4: { \
Decimal4Value dv(val.val4); \
return to_type(dv.whole_part(type)); \
} \
case 8: { \
Decimal8Value dv(val.val8); \
return to_type(dv.whole_part(type)); \
} \
case 16: { \
return to_type(dv.whole_part(type)); \
} \
default:\
DCHECK(false); \
return to_type::null(); \
} \
}
__int128_t val16
Definition: udf.h:572
DecimalValue< int128_t > Decimal16Value
bool is_null
Definition: udf.h:359
DecimalValue< int64_t > Decimal8Value
DecimalValue< int32_t > Decimal4Value

Definition at line 244 of file decimal-operators.cc.

#define CAST_FLOAT_TO_DECIMAL (   from_type)
Value:
DecimalVal DecimalOperators::CastToDecimalVal( \
FunctionContext* context, const from_type& val) { \
if (val.is_null) return DecimalVal::null(); \
ColumnType type = AnyValUtil::TypeDescToColumnType(context->GetReturnType()); \
return FloatToDecimalVal(context, type, val.val); \
}

Definition at line 236 of file decimal-operators.cc.

#define CAST_INT_TO_DECIMAL (   from_type)
Value:
DecimalVal DecimalOperators::CastToDecimalVal( \
FunctionContext* context, const from_type& val) { \
if (val.is_null) return DecimalVal::null(); \
ColumnType type = AnyValUtil::TypeDescToColumnType(context->GetReturnType()); \
return IntToDecimalVal(context, type, val.val); \
}

Definition at line 228 of file decimal-operators.cc.

#define DECIMAL_ARITHMETIC_OP (   FN_NAME,
  OP_FN 
)

Definition at line 552 of file decimal-operators.cc.

#define DECIMAL_ARITHMETIC_OP_CHECK_NAN (   FN_NAME,
  OP_FN 
)

Definition at line 591 of file decimal-operators.cc.

#define DECIMAL_BINARY_OP (   FN_NAME,
  OP_FN 
)

Definition at line 634 of file decimal-operators.cc.

#define RETURN_IF_OVERFLOW (   context,
  overflow 
)
Value:
do {\
if (UNLIKELY(overflow)) {\
context->AddWarning("Expression overflowed, returning NULL");\
return DecimalVal::null();\
}\
} while (false)
#define UNLIKELY(expr)
Definition: compiler-util.h:33

Definition at line 32 of file decimal-operators.cc.

Referenced by impala::DecimalOperators::FloatToDecimalVal(), impala::DecimalOperators::IntToDecimalVal(), and impala::DecimalOperators::ScaleDecimalValue().