Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE > Class Template Referenceabstract

#include <uda-test-harness.h>

Inheritance diagram for impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >:
Collaboration diagram for impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >:

Classes

struct  ScopedFunctionContext
 

Public Types

typedef void(* InitFn )(FunctionContext *context, INTERMEDIATE *result)
 
typedef void(* MergeFn )(FunctionContext *context, const INTERMEDIATE &src, INTERMEDIATE *dst)
 
typedef const INTERMEDIATE(* SerializeFn )(FunctionContext *context, const INTERMEDIATE &type)
 
typedef RESULT(* FinalizeFn )(FunctionContext *context, const INTERMEDIATE &value)
 
typedef bool(* ResultComparator )(const RESULT &x, const RESULT &y)
 

Public Member Functions

void SetResultComparator (ResultComparator fn)
 
void SetIntermediateSize (int byte_size)
 This must be called if the INTERMEDIATE is TYPE_FIXED_BUFFER. More...
 
const std::string & GetErrorMsg () const
 Returns the failure string if any. More...
 

Protected Member Functions

 UdaTestHarnessBase (InitFn init_fn, MergeFn merge_fn, SerializeFn serialize_fn, FinalizeFn finalize_fn)
 
bool Execute (const RESULT &expected, UdaExecutionMode mode)
 Runs the UDA in all the modes, validating the result is 'expected' each time. More...
 
bool CheckContext (FunctionContext *context)
 Returns false if there is an error set in the context. More...
 
bool CheckResult (const RESULT &x, const RESULT &y)
 Verifies x == y, using the custom comparator if set. More...
 
RESULT ExecuteSingleNode (ScopedFunctionContext *result_context)
 
RESULT ExecuteOneLevel (int num_nodes, ScopedFunctionContext *result_context)
 
RESULT ExecuteTwoLevel (int num1, int num2, ScopedFunctionContext *result_context)
 
virtual void Update (int idx, FunctionContext *context, INTERMEDIATE *dst)=0
 

Protected Attributes

InitFn init_fn_
 UDA functions. More...
 
MergeFn merge_fn_
 
SerializeFn serialize_fn_
 
FinalizeFn finalize_fn_
 
ResultComparator result_comparator_fn_
 Customer comparator, NULL if default == should be used. More...
 
int num_input_values_
 Set during Execute() by subclass. More...
 
int fixed_buffer_byte_size_
 Buffer len for intermediate results if the type is TYPE_FIXED_BUFFER. More...
 
std::string error_msg_
 Error message if anything went wrong during the execution. More...
 

Detailed Description

template<typename RESULT, typename INTERMEDIATE>
class impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >

Definition at line 40 of file uda-test-harness.h.

Member Typedef Documentation

template<typename RESULT , typename INTERMEDIATE >
typedef RESULT(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::FinalizeFn)(FunctionContext *context, const INTERMEDIATE &value)

Definition at line 50 of file uda-test-harness.h.

template<typename RESULT , typename INTERMEDIATE >
typedef void(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::InitFn)(FunctionContext *context, INTERMEDIATE *result)

Definition at line 42 of file uda-test-harness.h.

template<typename RESULT , typename INTERMEDIATE >
typedef void(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::MergeFn)(FunctionContext *context, const INTERMEDIATE &src, INTERMEDIATE *dst)

Definition at line 44 of file uda-test-harness.h.

template<typename RESULT , typename INTERMEDIATE >
typedef bool(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ResultComparator)(const RESULT &x, const RESULT &y)

UDA test harness allows for custom comparator to validate results. UDAs can specify a custom comparator to, for example, tolerate numerical imprecision. Returns true if x and y should be treated as equal.

Definition at line 55 of file uda-test-harness.h.

template<typename RESULT , typename INTERMEDIATE >
typedef const INTERMEDIATE(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::SerializeFn)(FunctionContext *context, const INTERMEDIATE &type)

Definition at line 47 of file uda-test-harness.h.

Constructor & Destructor Documentation

template<typename RESULT , typename INTERMEDIATE >
impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::UdaTestHarnessBase ( InitFn  init_fn,
MergeFn  merge_fn,
SerializeFn  serialize_fn,
FinalizeFn  finalize_fn 
)
inlineprotected

Definition at line 70 of file uda-test-harness.h.

Member Function Documentation

