Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/hll_default' into hll_default
Browse files Browse the repository at this point in the history
# Conflicts:
#	be/src/exprs/hll_function.cpp
  • Loading branch information
HangyuanLiu committed Sep 24, 2019
2 parents 9bf922f + 7105674 commit fe966b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
14 changes: 2 additions & 12 deletions be/src/exprs/hll_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ namespace doris {
using doris_udf::BigIntVal;
using doris_udf::StringVal;

const std::string HllFunctions::hll_empty_buffer = init_empty_hll();
std::string HllFunctions::init_empty_hll() {
const int HLL_EMPTY_SIZE = 1;
std::string buf;
std::unique_ptr<HyperLogLog> hll;
hll.reset(new HyperLogLog());
buf.resize(HLL_EMPTY_SIZE);
hll->serialize((uint8_t*)buf.c_str());
return buf;
}

void HllFunctions::init() {
}

Expand All @@ -60,7 +49,8 @@ void HllFunctions::hll_init(FunctionContext *, StringVal* dst) {
dst->ptr = (uint8_t*)new HyperLogLog();
}
StringVal HllFunctions::empty_hll(FunctionContext* ctx) {
return AnyValUtil::from_string_temp(ctx, hll_empty_buffer);
HyperLogLog hll;
return AnyValUtil::from_string_temp(ctx, hll.empty());
}

template <typename T>
Expand Down
4 changes: 0 additions & 4 deletions be/src/exprs/hll_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef DORIS_BE_SRC_QUERY_EXPRS_HLL_FUNCTION_H
#define DORIS_BE_SRC_QUERY_EXPRS_HLL_FUNCTION_H

#include <string>
#include "udf/udf.h"

namespace doris {
Expand All @@ -40,9 +39,6 @@ class HllFunctions {
static StringVal hll_serialize(FunctionContext* ctx, const StringVal& src);

static BigIntVal hll_cardinality(FunctionContext* ctx, const StringVal& src);

const static std::string hll_empty_buffer;
static std::string init_empty_hll();
};
}

Expand Down
8 changes: 8 additions & 0 deletions be/src/olap/hll.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ class HyperLogLog {

int64_t estimate_cardinality();

std::string empty() {
const int HLL_EMPTY_SIZE = 1;
std::string buf;
buf.resize(HLL_EMPTY_SIZE);
this->serialize((uint8_t*)buf.c_str());
return buf;
}

// only for debug
std::string to_string() {
switch (_type) {
Expand Down

0 comments on commit fe966b0

Please sign in to comment.