[Vectorized][Function] add orthogonal bitmap agg functions (#10126)

* [Vectorized][Function] add orthogonal bitmap agg functions
save some file about orthogonal bitmap function
add some file to rebase
update functions file

* refactor union_count function
refactor orthogonal union count functions

* remove bool is_variadic
This commit is contained in:
zhangstar333
2022-06-17 08:48:41 +08:00
committed by GitHub
parent a62a485faf
commit 44e979e43b
15 changed files with 772 additions and 240 deletions

View File

@ -559,20 +559,23 @@ public class FunctionCallExpr extends Expr {
throw new AnalysisException("BITMAP_UNION_INT params only support TINYINT or SMALLINT or INT");
}
if (fnName.getFunction().equalsIgnoreCase(FunctionSet.INTERSECT_COUNT)) {
if (fnName.getFunction().equalsIgnoreCase(FunctionSet.INTERSECT_COUNT) || fnName.getFunction()
.equalsIgnoreCase(FunctionSet.ORTHOGONAL_BITMAP_INTERSECT) || fnName.getFunction()
.equalsIgnoreCase(FunctionSet.ORTHOGONAL_BITMAP_INTERSECT_COUNT)) {
if (children.size() <= 2) {
throw new AnalysisException("intersect_count(bitmap_column, column_to_filter, filter_values) "
throw new AnalysisException(fnName + "(bitmap_column, column_to_filter, filter_values) "
+ "function requires at least three parameters");
}
Type inputType = getChild(0).getType();
if (!inputType.isBitmapType()) {
throw new AnalysisException("intersect_count function first argument should be of BITMAP type, but was " + inputType);
throw new AnalysisException(
fnName + "function first argument should be of BITMAP type, but was " + inputType);
}
for (int i = 2; i < children.size(); i++) {
if (!getChild(i).isConstant()) {
throw new AnalysisException("intersect_count function filter_values arg must be constant");
throw new AnalysisException(fnName + " function filter_values arg must be constant");
}
}
return;

View File

@ -46,8 +46,11 @@ public class AggregateFunction extends Function {
private static final Logger LOG = LogManager.getLogger(AggregateFunction.class);
public static ImmutableSet<String> NOT_NULLABLE_AGGREGATE_FUNCTION_NAME_SET =
ImmutableSet.of("row_number", "rank", "dense_rank", "multi_distinct_count", "multi_distinct_sum", "hll_union_agg", "hll_union", "bitmap_union", "bitmap_intersect", FunctionSet.COUNT, "approx_count_distinct", "ndv", FunctionSet.BITMAP_UNION_INT, FunctionSet.BITMAP_UNION_COUNT, "ndv_no_finalize", FunctionSet.WINDOW_FUNNEL);
public static ImmutableSet<String> NOT_NULLABLE_AGGREGATE_FUNCTION_NAME_SET = ImmutableSet.of("row_number", "rank",
"dense_rank", "multi_distinct_count", "multi_distinct_sum", "hll_union_agg", "hll_union", "bitmap_union",
"bitmap_intersect", "orthogonal_bitmap_intersect", "orthogonal_bitmap_intersect_count", "intersect_count",
"orthogonal_bitmap_union_count", FunctionSet.COUNT, "approx_count_distinct", "ndv",
FunctionSet.BITMAP_UNION_INT, FunctionSet.BITMAP_UNION_COUNT, "ndv_no_finalize", FunctionSet.WINDOW_FUNNEL);
public static ImmutableSet<String> ALWAYS_NULLABLE_AGGREGATE_FUNCTION_NAME_SET =
ImmutableSet.of("stddev_samp", "variance_samp", "var_samp", "percentile_approx");

View File

@ -1684,6 +1684,14 @@ public class FunctionSet<T> {
BITMAP_INTERSECT_FINALIZE_SYMBOL.get(t),
true, false, true));
// VEC_INTERSECT_COUNT
addBuiltin(
AggregateFunction.createBuiltin(INTERSECT_COUNT, Lists.newArrayList(Type.BITMAP, t, t), Type.BIGINT,
Type.VARCHAR, true, BITMAP_INTERSECT_INIT_SYMBOL.get(t),
BITMAP_INTERSECT_UPDATE_SYMBOL.get(t), BITMAP_INTERSECT_MERGE_SYMBOL.get(t),
BITMAP_INTERSECT_SERIALIZE_SYMBOL.get(t), null, null,
BITMAP_INTERSECT_FINALIZE_SYMBOL.get(t), true, false, true, true));
// HLL_UNION_AGG
addBuiltin(AggregateFunction.createBuiltin("hll_union_agg",
Lists.newArrayList(t), Type.BIGINT, Type.VARCHAR,
@ -2042,6 +2050,15 @@ public class FunctionSet<T> {
"",
"_ZN5doris15BitmapFunctions32orthogonal_bitmap_count_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
true, false, true));
//vec ORTHOGONAL_BITMAP_INTERSECT and ORTHOGONAL_BITMAP_INTERSECT_COUNT
addBuiltin(
AggregateFunction.createBuiltin(ORTHOGONAL_BITMAP_INTERSECT, Lists.newArrayList(Type.BITMAP, t, t),
Type.BITMAP, Type.BITMAP, true, "", "", "", "", "", "", "", true, false, true, true));
addBuiltin(AggregateFunction.createBuiltin(ORTHOGONAL_BITMAP_INTERSECT_COUNT,
Lists.newArrayList(Type.BITMAP, t, t), Type.BIGINT, Type.BITMAP, true, "", "", "", "", "", "", "",
true, false, true, true));
}
// bitmap
addBuiltin(AggregateFunction.createBuiltin(BITMAP_UNION, Lists.newArrayList(Type.BITMAP),
@ -2100,6 +2117,10 @@ public class FunctionSet<T> {
null,
"_ZN5doris15BitmapFunctions32orthogonal_bitmap_count_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
true, true, true));
// ORTHOGONAL_BITMAP_UNION_COUNT vectorized
addBuiltin(AggregateFunction.createBuiltin(ORTHOGONAL_BITMAP_UNION_COUNT, Lists.newArrayList(Type.BITMAP),
Type.BIGINT, Type.BITMAP, "", "", "", "", null, null, "", true, true, true, true));
// TODO(ml): supply function symbol
addBuiltin(AggregateFunction.createBuiltin(BITMAP_INTERSECT, Lists.newArrayList(Type.BITMAP),
Type.BITMAP, Type.VARCHAR,