template<typename RESULT , typename INTERMEDIATE >
bool impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::CheckContext ( FunctionContext context)
protected
template<typename RESULT , typename INTERMEDIATE >
bool impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::CheckResult ( const RESULT &  x,
const RESULT &  y 
)
protected

Verifies x == y, using the custom comparator if set.

Definition at line 86 of file uda-test-harness-impl.h.

template<typename RESULT , typename INTERMEDIATE >
bool impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::Execute ( const RESULT &  expected,
UdaExecutionMode  mode 
)
protected
template<typename RESULT , typename INTERMEDIATE >
RESULT impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ExecuteOneLevel ( int  num_nodes,
ScopedFunctionContext result_context 
)
protected

Runs the UDA, simulating a single level aggregation. The values are processed on num_nodes + 1 contexts. There are num_nodes that do update and serialize. There is a final context that does merge and finalize.

Definition at line 182 of file uda-test-harness-impl.h.

References impala_udf::UdfTestHarness::CreateTestContext(), and impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ScopedFunctionContext::get().

template<typename RESULT , typename INTERMEDIATE >
RESULT impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ExecuteSingleNode ( ScopedFunctionContext result_context)
protected

Runs the UDA on a single node. The entire execution happens in 1 context. The UDA does a update on all the input values and then a finalize.

Definition at line 160 of file uda-test-harness-impl.h.

References impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ScopedFunctionContext::get().

template<typename RESULT , typename INTERMEDIATE >
RESULT impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ExecuteTwoLevel ( int  num1,
int  num2,
ScopedFunctionContext result_context 
)
protected

Runs the UDA, simulating a two level aggregation with num1 in the first level and num2 in the second. The values are processed in num1 + num2 contexts.

Definition at line 238 of file uda-test-harness-impl.h.

References impala_udf::UdfTestHarness::CreateTestContext(), and impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ScopedFunctionContext::get().

template<typename RESULT , typename INTERMEDIATE >
const std::string& impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::GetErrorMsg ( ) const
inline

Returns the failure string if any.

Definition at line 67 of file uda-test-harness.h.

References impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::error_msg_.

Referenced by TEST(), TestAvg(), TestCount(), and TestStringConcat().

template<typename RESULT , typename INTERMEDIATE >
void impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::SetIntermediateSize ( int  byte_size)
inline

This must be called if the INTERMEDIATE is TYPE_FIXED_BUFFER.

Definition at line 62 of file uda-test-harness.h.

References impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::fixed_buffer_byte_size_.

Referenced by TEST(), and TestAvg().

template<typename RESULT , typename INTERMEDIATE >
void impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::SetResultComparator ( ResultComparator  fn)
inline

Member Data Documentation

template<typename RESULT , typename INTERMEDIATE >
std::string impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::error_msg_
protected

Error message if anything went wrong during the execution.

Definition at line 137 of file uda-test-harness.h.

Referenced by impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::GetErrorMsg().

template<typename RESULT , typename INTERMEDIATE >
FinalizeFn impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::finalize_fn_
protected

Definition at line 125 of file uda-test-harness.h.

template<typename RESULT , typename INTERMEDIATE >
int impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::fixed_buffer_byte_size_
protected

Buffer len for intermediate results if the type is TYPE_FIXED_BUFFER.

Definition at line 134 of file uda-test-harness.h.

Referenced by impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::SetIntermediateSize().

template<typename RESULT , typename INTERMEDIATE >
InitFn impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::init_fn_
protected

UDA functions.

Definition at line 122 of file uda-test-harness.h.

template<typename RESULT , typename INTERMEDIATE >
MergeFn impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::merge_fn_
protected

Definition at line 123 of file uda-test-harness.h.

template<typename RESULT , typename INTERMEDIATE >
int impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::num_input_values_
protected

Set during Execute() by subclass.

Definition at line 131 of file uda-test-harness.h.

Referenced by impala_udf::UdaTestHarness< RESULT, INTERMEDIATE, INPUT >::Execute().

template<typename RESULT , typename INTERMEDIATE >
ResultComparator impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::result_comparator_fn_
protected

Customer comparator, NULL if default == should be used.

Definition at line 128 of file uda-test-harness.h.

Referenced by impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::SetResultComparator().

template<typename RESULT , typename INTERMEDIATE >
SerializeFn impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::serialize_fn_
protected

Definition at line 124 of file uda-test-harness.h.


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