Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <uda-test-harness.h>
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... | |
Definition at line 40 of file uda-test-harness.h.
typedef RESULT(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::FinalizeFn)(FunctionContext *context, const INTERMEDIATE &value) |
Definition at line 50 of file uda-test-harness.h.
typedef void(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::InitFn)(FunctionContext *context, INTERMEDIATE *result) |
Definition at line 42 of file uda-test-harness.h.
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.
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.
typedef const INTERMEDIATE(* impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::SerializeFn)(FunctionContext *context, const INTERMEDIATE &type) |
Definition at line 47 of file uda-test-harness.h.
|
inlineprotected |
Definition at line 70 of file uda-test-harness.h.
|
protected |
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().
|
protected |
Verifies x == y, using the custom comparator if set.
Definition at line 86 of file uda-test-harness-impl.h.
|
protected |
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().
|
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().
|
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().
|
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().
|
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().
|
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_.
|
inline |
Definition at line 57 of file uda-test-harness.h.
References impala_udf::UdaTestHarnessBase< RESULT, INTERMEDIATE >::result_comparator_fn_.
Referenced by TEST().
|
protectedpure virtual |
Implemented in impala_udf::UdaTestHarness4< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3, INPUT4 >, impala_udf::UdaTestHarness3< RESULT, INTERMEDIATE, INPUT1, INPUT2, INPUT3 >, impala_udf::UdaTestHarness2< RESULT, INTERMEDIATE, INPUT1, INPUT2 >, and impala_udf::UdaTestHarness< RESULT, INTERMEDIATE, INPUT >.
|
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().
|
protected |
Definition at line 125 of file uda-test-harness.h.
|
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().
|
protected |
UDA functions.
Definition at line 122 of file uda-test-harness.h.
|
protected |
Definition at line 123 of file uda-test-harness.h.
|
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().
|
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().
|
protected |
Definition at line 124 of file uda-test-harness.h.