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

statistics: use another way to merge topn #47765

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e0e2588
statistics: use another way to merge topn
winoros Oct 18, 2023
99327a9
Merge branch 'master' into merge-topn-one-pass
winoros Oct 18, 2023
72adddd
fantastic skipping
winoros Oct 18, 2023
0086a8c
use Fix instead of Pop then Push
winoros Oct 18, 2023
abf47b8
fix topn num and enlarge the log's step
winoros Oct 19, 2023
547f9c6
save some cpu for calling NextClear
winoros Oct 19, 2023
b697bbf
change log pos and fix deadloop
winoros Oct 19, 2023
26fd8da
Merge branch 'master' into merge-topn-one-pass
winoros Oct 19, 2023
8fa85f9
Merge branch 'master' into merge-topn-one-pass
winoros Jan 26, 2024
6c01400
fix the bug of codes
winoros Feb 5, 2024
78f35ea
redo the num change to reduce the diff
winoros Feb 5, 2024
6a61462
skip two test
winoros Feb 5, 2024
fd09e6f
fix linting
winoros Feb 5, 2024
1dc2a28
remove dead codes
winoros Feb 5, 2024
06f4d41
Merge branch 'master' into merge-topn-one-pass
winoros Feb 5, 2024
6dcbcc0
Merge remote-tracking branch 'origin/master' into merge-topn-one-pass
winoros Feb 21, 2024
6f0c669
address comments
winoros Feb 21, 2024
8038ee3
use a wrapper
winoros Feb 25, 2024
b819a09
Merge branch 'master' into merge-topn-one-pass
winoros Mar 7, 2024
606519c
Merge branch 'master' into merge-topn-one-pass
winoros Mar 27, 2024
3d4997e
Merge branch 'master' into merge-topn-one-pass
winoros Jan 22, 2025
63a02bb
Merge remote-tracking branch 'origin/master' into merge-topn-one-pass
winoros Jan 22, 2025
78a3d37
Merge remote-tracking branch 'origin/master' into merge-topn-one-pass
winoros Jan 23, 2025
4efdb94
unskip tests
winoros Jan 24, 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
13 changes: 13 additions & 0 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,19 @@ def go_deps():
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/beorn7/perks/com_github_beorn7_perks-v1.0.1.zip",
],
)
go_repository(
name = "com_github_bits_and_blooms_bitset",
build_file_proto_mode = "disable_global",
importpath = "github.com/bits-and-blooms/bitset",
sha256 = "b636514bfb66e65360dee3d842714ecaccae4bc4b2a5a1de5df57c866015e3ec",
strip_prefix = "github.com/bits-and-blooms/bitset@v1.10.0",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/bits-and-blooms/bitset/com_github_bits_and_blooms_bitset-v1.10.0.zip",
"http://ats.apps.svc/gomod/github.com/bits-and-blooms/bitset/com_github_bits_and_blooms_bitset-v1.10.0.zip",
"https://cache.hawkingrei.com/gomod/github.com/bits-and-blooms/bitset/com_github_bits_and_blooms_bitset-v1.10.0.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/bits-and-blooms/bitset/com_github_bits_and_blooms_bitset-v1.10.0.zip",
],
)
go_repository(
name = "com_github_bkielbasa_cyclop",
build_file_proto_mode = "disable_global",
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/aws/aws-sdk-go v1.48.14
github.com/bazelbuild/buildtools v0.0.0-20230926111657-7d855c59baeb
github.com/bazelbuild/rules_go v0.42.1-0.20231101215950-df20c987afcb
github.com/bits-and-blooms/bitset v1.10.0
github.com/blacktear23/go-proxyprotocol v1.0.6
github.com/butuzov/mirror v1.1.0
github.com/carlmjohnson/flagext v0.21.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/blacktear23/go-proxyprotocol v1.0.6 h1:eTt6UMpEnq59NjON49b3Cay8Dm0sCs1nDliwgkyEsRM=
github.com/blacktear23/go-proxyprotocol v1.0.6/go.mod h1:FSCbgnRZrQXazBLL5snfBbrcFSMtcmUDhSRb9OfFA1o=
github.com/bmatcuk/doublestar/v2 v2.0.4 h1:6I6oUiT/sU27eE2OFcWqBhL1SwjyvQuOssxT4a1yidI=
Expand Down
17 changes: 17 additions & 0 deletions pkg/statistics/cmsketch_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,20 @@ func topNMetaToDatum(val TopNMeta,
}
return dat, err
}

// TopNMetaValToDatum transforms the value of the TopN item to the datum.
func TopNMetaValToDatum(val []byte, tp byte, isIndex bool, loc *time.Location) (d types.Datum, err error) {
if isIndex {
d.SetBytes(val)
} else {
if types.IsTypeTime(tp) {
// Handle date time values specially since they are encoded to int and we'll get int values if using DecodeOne.
_, d, err = codec.DecodeAsDateTime(val, tp, loc)
} else if types.IsTypeFloat(tp) {
_, d, err = codec.DecodeAsFloat32(val, tp)
} else {
_, d, err = codec.DecodeOne(val)
}
}
return d, err
}
2 changes: 2 additions & 0 deletions pkg/statistics/handle/globalstats/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ go_library(
"//pkg/statistics/handle/types",
"//pkg/statistics/handle/util",
"//pkg/types",
"//pkg/util/chunk",
"//pkg/util/hack",
"//pkg/util/logutil",
"//pkg/util/sqlkiller",
"@com_github_bits_and_blooms_bitset//:bitset",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_tiancaiamao_gp//:gp",
Expand Down
4 changes: 4 additions & 0 deletions pkg/statistics/handle/globalstats/global_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ func TestGlobalIndexStatistics(t *testing.T) {
}

func TestIssues24349(t *testing.T) {
t.Skip()
winoros marked this conversation as resolved.
Show resolved Hide resolved
store := testkit.CreateMockStore(t)
testKit := testkit.NewTestKit(t, store)
testKit.MustExec("use test")
Expand All @@ -932,6 +933,7 @@ func TestIssues24349(t *testing.T) {
}

func TestIssues24349WithConcurrency(t *testing.T) {
t.Skip()
store := testkit.CreateMockStore(t)
testKit := testkit.NewTestKit(t, store)
testKit.MustExec("use test")
Expand All @@ -945,6 +947,7 @@ func TestIssues24349WithConcurrency(t *testing.T) {
}

func TestGlobalStatsAndSQLBinding(t *testing.T) {
t.Skip()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
Expand All @@ -953,6 +956,7 @@ func TestGlobalStatsAndSQLBinding(t *testing.T) {
}

func TestGlobalStatsAndSQLBindingWithConcurrency(t *testing.T) {
t.Skip()
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
Expand Down
Loading