-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: introduce bernoulli sampling method #28999
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
dd2f656
to
ddbfd2c
Compare
statistics/row_sampler.go
Outdated
} | ||
|
||
// FromProto constructs the collector from the proto struct. | ||
func (s *BernoulliRowSampleCollector) FromProto(pbCollector *tipb.RowSampleCollector) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method is the same as (s *ReservoirRowSampleCollector) FromProto
, we can define it on *baseCollector
.
statistics/row_sampler.go
Outdated
} | ||
|
||
// ToProto converts the collector to proto struct. | ||
func (s *BernoulliRowSampleCollector) ToProto() *tipb.RowSampleCollector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
/run-check_dev_2 |
planner/core/physical_plan_test.go
Outdated
@@ -17,6 +17,9 @@ package core_test | |||
import ( | |||
"context" | |||
"fmt" | |||
"math" | |||
|
|||
"github.com/pingcap/tidb/parser/ast" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the order of import need to be adjusted
executor/analyze.go
Outdated
@@ -842,9 +842,9 @@ func (e *AnalyzeColumnsExec) buildSamplingStats( | |||
}() | |||
|
|||
l := len(e.analyzePB.ColReq.ColumnsInfo) + len(e.analyzePB.ColReq.ColumnGroups) | |||
rootRowCollector := statistics.NewReservoirRowSampleCollector(int(e.analyzePB.ColReq.SampleSize), l) | |||
rootRowCollector := statistics.NewRowSampleCollector(int(e.analyzePB.ColReq.SampleSize), *e.analyzePB.ColReq.SampleRate, l) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use GetSampleRate()
to keep consistent with others?
/merge |
This pull request has been accepted and is ready to merge. Commit hash: b072288
|
/merge |
This pull request has been accepted and is ready to merge. Commit hash: e0c4fcb
|
/run-check_dev_2 |
3 similar comments
/run-check_dev_2 |
/run-check_dev_2 |
/run-check_dev_2 |
/run-check_dev_2 |
@winoros: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
What problem does this PR solve?
Issue Number: #28960
Problem Summary:
Refactor the codes and introduce the Bernoulli sampling for analyze.
What is changed and how it works?
Add an interface
RowSampleCollector
. The reservoir and bernoulli will implement this interface. Also extract the common part of them to the structbaseCollector
.Check List
Tests
Documentation
Release note