Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLL support default value #1825

Merged
merged 11 commits into from
Sep 25, 2019
15 changes: 12 additions & 3 deletions be/src/olap/aggregate_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ struct AggregateFuncTraits<OLAP_FIELD_AGGREGATION_HLL_UNION, OLAP_FIELD_TYPE_HLL
dst_slice->size = sizeof(HyperLogLog);
// use 'placement new' to allocate HyperLogLog on arena, so that we can control the memory usage.
char* mem = arena->Allocate(dst_slice->size);
dst_slice->data = (char*) new (mem) HyperLogLog(src_slice->data);
if (src_slice->empty()) {
dst_slice->data = (char*) new (mem) HyperLogLog();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the slice size is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When HLL columns are NULL in the LOAD data

} else {
dst_slice->data = (char*) new (mem) HyperLogLog(src_slice->data);
}
}

static void update(RowCursorCell* dst, const RowCursorCell& src, Arena* arena) {
Expand All @@ -420,8 +424,13 @@ struct AggregateFuncTraits<OLAP_FIELD_AGGREGATION_HLL_UNION, OLAP_FIELD_TYPE_HLL

// fixme(kks): trick here, need improve
if (arena == nullptr) { // for query
HyperLogLog src_hll = HyperLogLog(src_slice->data);
dst_hll->merge(src_hll);
if (src_slice->empty()) {
HyperLogLog src_hll = HyperLogLog();
dst_hll->merge(src_hll);
} else {
HyperLogLog src_hll = HyperLogLog(src_slice->data);
dst_hll->merge(src_hll);
}
} else { // for stream load
auto* src_hll = reinterpret_cast<HyperLogLog*>(src_slice->data);
dst_hll->merge(*src_hll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private void finalizeParams(ParamCreateContext context) throws UserException, An
}

// check hll_hash
if (destSlotDesc.getType().getPrimitiveType() == PrimitiveType.HLL) {
if (destSlotDesc.getType().getPrimitiveType() == PrimitiveType.HLL && exprMap.get(destSlotDesc.getColumn().getName()) != null) {
if (!(expr instanceof FunctionCallExpr)) {
throw new AnalysisException("HLL column must use hll_hash function, like "
+ destSlotDesc.getColumn().getName() + "=hll_hash(xxx)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ private void finalizeParams() throws UserException {
}
}
}

// check hll_hash
if (dstSlotDesc.getType().getPrimitiveType() == PrimitiveType.HLL) {
if (dstSlotDesc.getType().getPrimitiveType() == PrimitiveType.HLL && exprsByName.get(dstSlotDesc.getColumn().getName()) != null) {
if (!(expr instanceof FunctionCallExpr)) {
throw new AnalysisException("HLL column must use hll_hash function, like "
+ dstSlotDesc.getColumn().getName() + "=hll_hash(xxx)");
Expand Down