MCPcopy
hub / github.com/pingcap/tidb / getRowData

Function getRowData

pkg/planner/core/plan_cache_partition_table_test.go:609–663  ·  view source on GitHub ↗
(rowData map[any]string, filler string, cols []string, isCaseSensitive bool, id ...any)

Source from the content-addressed store, hash-verified

607}
608
609func getRowData(rowData map[any]string, filler string, cols []string, isCaseSensitive bool, id ...any) []string {
610 maxRange := 2000000
611 ret := make([]string, 0, len(id))
612 dup := make(map[any]struct{}, len(id))
613 for i := range id {
614 isStr := false
615 switch x := id[i].(type) {
616 case int:
617 if x >= maxRange {
618 continue
619 }
620 case string:
621 if isCaseSensitive {
622 if x >= "x" {
623 continue
624 }
625 } else {
626 lc := strings.ToLower(x)
627 if lc >= "x" {
628 continue
629 }
630 }
631 isStr = true
632 default:
633 panic("Unsupported type")
634 }
635 if _, ok := dup[id[i]]; ok {
636 continue
637 }
638 var row string
639 for j, col := range cols {
640 if j > 0 {
641 row += " "
642 }
643 switch col {
644 case "a":
645 if isStr {
646 row += id[i].(string)
647 } else {
648 row += strconv.Itoa(id[i].(int))
649 }
650 case "b":
651 row += rowData[id[i]]
652 case "c":
653 row += filler
654 case "space(1)":
655 row += " "
656 }
657 }
658 ret = append(ret, row)
659 dup[id[i]] = struct{}{}
660 }
661 sort.Strings(ret)
662 return ret
663}
664
665func getRandCols(seededRand *rand.Rand) ([]string, bool) {
666 allCols := []string{"a", "b", "c", "space(1)"}

Callers 4

preparedStmtPointGetFunction · 0.70
nonPreparedStmtPointGetFunction · 0.70

Calls 1

ToLowerMethod · 0.65

Tested by

no test coverage detected