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

[Feature] Refactor to support DataSketches Quantile、Theta、Frequency Sketches #53701

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d4fa445
support dataSketches include Quantile Sketches、Theta Sketch、Frequency…
chenminghua8 Oct 22, 2024
cf082a9
fix format exception.
chenminghua8 Oct 23, 2024
2540ae9
fix format exception.
chenminghua8 Oct 24, 2024
02dc2b0
fix format exception.
chenminghua8 Oct 24, 2024
358b652
fix format exception.
chenminghua8 Oct 24, 2024
60f073e
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Oct 24, 2024
01a85d0
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Nov 24, 2024
6aff6a7
fix AggStateCombinatorTest fault
chenminghua8 Nov 24, 2024
c573071
fix AggStateCombinatorTest fault
chenminghua8 Nov 25, 2024
51e8596
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Nov 25, 2024
accf967
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Nov 26, 2024
e0257e9
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Dec 2, 2024
38b153e
add tests
chenminghua8 Dec 2, 2024
19d9389
add tests
chenminghua8 Dec 4, 2024
793cc6c
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Dec 4, 2024
8d337aa
Add test cases to improve code coverage
chenminghua8 Dec 4, 2024
643e868
Add test cases to improve code coverage
chenminghua8 Dec 4, 2024
6e0516b
Add test cases to improve code coverage
chenminghua8 Dec 4, 2024
707b4f1
support dataSketches include Quantile Sketches、Theta Sketch、Frequency…
chenminghua8 Oct 22, 2024
f8276df
fix format exception.
chenminghua8 Oct 23, 2024
7bde2bc
fix format exception.
chenminghua8 Oct 24, 2024
573ee8c
fix format exception.
chenminghua8 Oct 24, 2024
fab9f3f
fix format exception.
chenminghua8 Oct 24, 2024
cd3cba0
fix AggStateCombinatorTest fault
chenminghua8 Nov 24, 2024
b00773a
fix AggStateCombinatorTest fault
chenminghua8 Nov 25, 2024
aaae8aa
add tests
chenminghua8 Dec 2, 2024
2f092b1
add tests
chenminghua8 Dec 4, 2024
e4db576
Add test cases to improve code coverage
chenminghua8 Dec 4, 2024
cc875af
Add test cases to improve code coverage
chenminghua8 Dec 4, 2024
139ac86
Add test cases to improve code coverage
chenminghua8 Dec 4, 2024
ebaca8d
Fix aggregate_test test error due to using unused AnyValUtils
chenminghua8 Dec 5, 2024
ca4e313
Fix aggregate_test test error due to using unused AnyValUtils
chenminghua8 Dec 5, 2024
260d88b
Fix aggregate_test test error due to using unused AnyValUtils
chenminghua8 Dec 5, 2024
6d2dcf2
Fix other sketch nullptr and add ds_theta_count_distinct syntax
chenminghua8 Dec 8, 2024
499533f
Fix Clang format failling
chenminghua8 Dec 8, 2024
bbe0ec7
Fix Clang format failling
chenminghua8 Dec 8, 2024
aaa6acc
Fix Clang format failling
chenminghua8 Dec 8, 2024
cd04f84
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Dec 30, 2024
026988f
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Dec 31, 2024
6495748
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Dec 31, 2024
78a11af
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Dec 31, 2024
40589e6
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Dec 31, 2024
f95f6d4
Merge branch 'support_dataSketches' of github.com:chenminghua8/starro…
chenminghua8 Dec 31, 2024
df3b57b
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Dec 31, 2024
35b7ef4
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Dec 31, 2024
8cc2d01
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Dec 31, 2024
883d8b7
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Jan 2, 2025
d32f246
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Jan 3, 2025
55cd8d5
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Jan 3, 2025
9c56a07
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Jan 5, 2025
054adb0
Merge branch 'support_dataSketches' of github.com:chenminghua8/starro…
chenminghua8 Jan 5, 2025
272ff38
Merge branch 'StarRocks:main' into support_dataSketches
chenminghua8 Jan 5, 2025
e56d402
Merge branch 'support_dataSketches' of github.com:chenminghua8/starro…
chenminghua8 Jan 5, 2025
1fe2518
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Jan 5, 2025
f2ec4b7
Refactor to support DataSketches Quantile、Theta、Frequency Sketches
chenminghua8 Jan 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
support dataSketches include Quantile Sketches、Theta Sketch、Frequency…
… Sketches.

Signed-off-by: chenminghua8 <cmptmn@126.com>
  • Loading branch information
chenminghua8 committed Oct 22, 2024
commit d4fa445e54457bcd9ca143dc083b9d14eae87f09
691 changes: 691 additions & 0 deletions be/src/exprs/agg/ds_agg.h

Large diffs are not rendered by default.

240 changes: 0 additions & 240 deletions be/src/exprs/agg/ds_hll_count_distinct.h

This file was deleted.

