Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 > Class Template Reference

#include <uda-test-harness.h>

Inheritance diagram for impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >:
Collaboration diagram for impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >:

Public Types

typedef void(* UpdateFn )(FunctionContext *context, const INPUT1 &input1, const INPUT2 &input2, const INPUT3 &input3, INTERMEDIATE *result)
 
typedef UdaTestHarnessBase
< RESULT, INTERMEDIATE > 
BaseClass
 
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

 UdaTestHarness3 (typename BaseClass::InitFn init_fn, UpdateFn update_fn, typename BaseClass::MergeFn merge_fn, typename BaseClass::SerializeFn serialize_fn, typename BaseClass::FinalizeFn finalize_fn)
 
bool Execute (const std::vector< INPUT1 > &values1, const std::vector< INPUT2 > &values2, const std::vector< INPUT3 > &values3, const RESULT &expected, UdaExecutionMode mode=ALL)
 Runs the UDA in all the modes, validating the result is 'expected' each time. More...
 
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

virtual void Update (int idx, FunctionContext *context, INTERMEDIATE *dst)
 
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)
 

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...
 

Private Attributes

UpdateFn update_fn_
 
const std::vector< INPUT1 > * input1_
 
const std::vector< INPUT2 > * input2_
 
const std::vector< INPUT3 > * input3_
 

Detailed Description

template<typename RESULT, typename INTERMEDIATE, typename INPUT1, typename INPUT2, typename INPUT3>
class impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >

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

Member Typedef Documentation

template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
typedef UdaTestHarnessBase<RESULT, INTERMEDIATE> impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::BaseClass

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

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

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)
inherited

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)
inherited

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)
inherited

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)
inherited

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

template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
typedef void(* impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::UpdateFn)(FunctionContext *context, const INPUT1 &input1, const INPUT2 &input2, const INPUT3 &input3, INTERMEDIATE *result)

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

Constructor & Destructor Documentation

template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::UdaTestHarness3 ( typename BaseClass::InitFn  init_fn,
UpdateFn  update_fn,
typename BaseClass::MergeFn  merge_fn,
typename BaseClass::SerializeFn  serialize_fn,
typename BaseClass::FinalizeFn  finalize_fn 
)
inline

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

Member Function Documentation

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

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 
)
protectedinherited
template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
bool impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::Execute ( const std::vector< INPUT1 > &  values1,
const std::vector< INPUT2 > &  values2,
const std::vector< INPUT3 > &  values3,
const RESULT &  expected,
UdaExecutionMode  mode = ALL 
)

Runs the UDA in all the modes, validating the result is 'expected' each time.

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

template<typename RESULT , typename INTERMEDIATE >
RESULT impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ExecuteOneLevel ( int  num_nodes,
ScopedFunctionContext result_context 
)
protectedinherited

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)
protectedinherited

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 
)
protectedinherited

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
inlineinherited

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)
inlineinherited

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)
inlineinherited
template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
void impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::Update ( int  idx,
FunctionContext context,
INTERMEDIATE *  dst 
)
protectedvirtual

Member Data Documentation

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

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_
protectedinherited

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_
protectedinherited

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_
protectedinherited

UDA functions.

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

template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
const std::vector<INPUT1>* impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::input1_
private

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

template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
const std::vector<INPUT2>* impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::input2_
private

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

template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
const std::vector<INPUT3>* impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::input3_
private

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

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

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

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

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_
protectedinherited

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_
protectedinherited

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

template<typename RESULT , typename INTERMEDIATE , typename INPUT1 , typename INPUT2 , typename INPUT3 >
UpdateFn impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >::update_fn_
private

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


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