mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 03:17:50 +00:00
create/delete index/frame tag
This commit is contained in:
parent
b450a62816
commit
beb280624d
3 changed files with 37 additions and 9 deletions
|
|
@ -94,8 +94,6 @@ func (h *Holder) Open() error {
|
|||
return fmt.Errorf("open index: name=%s, err=%s", index.Name(), err)
|
||||
}
|
||||
h.indexes[index.Name()] = index
|
||||
|
||||
h.Stats.Count("indexN", 1)
|
||||
}
|
||||
|
||||
// Periodically flush cache.
|
||||
|
|
@ -233,8 +231,8 @@ func (h *Holder) createIndex(name string, opt IndexOptions) (*Index, error) {
|
|||
index.SetTimeQuantum(opt.TimeQuantum)
|
||||
|
||||
h.indexes[index.Name()] = index
|
||||
|
||||
h.Stats.Count("indexN", 1)
|
||||
fmt.Println("HERE")
|
||||
h.Stats.Count("createIndex", 1)
|
||||
|
||||
return index, nil
|
||||
}
|
||||
|
|
@ -274,7 +272,7 @@ func (h *Holder) DeleteIndex(name string) error {
|
|||
// Remove reference.
|
||||
delete(h.indexes, name)
|
||||
|
||||
h.Stats.Count("indexN", -1)
|
||||
h.Stats.Count("deleteIndex", 1)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
6
index.go
6
index.go
|
|
@ -164,8 +164,6 @@ func (i *Index) openFrames() error {
|
|||
return fmt.Errorf("open frame: name=%s, err=%s", fr.Name(), err)
|
||||
}
|
||||
i.frames[fr.Name()] = fr
|
||||
|
||||
i.Stats.Count("frameN", 1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -405,7 +403,7 @@ func (i *Index) createFrame(name string, opt FrameOptions) (*Frame, error) {
|
|||
// Add to index's frame lookup.
|
||||
i.frames[name] = f
|
||||
|
||||
i.Stats.Count("frameN", 1)
|
||||
i.Stats.Count("createFrame", 1)
|
||||
|
||||
return f, nil
|
||||
}
|
||||
|
|
@ -445,7 +443,7 @@ func (i *Index) DeleteFrame(name string) error {
|
|||
// Remove reference.
|
||||
delete(i.frames, name)
|
||||
|
||||
i.Stats.Count("frameN", -1)
|
||||
i.Stats.Count("deleteFrame", 1)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,38 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestStatsCount_CreateIndex(t *testing.T) {
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
|
||||
called := false
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
idx := e.Holder.Index("d")
|
||||
if idx == nil {
|
||||
t.Fatal("index not found")
|
||||
}
|
||||
|
||||
e.Holder.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64) {
|
||||
if name != "createIndex" {
|
||||
t.Errorf("Expected createIndex, Results %s", name)
|
||||
}
|
||||
|
||||
called = true
|
||||
return
|
||||
},
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "d", MustParse(`SetColumnAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !called {
|
||||
t.Error("Count isn't called")
|
||||
}
|
||||
}
|
||||
|
||||
type MockStats struct {
|
||||
mockCount func(name string, value int64)
|
||||
mockCountWithTags func(name string, value int64, tags []string)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue