Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <uda-test-harness.h>
Public Types | |
typedef void(* | UpdateFn )(FunctionContext *context, const INPUT1 &input1, const INPUT2 &input2, 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 | |
UdaTestHarness2 (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 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_ |
Definition at line 185 of file uda-test-harness.h.
typedef UdaTestHarnessBase<RESULT, INTERMEDIATE> impala_udf::UdaTestHarness2< RESULT, INTERMEDIATE, INPUT1, INPUT2 >::BaseClass |
Definition at line 190 of file uda-test-harness.h.
|
inherited |
Definition at line 50 of file uda-test-harness.h.
|
inherited |
Definition at line 42 of file uda-test-harness.h.
|
inherited |
Definition at line 44 of file uda-test-harness.h.
|
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.
|
inherited |
Definition at line 47 of file uda-test-harness.h.
typedef void(* impala_udf::UdaTestHarness2< RESULT, INTERMEDIATE, INPUT1, INPUT2 >::UpdateFn)(FunctionContext *context, const INPUT1 &input1, const INPUT2 &input2, INTERMEDIATE *result) |
Definition at line 187 of file uda-test-harness.h.
|
inline |
Definition at line 192 of file uda-test-harness.h.
|
protectedinherited |
Returns false if there is an error set in the context.
Definition at line 75 of file uda-test-harness-impl.h.
References impala_udf::FunctionContext::error_msg(), and impala_udf::FunctionContext::has_error().
Referenced by impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::ScopedFunctionContext::~ScopedFunctionContext().
|
protectedinherited |
Verifies x == y, using the custom comparator if set.
Definition at line 86 of file uda-test-harness-impl.h.
|
protectedinherited |
Runs the UDA in all the modes, validating the result is 'expected' each time.
Definition at line 94 of file uda-test-harness-impl.h.
References impala_udf::ALL, impala_udf::UdfTestHarness::CreateTestContext(), impala_udf::DebugString(), impala_udf::ONE_LEVEL, impala_udf::SINGLE_NODE, and impala_udf::TWO_LEVEL.
Referenced by impala_udf::UdaTestHarness< RESULT, INTERMEDIATE, INPUT >::Execute().
bool impala_udf::UdaTestHarness2< RESULT, INTERMEDIATE, INPUT1, INPUT2 >::Execute | ( | const std::vector< INPUT1 > & | values1, |
const std::vector< INPUT2 > & | values2, | ||
const RESULT & | expected, | ||
UdaExecutionMode | mode = ALL |
||
) |
Runs the UDA in all the modes, validating the result is 'expected' each time.
Definition at line 349 of file uda-test-harness-impl.h.
Referenced by TEST(), and TestStringConcat().
|
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().
|
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().
|
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().
|
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().
|
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_.
|
inlineinherited |
Definition at line 57 of file uda-test-harness.h.
References impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::result_comparator_fn_.
Referenced by TEST().
|
protectedvirtual |
Implements impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >.
Definition at line 365 of file uda-test-harness-impl.h.
|
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().
|
protectedinherited |
Definition at line 125 of file uda-test-harness.h.
|
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().
|
protectedinherited |
UDA functions.
Definition at line 122 of file uda-test-harness.h.
|
private |
Definition at line 211 of file uda-test-harness.h.
|
private |
Definition at line 212 of file uda-test-harness.h.
|
protectedinherited |
Definition at line 123 of file uda-test-harness.h.
|
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().
|
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().
|
protectedinherited |
Definition at line 124 of file uda-test-harness.h.
|
private |
Definition at line 210 of file uda-test-harness.h.