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

Function GetSplitKeys

br/pkg/utils/db.go:63–92  ·  view source on GitHub ↗
(ctx sqlexec.RestrictedSQLExecutor)

Source from the content-addressed store, hash-verified

61}
62
63func GetSplitKeys(ctx sqlexec.RestrictedSQLExecutor) int64 {
64 const defaultSplitKeys = 960000
65 varStr := "show config where name = 'coprocessor.region-split-keys' and type = 'tikv'"
66 rows, fields, err := ctx.ExecRestrictedSQL(
67 kv.WithInternalSourceType(context.Background(), kv.InternalTxnBR),
68 nil,
69 varStr,
70 )
71 if err != nil {
72 log.Warn("failed to get split keys, use default value", logutil.ShortError(err))
73 return defaultSplitKeys
74 }
75 if len(rows) == 0 {
76 // use the default value
77 return defaultSplitKeys
78 }
79
80 d := rows[0].GetDatum(3, &fields[3].Column.FieldType)
81 splitKeysStr, err := d.ToString()
82 if err != nil {
83 log.Warn("failed to get split keys, use default value", logutil.ShortError(err))
84 return defaultSplitKeys
85 }
86 splitKeys, err := strconv.ParseInt(splitKeysStr, 10, 64)
87 if err != nil {
88 log.Warn("failed to get split keys, use default value", logutil.ShortError(err))
89 return defaultSplitKeys
90 }
91 return splitKeys
92}
93
94func GetGcRatio(ctx sqlexec.RestrictedSQLExecutor) (string, error) {
95 valStr := "show config where name = 'gc.ratio-threshold' and type = 'tikv'"

Callers 2

TestRegionSplitInfoFunction · 0.92
GetRegionSplitInfoFunction · 0.85

Calls 5

ShortErrorFunction · 0.92
WarnMethod · 0.80
GetDatumMethod · 0.80
ExecRestrictedSQLMethod · 0.65
ToStringMethod · 0.65

Tested by 1

TestRegionSplitInfoFunction · 0.74