-
-
Notifications
You must be signed in to change notification settings - Fork 195
/
histogram.go
147 lines (113 loc) · 2.87 KB
/
histogram.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package plan
import (
"encoding/json"
"fmt"
"strings"
"github.com/dolthub/go-mysql-server/sql"
)
func NewUpdateHistogram(db, table, index string, cols []string, stats sql.Statistic) *UpdateHistogram {
return &UpdateHistogram{db: db, cols: cols, index: index, table: table, stats: stats}
}
type UpdateHistogram struct {
db string
table string
index string
cols []string
stats sql.Statistic
prov sql.StatsProvider
}
var _ sql.Node = (*UpdateHistogram)(nil)
func (u *UpdateHistogram) Db() string {
return u.db
}
func (u *UpdateHistogram) Table() string {
return u.table
}
func (u *UpdateHistogram) Index() string {
return u.index
}
func (u *UpdateHistogram) Cols() []string {
return u.cols
}
func (u *UpdateHistogram) Stats() sql.Statistic {
return u.stats
}
func (u *UpdateHistogram) WithProvider(prov sql.StatsProvider) *UpdateHistogram {
ret := *u
ret.prov = prov
return &ret
}
func (u *UpdateHistogram) StatsProvider() sql.StatsProvider {
return u.prov
}
func (u *UpdateHistogram) Resolved() bool {
return true
}
func (u *UpdateHistogram) String() string {
statMap := u.stats.ToInterface()
statBytes, _ := json.Marshal(statMap)
return fmt.Sprintf("update histogram %s.(%s) using %s", u.table, strings.Join(u.cols, ","), statBytes)
}
func (u *UpdateHistogram) Schema() sql.Schema {
return analyzeSchema
}
func (u *UpdateHistogram) Children() []sql.Node {
return nil
}
func (u *UpdateHistogram) WithChildren(children ...sql.Node) (sql.Node, error) {
return u, nil
}
func (u *UpdateHistogram) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool {
return true
}
func (u *UpdateHistogram) IsReadOnly() bool {
return false
}
func NewDropHistogram(db, table string, cols []string) *DropHistogram {
return &DropHistogram{db: db, cols: cols, table: table}
}
type DropHistogram struct {
db string
table string
cols []string
prov sql.StatsProvider
}
var _ sql.Node = (*DropHistogram)(nil)
func (d *DropHistogram) StatsProvider() sql.StatsProvider {
return d.prov
}
func (d *DropHistogram) WithProvider(prov sql.StatsProvider) *DropHistogram {
ret := *d
ret.prov = prov
return &ret
}
func (d *DropHistogram) Db() string {
return d.db
}
func (d *DropHistogram) Table() string {
return d.table
}
func (d *DropHistogram) Cols() []string {
return d.cols
}
func (d *DropHistogram) Resolved() bool {
return true
}
func (d *DropHistogram) String() string {
return fmt.Sprintf("drop histogram %s.(%s)", d.table, strings.Join(d.cols, ","))
}
func (d *DropHistogram) Schema() sql.Schema {
return analyzeSchema
}
func (d *DropHistogram) Children() []sql.Node {
return nil
}
func (d *DropHistogram) WithChildren(_ ...sql.Node) (sql.Node, error) {
return d, nil
}
func (d *DropHistogram) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool {
return true
}
func (d *DropHistogram) IsReadOnly() bool {
return false
}