16 #include <gtest/gtest.h>
25 using namespace impala;
26 using namespace impala_udf;
84 if (buffer_len < val.
len) {
89 memcpy(value, val.
ptr, val.
len);
105 if (state->
value == NULL) {
106 state->
Set(context, input);
109 int cmp = memcmp(input.
ptr, state->
value, ::min(input.
len, state->
len));
110 if (cmp < 0 || (cmp == 0 && input.
len < state->
len)) {
111 state->
Set(context, input);
118 if (state->
value == NULL)
return intermediate;
131 if (src_state->
value == NULL)
return;
138 if (state->
value == NULL)
return StringVal::null();
159 if (input == NULL)
return;
160 val->
val |= *
reinterpret_cast<const int64_t*
>(input);
168 int64_t set_bits = 0;
184 assert(val->
len == 256);
185 memset(val->
ptr, 0, 256);
190 if (input == NULL)
return;
191 for (
int i = 0; i < 256; ++i) {
201 int compressed_size = 0;
202 uint8_t* result = NULL;
203 return StringVal(result, compressed_size);
207 uint8_t* src_uncompressed = NULL;
208 for (
int i = 0; i < 256; ++i) {
209 dst->
ptr[i] ^= src_uncompressed[i];
214 int64_t set_bits = 0;
223 vector<IntVal> no_nulls;
224 no_nulls.resize(1000);
230 TEST(CountMultiArgTest, Basic) {
232 vector<IntVal> no_nulls;
233 no_nulls.resize(num);
242 EXPECT_TRUE(test3.Execute(no_nulls, no_nulls, no_nulls,
BigIntVal(3 * num)));
246 EXPECT_TRUE(test4.Execute(no_nulls, no_nulls, no_nulls, no_nulls,
BigIntVal(4 * num)));
258 vector<IntVal> no_nulls;
259 no_nulls.resize(1000);
275 vector<StringVal> values;
291 values.push_back(StringVal::null());
302 vector<BigIntVal> input;
303 for (
int i = 0; i < 10; ++i) {
313 int main(
int argc,
char** argv) {
315 ::testing::InitGoogleTest(&argc, argv);
316 return RUN_ALL_TESTS();
BigIntVal MemTest(FunctionContext *context, const BigIntVal &bytes)
void SetResultComparator(ResultComparator fn)
const BigIntVal MemTestSerialize(FunctionContext *context, const BigIntVal &total)
void XorMerge(FunctionContext *context, const BigIntVal &src, BigIntVal *dst)
BigIntVal DistinctEstimateFinalize(FunctionContext *context, const StringVal &val)
BigIntVal MemTestFinalize(FunctionContext *context, const BigIntVal &total)
void SetIntermediateSize(int byte_size)
This must be called if the INTERMEDIATE is TYPE_FIXED_BUFFER.
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.
void DistinctEstimateMerge(FunctionContext *context, const StringVal &src, StringVal *dst)
BigIntVal CountFinalize(FunctionContext *context, const BigIntVal &val)
void CountUpdate(FunctionContext *context, const IntVal &input, BigIntVal *val)
void MinInit(FunctionContext *context, BufferVal *val)
int128_t abs(const int128_t &x)
void DistinctEstimateInit(FunctionContext *context, StringVal *val)
int main(int argc, char **argv)
void MemTestInit(FunctionContext *, BigIntVal *total)
const StringSearch UrlParser::hash_search & hash
BigIntVal XorFinalize(FunctionContext *context, const BigIntVal &val)
StringVal DistinctEstimatSerialize(FunctionContext *context, const StringVal &intermediate)
StringVal MinFinalize(FunctionContext *context, const BufferVal &val)
void MemTestMerge(FunctionContext *context, const BigIntVal &src, BigIntVal *dst)
bool FuzzyCompare(const BigIntVal &r1, const BigIntVal &r2)
void InitGoogleLoggingSafe(const char *arg)
void Set(FunctionContext *context, const StringVal &val)
void Free(uint8_t *buffer)
Frees a buffer returned from Allocate() or Reallocate()
const BufferVal MinSerialize(FunctionContext *context, const BufferVal &intermediate)
void Count3Update(FunctionContext *context, const IntVal &input1, const IntVal &input2, const IntVal &input3, BigIntVal *val)
void CountInit(FunctionContext *context, BigIntVal *val)
This is an example of the COUNT aggregate function.
void MinUpdate(FunctionContext *context, const StringVal &input, BufferVal *val)
void XorUpdate(FunctionContext *context, const double *input, BigIntVal *val)
uint8_t * Allocate(int byte_size)
bool Execute(const std::vector< INPUT > &values, const RESULT &expected, UdaExecutionMode mode=ALL)
Runs the UDA in all the modes, validating the result is 'expected' each time.
void XorInit(FunctionContext *context, BigIntVal *val)
void CountMerge(FunctionContext *context, const BigIntVal &src, BigIntVal *dst)
void Count4Update(FunctionContext *context, const IntVal &input1, const IntVal &input2, const IntVal &input3, const IntVal &input4, BigIntVal *val)
void DistinctEstimatUpdate(FunctionContext *context, const int64_t *input, StringVal *val)
const std::string & GetErrorMsg() const
Returns the failure string if any.
void MemTestUpdate(FunctionContext *context, const BigIntVal &bytes, BigIntVal *total)
void Count2Update(FunctionContext *context, const IntVal &input1, const IntVal &input2, BigIntVal *val)
void MinMerge(FunctionContext *context, const BufferVal &src, BufferVal *dst)