@@ -42,8 +42,6 @@ type AnalyzeExec struct {
42
42
tasks []* analyzeTask
43
43
}
44
44
45
- var maxBucketSize = int64 (256 )
46
-
47
45
const (
48
46
maxSampleSize = 10000
49
47
maxRegionSampleSize = 1000
@@ -167,6 +165,7 @@ type AnalyzeIndexExec struct {
167
165
priority int
168
166
analyzePB * tipb.AnalyzeReq
169
167
result distsql.SelectResult
168
+ maxNumBuckets uint64
170
169
}
171
170
172
171
func (e * AnalyzeIndexExec ) open () error {
@@ -211,7 +210,7 @@ func (e *AnalyzeIndexExec) buildStats() (hist *statistics.Histogram, cms *statis
211
210
if err != nil {
212
211
return nil , nil , errors .Trace (err )
213
212
}
214
- hist , err = statistics .MergeHistograms (e .ctx .GetSessionVars ().StmtCtx , hist , statistics .HistogramFromProto (resp .Hist ), int (maxBucketSize ))
213
+ hist , err = statistics .MergeHistograms (e .ctx .GetSessionVars ().StmtCtx , hist , statistics .HistogramFromProto (resp .Hist ), int (e . maxNumBuckets ))
215
214
if err != nil {
216
215
return nil , nil , errors .Trace (err )
217
216
}
@@ -255,6 +254,7 @@ type AnalyzeColumnsExec struct {
255
254
keepOrder bool
256
255
analyzePB * tipb.AnalyzeReq
257
256
resultHandler * tableResultHandler
257
+ maxNumBuckets uint64
258
258
}
259
259
260
260
func (e * AnalyzeColumnsExec ) open () error {
@@ -339,7 +339,7 @@ func (e *AnalyzeColumnsExec) buildStats() (hists []*statistics.Histogram, cms []
339
339
}
340
340
sc := e .ctx .GetSessionVars ().StmtCtx
341
341
if e .pkInfo != nil {
342
- pkHist , err = statistics .MergeHistograms (sc , pkHist , statistics .HistogramFromProto (resp .PkHist ), int (maxBucketSize ))
342
+ pkHist , err = statistics .MergeHistograms (sc , pkHist , statistics .HistogramFromProto (resp .PkHist ), int (e . maxNumBuckets ))
343
343
if err != nil {
344
344
return nil , nil , errors .Trace (err )
345
345
}
@@ -365,7 +365,7 @@ func (e *AnalyzeColumnsExec) buildStats() (hists []*statistics.Histogram, cms []
365
365
return nil , nil , errors .Trace (err )
366
366
}
367
367
}
368
- hg , err := statistics .BuildColumn (e .ctx , maxBucketSize , col .ID , collectors [i ], & col .FieldType )
368
+ hg , err := statistics .BuildColumn (e .ctx , int64 ( e . maxNumBuckets ) , col .ID , collectors [i ], & col .FieldType )
369
369
if err != nil {
370
370
return nil , nil , errors .Trace (err )
371
371
}
@@ -374,13 +374,3 @@ func (e *AnalyzeColumnsExec) buildStats() (hists []*statistics.Histogram, cms []
374
374
}
375
375
return hists , cms , nil
376
376
}
377
-
378
- // SetMaxBucketSizeForTest sets the `maxBucketSize`.
379
- func SetMaxBucketSizeForTest (size int64 ) {
380
- maxBucketSize = size
381
- }
382
-
383
- // GetMaxBucketSizeForTest gets the `maxBucketSize`.
384
- func GetMaxBucketSizeForTest () int64 {
385
- return maxBucketSize
386
- }
0 commit comments