Skip to content

Commit

Permalink
*: rename "GetDDLJob" to "GetDDLJobByIdx" (pingcap#7129)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored Jul 25, 2018
1 parent dd99148 commit 8b913c9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (d *ddl) getHistoryDDLJob(id int64) (*model.Job, error) {

// getFirstDDLJob gets the first DDL job form DDL queue.
func (w *worker) getFirstDDLJob(t *meta.Meta) (*model.Job, error) {
job, err := t.GetDDLJob(0)
job, err := t.GetDDLJobByIdx(0)
return job, errors.Trace(err)
}

Expand Down
2 changes: 1 addition & 1 deletion ddl/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func testDropSchema(c *C, ctx sessionctx.Context, d *ddl, dbInfo *model.DBInfo)
}

func isDDLJobDone(c *C, t *meta.Meta) bool {
job, err := t.GetDDLJob(0)
job, err := t.GetDDLJobByIdx(0)
c.Assert(err, IsNil)
if job == nil {
return true
Expand Down
6 changes: 3 additions & 3 deletions meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,19 @@ func (m *Meta) getDDLJob(key []byte, index int64) (*model.Job, error) {
return job, errors.Trace(err)
}

// GetDDLJob returns the DDL job with index.
// GetDDLJobByIdx returns the corresponding DDL job by the index.
// The length of jobListKeys can only be 1 or 0.
// If its length is 1, we need to replace m.jobListKey with jobListKeys[0].
// Otherwise, we use m.jobListKey directly.
func (m *Meta) GetDDLJob(index int64, jobListKeys ...JobListKeyType) (*model.Job, error) {
func (m *Meta) GetDDLJobByIdx(index int64, jobListKeys ...JobListKeyType) (*model.Job, error) {
listKey := m.jobListKey
if len(jobListKeys) != 0 {
listKey = jobListKeys[0]
}

startTime := time.Now()
job, err := m.getDDLJob(listKey, index)
metrics.MetaHistogram.WithLabelValues(metrics.GetDDLJob, metrics.RetLabel(err)).Observe(time.Since(startTime).Seconds())
metrics.MetaHistogram.WithLabelValues(metrics.GetDDLJobByIdx, metrics.RetLabel(err)).Observe(time.Since(startTime).Seconds())
return job, errors.Trace(err)
}

Expand Down
4 changes: 2 additions & 2 deletions meta/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ func (s *testSuite) TestDDL(c *C) {
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(1))

v, err := t.GetDDLJob(0)
v, err := t.GetDDLJobByIdx(0)
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, job)
v, err = t.GetDDLJob(1)
v, err = t.GetDDLJobByIdx(1)
c.Assert(err, IsNil)
c.Assert(v, IsNil)
job.ID = 2
Expand Down
2 changes: 1 addition & 1 deletion metrics/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (

GetSchemaDiff = "get_schema_diff"
SetSchemaDiff = "set_schema_diff"
GetDDLJob = "get_ddl_job"
GetDDLJobByIdx = "get_ddl_job"
UpdateDDLJob = "update_ddl_job"
GetHistoryDDLJob = "get_history_ddl_job"

Expand Down
4 changes: 2 additions & 2 deletions util/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func GetDDLInfo(txn kv.Transaction) (*DDLInfo, error) {
info := &DDLInfo{}
t := meta.NewMeta(txn)

info.Job, err = t.GetDDLJob(0)
info.Job, err = t.GetDDLJobByIdx(0)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func getDDLJobsInQueue(t *meta.Meta, jobListKey meta.JobListKeyType) ([]*model.J
}
jobs := make([]*model.Job, cnt)
for i := range jobs {
jobs[i], err = t.GetDDLJob(int64(i), jobListKey)
jobs[i], err = t.GetDDLJobByIdx(int64(i), jobListKey)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit 8b913c9

Please sign in to comment.