Skip to content

Commit

Permalink
*: rename statist to statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Nov 17, 2015
1 parent 051a476 commit 7b41184
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func newDDL(store kv.Storage, infoHandle *infoschema.Handle, hook Callback, leas

d.start()

variable.RegisterStatist(d)
variable.RegisterStatistics(d)

return d
}
Expand Down
4 changes: 2 additions & 2 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (do *Domain) SetLease(lease time.Duration) {
do.ddl.SetLease(lease)
}

// Stats returns the DDL statistic.
// Stats returns the domain statistic.
func (do *Domain) Stats() (map[string]interface{}, error) {
m := make(map[string]interface{})
m[ddlLastReloadSchemaTS] = atomic.LoadInt64(&do.lastLeaseTS)
Expand Down Expand Up @@ -195,7 +195,7 @@ func NewDomain(store kv.Storage, lease time.Duration) (d *Domain, err error) {
log.Fatalf("load schema err %v", err)
}

variable.RegisterStatist(d)
variable.RegisterStatistics(d)

go d.loadSchemaInLoop(lease)

Expand Down
2 changes: 1 addition & 1 deletion plan/plans/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p *testShowSuit) SetUpSuite(c *C) {
p.ctx = nc
variable.BindSessionVars(p.ctx)
variable.BindGlobalVarAccessor(p.ctx, nc)
variable.RegisterStatist(p.ms)
variable.RegisterStatistics(p.ms)

p.dbName = "testshowplan"
p.store = newStore(c, p.dbName)
Expand Down
24 changes: 12 additions & 12 deletions sessionctx/variable/statusvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,41 @@ var globalStatusScopes = make(map[string]ScopeFlag)
// DefaultScopeFlag is the status default scope.
var DefaultScopeFlag = ScopeGlobal | ScopeSession

// Statists is the set of all statists.
var Statists []Statist
// StatisticsList is the set of all statistics.
var StatisticsList []Statistics

// StatusVal is the value of the corresponding status variable.
type StatusVal struct {
Scope ScopeFlag
Value interface{}
}

// Statist is the interface of statist.
type Statist interface {
// Statistics is the interface of statistics.
type Statistics interface {
// GetScope gets the status variables scope.
GetScope(status string) ScopeFlag
// Stats returns the statist statistics.
// Stats returns the statistics status variables.
Stats() (map[string]interface{}, error)
}

// RegisterStatist registers statist.
func RegisterStatist(s Statist) {
Statists = append(Statists, s)
// RegisterStatistics registers statistics.
func RegisterStatistics(s Statistics) {
StatisticsList = append(StatisticsList, s)
}

// GetStatusVars gets registered statists status variables.
// GetStatusVars gets registered statistics status variables.
func GetStatusVars() (map[string]*StatusVal, error) {
statusVars = make(map[string]*StatusVal)
ret := make(map[string]*StatusVal)

for _, statist := range Statists {
vals, err := statist.Stats()
for _, statistics := range StatisticsList {
vals, err := statistics.Stats()
if err != nil {
return nil, errors.Trace(err)
}

for name, val := range vals {
scope := statist.GetScope(name)
scope := statistics.GetScope(name)
statusVars[name] = &StatusVal{Value: val, Scope: scope}
ret[name] = &StatusVal{Value: val, Scope: scope}
}
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/statusvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type testStatusVarSuite struct {

func (s *testStatusVarSuite) SetUpSuite(c *C) {
s.ms = &mockStatist{}
RegisterStatist(s.ms)
RegisterStatistics(s.ms)
}

// mockStatist represents mocked statist.
Expand Down

0 comments on commit 7b41184

Please sign in to comment.