Initial import of pstop v0.0.10
[pstop.git] / performance_schema / replication_workload / replication_workload.go
1 package replication_workload
2
3 import (
4         "database/sql"
5
6         // "github.com/sjmudd/pstop/lib"
7         ps "github.com/sjmudd/pstop/performance_schema"
8 )
9
10 // a table of rows
11 type Replication_workload struct {
12         ps.RelativeStats
13         ps.InitialTime
14         initial replication_workload_rows
15         current replication_workload_rows
16         results replication_workload_rows
17         totals  replication_workload_row
18 }
19
20 // reset the statistics to current values
21 func (t *Replication_workload) UpdateInitialValues() {
22         t.SetNow()
23         t.initial = make(replication_workload_rows, len(t.current))
24         copy(t.initial, t.current)
25
26         t.results = make(replication_workload_rows, len(t.current))
27         copy(t.results, t.current)
28
29         if t.WantRelativeStats() {
30                 t.results.subtract(t.initial) // should be 0 if relative
31         }
32
33         t.results.sort()
34         t.totals = t.results.totals()
35 }
36
37 // Collect data from the db, then merge it in.
38 func (t *Replication_workload) Collect(dbh *sql.DB) {
39 }
40
41
42
43
44
45
46
47 // return the headings for a table
48 func (t Replication_workload) Headings() string {
49         var r replication_workload_row
50
51         return r.headings()
52 }
53
54 // return the rows we need for displaying
55 func (t Replication_workload) RowContent(max_rows int) []string {
56         rows := make([]string, 0, max_rows)
57
58         for i := range t.results {
59                 if i < max_rows {
60                         rows = append(rows, t.results[i].row_content(t.totals))
61                 }
62         }
63
64         return rows
65 }
66
67 // return all the totals
68 func (t Replication_workload) TotalRowContent() string {
69         return t.totals.row_content(t.totals)
70 }
71
72 // return an empty string of data (for filling in)
73 func (t Replication_workload) EmptyRowContent() string {
74         var emtpy replication_workload_row
75         return emtpy.row_content(emtpy)
76 }
77
78 func (t Replication_workload) Description() string {
79         return "File I/O by filename (replication_workload)"
80 }
81