code: func convertRangeFromExpectedCnt(ranges []*ranger.Range, rangeCounts []float64, expectedCnt float64, desc bool) ([]*ranger.Range, float64, bool) {
  	var i int
  	var count float64
  	var convertedRanges []*ranger.Range
  	if desc {
  		for i = len(ranges) - 1; i >= 0; i-- {
  			if count+rangeCounts[i] >= expectedCnt {
  				break
  			}
  			count += rangeCounts[i]
  		}
  		if i < 0 {
  			return nil, 0, true
  		}
  		convertedRanges = []*ranger.Range{{LowVal: ranges[i].HighVal, HighVal: []types.Datum{types.MaxValueDatum()}, LowExclude: !ranges[i].HighExclude}}
  	} else {
  		for i = 0; i < len(ranges); i++ {
  			if count+rangeCounts[i] >= expectedCnt {
  				break
  			}
  			count += rangeCounts[i]
  		}
  		if i == len(ranges) {
  			return nil, 0, true
  		}
  		convertedRanges = []*ranger.Range{{LowVal: []types.Datum{{}}, HighVal: ranges[i].LowVal, HighExclude: !ranges[i].LowExclude}}
  	}
  	return convertedRanges, count, false
  }
docs: // convertRangeFromExpectedCnt builds new ranges used to estimate row count we need to scan in table scan before finding specified
  // number of tuples which fall into input ranges.