Skip to content

Commit

Permalink
more refine
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaRise committed Feb 29, 2024
1 parent c210f5f commit 27781a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/store/copr/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (l *LocationKeyRanges) splitKeyRangesByBuckets() []*LocationKeyRanges {
return res
}

func (c *RegionCache) splitKeyRangesByLocation(loc *tikv.KeyLocation, ranges *KeyRanges, res []*LocationKeyRanges) ([]*LocationKeyRanges, bool) {
func (c *RegionCache) splitKeyRangesByLocation(loc *tikv.KeyLocation, ranges *KeyRanges, res []*LocationKeyRanges) ([]*LocationKeyRanges, *KeyRanges, bool) {
// Iterate to the first range that is not complete in the region.
var r kv.KeyRange
var i int
Expand All @@ -137,7 +137,7 @@ func (c *RegionCache) splitKeyRangesByLocation(loc *tikv.KeyLocation, ranges *Ke
// All rest ranges belong to the same region.
if i == ranges.Len() {
res = append(res, &LocationKeyRanges{Location: loc, Ranges: ranges})
return res, true
return res, ranges, true
}
if loc.Contains(r.StartKey) {
// Part of r is not in the region. We need to split it.
Expand All @@ -147,7 +147,7 @@ func (c *RegionCache) splitKeyRangesByLocation(loc *tikv.KeyLocation, ranges *Ke
EndKey: loc.EndKey,
}
res = append(res, &LocationKeyRanges{Location: loc, Ranges: taskRanges})
*ranges = *ranges.Slice(i+1, ranges.Len())
ranges = ranges.Slice(i+1, ranges.Len())
ranges.first = &kv.KeyRange{
StartKey: loc.EndKey,
EndKey: r.EndKey,
Expand All @@ -156,9 +156,9 @@ func (c *RegionCache) splitKeyRangesByLocation(loc *tikv.KeyLocation, ranges *Ke
// rs[i] is not in the region.
taskRanges := ranges.Slice(0, i)
res = append(res, &LocationKeyRanges{Location: loc, Ranges: taskRanges})
*ranges = *ranges.Slice(i, ranges.Len())
ranges = ranges.Slice(i, ranges.Len())
}
return res, false
return res, ranges, false
}

// UnspecifiedLimit means no limit.
Expand All @@ -178,7 +178,7 @@ func (c *RegionCache) SplitKeyRangesByLocationsWithBuckets(bo *Backoffer, ranges
}

isBreak := false
res, isBreak = c.splitKeyRangesByLocation(loc, ranges, res)
res, ranges, isBreak = c.splitKeyRangesByLocation(loc, ranges, res)
if isBreak {
break
}
Expand Down Expand Up @@ -225,7 +225,7 @@ func (c *RegionCache) SplitKeyRangesByLocationsWithoutBuckets(bo *Backoffer, ran
}

isBreak := false
res, isBreak = c.splitKeyRangesByLocation(loc, ranges, res)
res, ranges, isBreak = c.splitKeyRangesByLocation(loc, ranges, res)
if isBreak {
break
}
Expand Down

0 comments on commit 27781a2

Please sign in to comment.