From aef66b2435ba71d5ddbc94de2bcb216311543caa Mon Sep 17 00:00:00 2001 From: Keyi Xie Date: Wed, 13 Mar 2019 10:34:19 +0800 Subject: [PATCH] statistics, store: tidy local variable (#9679) --- statistics/histogram.go | 4 ++-- store/tikv/backoff.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/statistics/histogram.go b/statistics/histogram.go index 77b29c1294..9d8263ae5c 100644 --- a/statistics/histogram.go +++ b/statistics/histogram.go @@ -894,7 +894,7 @@ type countByRangeFunc = func(*stmtctx.StatementContext, int64, []*ranger.Range) // Also, there're redundant calculation with Selectivity(). We need to reduce it too. func newHistogramBySelectivity(sc *stmtctx.StatementContext, histID int64, oldHist, newHist *Histogram, ranges []*ranger.Range, cntByRangeFunc countByRangeFunc) error { cntPerVal := int64(oldHist.AvgCountPerNotNullValue(int64(oldHist.totalRowCount()))) - var totCnt int64 = 0 + var totCnt int64 for boundIdx, ranIdx, highRangeIdx := 0, 0, 0; boundIdx < oldHist.Bounds.NumRows() && ranIdx < len(ranges); boundIdx, ranIdx = boundIdx+2, highRangeIdx { for highRangeIdx < len(ranges) && chunk.Compare(oldHist.Bounds.GetRow(boundIdx+1), 0, &ranges[highRangeIdx].HighVal[0]) >= 0 { highRangeIdx++ @@ -941,7 +941,7 @@ func (idx *Index) newIndexBySelectivity(sc *stmtctx.StatementContext, statsNode newIndexHist.Histogram = *NewHistogram(idx.ID, int64(float64(idx.NDV)*statsNode.Selectivity), 0, 0, types.NewFieldType(mysql.TypeBlob), chunk.InitialCapacity, 0) lowBucketIdx, highBucketIdx := 0, 0 - var totCnt int64 = 0 + var totCnt int64 // Bucket bound of index is encoded one, so we need to decode it if we want to calculate the fraction accurately. // TODO: enhance its calculation. diff --git a/store/tikv/backoff.go b/store/tikv/backoff.go index ca99dfa778..fc76850c3a 100644 --- a/store/tikv/backoff.go +++ b/store/tikv/backoff.go @@ -231,7 +231,7 @@ func (b *Backoffer) Backoff(typ backoffType, err error) error { b.totalSleep += f(b.ctx) b.types = append(b.types, typ) - var startTs interface{} = "" + var startTs interface{} if ts := b.ctx.Value(txnStartKey); ts != nil { startTs = ts }