Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
uda-sample.cc File Reference
#include "uda-sample.h"
#include <assert.h>
Include dependency graph for uda-sample.cc:

Go to the source code of this file.

Classes

struct  AvgStruct
 

Functions

void CountInit (FunctionContext *context, BigIntVal *val)
 This is an example of the COUNT aggregate function. More...
 
void CountUpdate (FunctionContext *context, const IntVal &input, BigIntVal *val)
 
void CountMerge (FunctionContext *context, const BigIntVal &src, BigIntVal *dst)
 
BigIntVal CountFinalize (FunctionContext *context, const BigIntVal &val)
 
void AvgInit (FunctionContext *context, BufferVal *val)
 
void AvgUpdate (FunctionContext *context, const DoubleVal &input, BufferVal *val)
 
void AvgMerge (FunctionContext *context, const BufferVal &src, BufferVal *dst)
 
DoubleVal AvgFinalize (FunctionContext *context, const BufferVal &val)
 
void StringConcatInit (FunctionContext *context, StringVal *val)
 
void StringConcatUpdate (FunctionContext *context, const StringVal &arg1, const StringVal &arg2, StringVal *val)
 
void StringConcatMerge (FunctionContext *context, const StringVal &src, StringVal *dst)
 
StringVal StringConcatFinalize (FunctionContext *context, const StringVal &val)
 
void SumSmallDecimalInit (FunctionContext *, DecimalVal *val)
 
void SumSmallDecimalUpdate (FunctionContext *ctx, const DecimalVal &src, DecimalVal *dst)
 
void SumSmallDecimalMerge (FunctionContext *, const DecimalVal &src, DecimalVal *dst)
 

Function Documentation

DoubleVal AvgFinalize ( FunctionContext context,
const BufferVal val 
)

Definition at line 69 of file uda-sample.cc.

References AvgStruct::count, impala_udf::DoubleVal::null(), and AvgStruct::sum.

Referenced by TestAvg().

void AvgInit ( FunctionContext context,
BufferVal val 
)

This is an example of the AVG(double) aggregate function. This function needs to maintain two pieces of state, the current sum and the count. We do this using the BufferVal intermediate type. When this UDA is registered, it would specify 16 bytes (8 byte sum + 8 byte count) as the size for this buffer.

Definition at line 49 of file uda-sample.cc.

Referenced by TestAvg().

void AvgMerge ( FunctionContext context,
const BufferVal src,
BufferVal dst 
)

Definition at line 61 of file uda-sample.cc.

References AvgStruct::count, and AvgStruct::sum.

Referenced by TestAvg().

void AvgUpdate ( FunctionContext context,
const DoubleVal input,
BufferVal val 
)
BigIntVal CountFinalize ( FunctionContext context,
const BigIntVal val 
)

Definition at line 37 of file uda-sample.cc.

void CountInit ( FunctionContext context,
BigIntVal val 
)

This is an example of the COUNT aggregate function.

Definition at line 23 of file uda-sample.cc.

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

void CountMerge ( FunctionContext context,
const BigIntVal src,
BigIntVal dst 
)

Definition at line 33 of file uda-sample.cc.

References impala_udf::BigIntVal::val.

void CountUpdate ( FunctionContext context,
const IntVal input,
BigIntVal val 
)

Definition at line 28 of file uda-sample.cc.

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

StringVal StringConcatFinalize ( FunctionContext context,
const StringVal val 
)

Definition at line 104 of file uda-sample.cc.

Referenced by TestStringConcat().

void StringConcatInit ( FunctionContext context,
StringVal val 
)

This is a sample of implementing the STRING_CONCAT aggregate function. Example: select string_concat(string_col, ",") from table

Definition at line 79 of file uda-sample.cc.

References impala_udf::AnyVal::is_null.

Referenced by TestStringConcat().

void StringConcatMerge ( FunctionContext context,
const StringVal src,
StringVal dst 
)

Definition at line 99 of file uda-sample.cc.

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

Referenced by TestStringConcat().

void StringConcatUpdate ( FunctionContext context,
const StringVal arg1,
const StringVal arg2,
StringVal val 
)
void SumSmallDecimalInit ( FunctionContext ,
DecimalVal val 
)

Definition at line 114 of file uda-sample.cc.

References impala_udf::AnyVal::is_null, and impala_udf::DecimalVal::val4.

void SumSmallDecimalMerge ( FunctionContext ,
const DecimalVal src,
DecimalVal dst 
)

Definition at line 128 of file uda-sample.cc.

References impala_udf::AnyVal::is_null, and impala_udf::DecimalVal::val4.