-
Notifications
You must be signed in to change notification settings - Fork 31
/
row.go
53 lines (46 loc) · 1.48 KB
/
row.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Package tableio contains the routines for managing
// performance_schema.tableio_waits_by_table.
package tableio
// Row contains w from table_io_waits_summary_by_table
type Row struct {
Name string // we don't keep the retrieved columns but store the generated table name
SumTimerWait uint64
SumTimerRead uint64
SumTimerWrite uint64
SumTimerFetch uint64
SumTimerInsert uint64
SumTimerUpdate uint64
SumTimerDelete uint64
CountStar uint64
CountRead uint64
CountWrite uint64
CountFetch uint64
CountInsert uint64
CountUpdate uint64
CountDelete uint64
}
// duplicateSlice copies the full slice
func duplicateSlice(slice []Row) []Row {
return append(make([]Row, len(slice)), slice...)
}
// subtract the countable values in one row from another
func (row *Row) subtract(other Row) {
row.SumTimerWait -= other.SumTimerWait
row.SumTimerFetch -= other.SumTimerFetch
row.SumTimerInsert -= other.SumTimerInsert
row.SumTimerUpdate -= other.SumTimerUpdate
row.SumTimerDelete -= other.SumTimerDelete
row.SumTimerRead -= other.SumTimerRead
row.SumTimerWrite -= other.SumTimerWrite
row.CountStar -= other.CountStar
row.CountFetch -= other.CountFetch
row.CountInsert -= other.CountInsert
row.CountUpdate -= other.CountUpdate
row.CountDelete -= other.CountDelete
row.CountRead -= other.CountRead
row.CountWrite -= other.CountWrite
}
// HasData indicates if there is data in the row (for counting valid rows)
func (row *Row) HasData() bool {
return row != nil && row.SumTimerWait > 0
}