18 changes: 9 additions & 9 deletions be/src/exprs/agg/factory/aggregate_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "exprs/agg/count.h"
#include "exprs/agg/covariance.h"
#include "exprs/agg/distinct.h"
#include "exprs/agg/ds_hll_count_distinct.h"
#include "exprs/agg/ds_agg.h"
#include "exprs/agg/exchange_perf.h"
#include "exprs/agg/group_concat.h"
#include "exprs/agg/histogram.h"
Expand Down Expand Up @@ -188,9 +188,6 @@ class AggregateFactory {
template <LogicalType T>
static AggregateFunctionPtr MakeHllNdvAggregateFunction();

template <LogicalType T>
static AggregateFunctionPtr MakeHllSketchAggregateFunction();

template <LogicalType T>
static AggregateFunctionPtr MakeHllRawAggregateFunction();

Expand Down Expand Up @@ -259,6 +256,9 @@ class AggregateFactory {

template <LogicalType LT>
static auto MakeRetractMaxAggregateFunction();

template <LogicalType LT, SketchType ST>
static AggregateFunctionPtr MakeDataSketchesAggregateFunction();
};

// The function should be placed by alphabetical order
Expand Down Expand Up @@ -394,11 +394,6 @@ AggregateFunctionPtr AggregateFactory::MakeHllNdvAggregateFunction() {
return std::make_shared<HllNdvAggregateFunction<LT, false>>();
}

template <LogicalType LT>
AggregateFunctionPtr AggregateFactory::MakeHllSketchAggregateFunction() {
return std::make_shared<HllSketchAggregateFunction<LT>>();
}

template <LogicalType LT>
AggregateFunctionPtr AggregateFactory::MakeHllRawAggregateFunction() {
return std::make_shared<HllNdvAggregateFunction<LT, true>>();
Expand Down Expand Up @@ -442,4 +437,9 @@ auto AggregateFactory::MakeRetractMaxAggregateFunction() {
MaxElement<LT, MaxAggregateDataRetractable<LT>>>>();
}

template <LogicalType LT, SketchType ST>
AggregateFunctionPtr AggregateFactory::MakeDataSketchesAggregateFunction() {
return std::make_shared<DataSketchesAggregateFunction<LT, ST>>();
}

} // namespace starrocks
28 changes: 25 additions & 3 deletions be/src/exprs/agg/factory/aggregate_resolver_approx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ struct HLLUnionBuilder {

resolver->add_aggregate_mapping<lt, TYPE_BIGINT, HyperLogLog>(
"approx_count_distinct", false, AggregateFactory::MakeHllNdvAggregateFunction<lt>());

resolver->add_aggregate_mapping_variadic<lt, TYPE_BIGINT, HLLSketchState>(
"ds_hll_count_distinct", false, AggregateFactory::MakeHllSketchAggregateFunction<lt>());
}
}
};
Expand All @@ -57,10 +54,35 @@ struct ApproxTopKBuilder {
}
};

struct DataSketchesBuilder {
template <LogicalType lt>
void operator()(AggregateFuncResolver* resolver) {
if constexpr (lt_is_fixedlength<lt> || lt_is_string<lt>) {
resolver->add_aggregate_mapping<lt, TYPE_BIGINT, DSSketchState<lt, SketchType::HLL>>(
"ds_hll_count_distinct", false,
AggregateFactory::MakeDataSketchesAggregateFunction<lt, SketchType::HLL>());
resolver->add_aggregate_mapping<lt, TYPE_BIGINT, DSSketchState<lt, SketchType::THETA>>(
"ds_theta", false,
AggregateFactory::MakeDataSketchesAggregateFunction<lt, SketchType::THETA>());
}
if constexpr (lt_is_integer<lt> || lt_is_float<lt>) {
resolver->add_aggregate_mapping<lt, TYPE_ARRAY, DSSketchState<lt, SketchType::QUANTILE>>(
"ds_quantile", false,
AggregateFactory::MakeDataSketchesAggregateFunction<lt, SketchType::QUANTILE>());
}
if constexpr (lt_is_integer<lt> || lt_is_float<lt> || lt_is_string<lt>) {
resolver->add_aggregate_mapping<lt, TYPE_ARRAY, DSSketchState<lt, SketchType::FREQUENT>>(
"ds_frequent", false,
AggregateFactory::MakeDataSketchesAggregateFunction<lt, SketchType::FREQUENT>());
}
}
};

void AggregateFuncResolver::register_approx() {
for (auto type : aggregate_types()) {
type_dispatch_all(type, HLLUnionBuilder(), this);
type_dispatch_all(type, ApproxTopKBuilder(), this);
type_dispatch_all(type, DataSketchesBuilder(), this);
}
add_aggregate_mapping<TYPE_HLL, TYPE_HLL, HyperLogLog>("hll_union", false,
AggregateFactory::MakeHllUnionAggregateFunction());
Expand Down
2 changes: 1 addition & 1 deletion be/src/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ add_library(Types STATIC
array_type_info.cpp
bitmap_value.cpp
date_value.cpp
ds_sketch.cpp
hll.cpp
hll_sketch.cpp
logical_type.cpp
map_type_info.cpp
struct_type_info.cpp
Expand Down
5 changes: 1 addition & 4 deletions be/src/types/hll_sketch.cpp → be/src/types/ds_sketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

#include "types/hll_sketch.h"
#include "types/ds_sketch.h"

#include "common/logging.h"
#include "runtime/mem_pool.h"
Expand Down Expand Up @@ -54,9 +54,6 @@ void DataSketchesHll::merge(const DataSketchesHll& other) {
_sketch_union = std::make_unique<hll_union_type>(other.get_lg_config_k(), alloc_type(_memory_usage));
}
auto o_sketch = other.get_hll_sketch();
if (o_sketch == nullptr) {
return;
}
_sketch_union->update(*o_sketch);
this->mark_changed();
}
Expand Down
Loading
Loading