Remove parent index
This commit is contained in:
parent
e6f9a5bbb3
commit
68506c7163
|
@ -110,15 +110,6 @@ func jobTableSchema() *memdb.TableSchema {
|
|||
Conditional: jobIsGCable,
|
||||
},
|
||||
},
|
||||
"parent": &memdb.IndexSchema{
|
||||
Name: "parent",
|
||||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: &memdb.StringFieldIndex{
|
||||
Field: "ParentID",
|
||||
Lowercase: true,
|
||||
},
|
||||
},
|
||||
"periodic": &memdb.IndexSchema{
|
||||
Name: "periodic",
|
||||
AllowMissing: false,
|
||||
|
|
|
@ -359,18 +359,6 @@ func (s *StateStore) Jobs() (memdb.ResultIterator, error) {
|
|||
return iter, nil
|
||||
}
|
||||
|
||||
// ChildJobs returns an iterator over all the children of the passed job.
|
||||
func (s *StateStore) ChildJobs(id string) (memdb.ResultIterator, error) {
|
||||
txn := s.db.Txn(false)
|
||||
|
||||
// Scan all jobs whose parent is the passed id.
|
||||
iter, err := txn.Get("jobs", "parent", id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return iter, nil
|
||||
}
|
||||
|
||||
// JobsByPeriodic returns an iterator over all the periodic or non-periodic jobs.
|
||||
func (s *StateStore) JobsByPeriodic(periodic bool) (memdb.ResultIterator, error) {
|
||||
txn := s.db.Txn(false)
|
||||
|
|
|
@ -405,48 +405,6 @@ func TestStateStore_Jobs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestStateStore_ChildJobs(t *testing.T) {
|
||||
state := testStateStore(t)
|
||||
parent := mock.Job()
|
||||
var childJobs []*structs.Job
|
||||
|
||||
if err := state.UpsertJob(999, parent); err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
job := mock.Job()
|
||||
job.ParentID = parent.ID
|
||||
childJobs = append(childJobs, job)
|
||||
|
||||
err := state.UpsertJob(1000+uint64(i), job)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
iter, err := state.ChildJobs(parent.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
var out []*structs.Job
|
||||
for {
|
||||
raw := iter.Next()
|
||||
if raw == nil {
|
||||
break
|
||||
}
|
||||
out = append(out, raw.(*structs.Job))
|
||||
}
|
||||
|
||||
sort.Sort(JobIDSort(childJobs))
|
||||
sort.Sort(JobIDSort(out))
|
||||
|
||||
if !reflect.DeepEqual(childJobs, out) {
|
||||
t.Fatalf("bad: %#v %#v", childJobs, out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStateStore_JobsByPeriodic(t *testing.T) {
|
||||
state := testStateStore(t)
|
||||
var periodic, nonPeriodic []*structs.Job
|
||||
|
|
Loading…
Reference in New Issue