Skip to content

Commit

Permalink
chore: make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
shhdgit committed May 19, 2022
1 parent 52d47d4 commit e99a6e6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pkg/keyvisual/decorator/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,31 @@ func (inOrder *TableInOrder) BuildFromTableMap(m *sync.Map) {

// FindOne will find first table detail which id is between [fromId, toId).
// Returns nil if not found any
func (inOrder *TableInOrder) FindOne(fromId, toId int64) *tableDetail {
if fromId >= toId {
func (inOrder *TableInOrder) FindOne(fromID, toID int64) *tableDetail {
if fromID >= toID {
return nil
}

inOrder.rwMu.RLock()
defer inOrder.rwMu.RUnlock()

tLen := len(inOrder.tables)
var pivot int = tLen / 2
pivot := tLen / 2
left := 0
right := tLen
for pivot > left {
prevId := inOrder.tables[pivot-1].ID
prevID := inOrder.tables[pivot-1].ID
id := inOrder.tables[pivot].ID
// find approaching id near the fromId
// table_1 ------- table_3 ------- table_5
// ^
// search table_2
// approaching result: table_3
if prevId < fromId && id >= fromId {
if prevID < fromID && id >= fromID {
break
}

if id < fromId {
if id < fromID {
left = pivot
} else {
right = pivot
Expand All @@ -115,7 +115,7 @@ func (inOrder *TableInOrder) FindOne(fromId, toId int64) *tableDetail {
}

id := inOrder.tables[pivot].ID
if id < fromId || id >= toId {
if id < fromID || id >= toID {
return nil
}

Expand Down Expand Up @@ -228,9 +228,8 @@ func (e *tidbLabeler) label(startKey, endKey string) (label LabelKey) {
label.Labels = append(label.Labels, detail.DB, detail.Name)
// can't find the row/index info if the table info was came from a range
return
} else {
label.Labels = append(label.Labels, fmt.Sprintf("table_%d", startTableID))
}
label.Labels = append(label.Labels, fmt.Sprintf("table_%d", startTableID))
}

if isCommonHandle, rowID := startKeyInfo.RowInfo(); isCommonHandle {
Expand Down

0 comments on commit e99a6e6

Please sign in to comment.