code: func (h *rpcHandler) extractKVRanges(keyRanges []*coprocessor.KeyRange, descScan bool) (kvRanges []kv.KeyRange, err error) {
  	for _, kran := range keyRanges {
  		if bytes.Compare(kran.GetStart(), kran.GetEnd()) >= 0 {
  			err = errors.Errorf("invalid range, start should be smaller than end: %v %v", kran.GetStart(), kran.GetEnd())
  			return
  		}
  
  		upperKey := kran.GetEnd()
  		if bytes.Compare(upperKey, h.rawStartKey) <= 0 {
  			continue
  		}
  		lowerKey := kran.GetStart()
  		if len(h.rawEndKey) != 0 && bytes.Compare(lowerKey, h.rawEndKey) >= 0 {
  			break
  		}
  		var kvr kv.KeyRange
  		kvr.StartKey = kv.Key(maxStartKey(lowerKey, h.rawStartKey))
  		kvr.EndKey = kv.Key(minEndKey(upperKey, h.rawEndKey))
  		kvRanges = append(kvRanges, kvr)
  	}
  	if descScan {
  		reverseKVRanges(kvRanges)
  	}
  	return
  }
docs: // extractKVRanges extracts kv.KeyRanges slice from a SelectRequest.