mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
fixed DB to index conflicts after merge
This commit is contained in:
parent
5a8c165c53
commit
a543ba21bb
9 changed files with 49 additions and 52 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,3 +2,5 @@ default.etcd/
|
|||
*.test
|
||||
vendor
|
||||
.protoc-gen-gofast
|
||||
|
||||
/datadog/.DS_Store
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package pilosa
|
|||
import (
|
||||
"encoding/binary"
|
||||
"hash/fnv"
|
||||
"sync"
|
||||
|
||||
"github.com/pilosa/pilosa/internal"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ on the configured port.`,
|
|||
flags.StringVarP(&Server.Config.Cluster.Type, "cluster.type", "", "static", "Determine how the cluster handles membership and state sharing. Choose from [static, http, gossip]")
|
||||
flags.StringVarP(&Server.Config.Cluster.GossipSeed, "cluster.gossip-seed", "", "", "Host with which to seed the gossip membership.")
|
||||
flags.StringVarP(&Server.Config.Cluster.InternalPort, "cluster.internal-port", "", "", "Port to which pilosa should bind for internal state sharing.")
|
||||
flags.StringVarP(&Server.Config.Metric.Service, "metric.service", "", "noop", "Default URI on which pilosa should listen.")
|
||||
flags.StringVarP(&Server.Config.Metric.Service, "metric.service", "", "nop", "Default URI on which pilosa should listen.")
|
||||
flags.StringVarP(&Server.Config.Metric.Host, "metric.host", "", "", "Default URI to send metrics.")
|
||||
flags.DurationVarP((*time.Duration)(&Server.Config.Metric.PollingInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.")
|
||||
return serveCmd
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const (
|
|||
DefaultPort = "10101"
|
||||
DefaultClusterType = "static"
|
||||
DefaultInternalPort = "14000"
|
||||
DefaultMetrics = "noop"
|
||||
DefaultMetrics = "nop"
|
||||
)
|
||||
|
||||
// Config represents the configuration for the command.
|
||||
|
|
|
|||
|
|
@ -920,7 +920,7 @@ func (e *Executor) executeSetColumnAttrs(ctx context.Context, index string, c *p
|
|||
if err := idx.ColumnAttrStore().SetAttrs(id, attrs); err != nil {
|
||||
return err
|
||||
}
|
||||
d.Stats.Count("SetProfileAttrs", 1)
|
||||
idx.Stats.Count("SetProfileAttrs", 1)
|
||||
// Do not forward call if this is already being forwarded.
|
||||
if opt.Remote {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ func (h *Holder) newIndex(path, name string) (*Index, error) {
|
|||
return nil, err
|
||||
}
|
||||
index.LogOutput = h.LogOutput
|
||||
index.stats = h.Stats.WithTags(fmt.Sprintf("index:%s", index.Name()))
|
||||
index.Stats = h.Stats.WithTags(fmt.Sprintf("index:%s", index.Name()))
|
||||
index.broadcaster = h.Broadcaster
|
||||
return index, nil
|
||||
}
|
||||
|
|
|
|||
12
index.go
12
index.go
|
|
@ -44,7 +44,7 @@ type Index struct {
|
|||
columnAttrStore *AttrStore
|
||||
|
||||
broadcaster Broadcaster
|
||||
stats StatsClient
|
||||
Stats StatsClient
|
||||
|
||||
LogOutput io.Writer
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ func NewIndex(path, name string) (*Index, error) {
|
|||
|
||||
columnLabel: DefaultColumnLabel,
|
||||
|
||||
stats: NopStatsClient,
|
||||
Stats: NopStatsClient,
|
||||
LogOutput: ioutil.Discard,
|
||||
}, nil
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ func (i *Index) openFrames() error {
|
|||
}
|
||||
i.frames[fr.Name()] = fr
|
||||
|
||||
i.stats.Count("frameN", 1)
|
||||
i.Stats.Count("frameN", 1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -405,7 +405,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("frameN", 1)
|
||||
|
||||
return f, nil
|
||||
}
|
||||
|
|
@ -416,7 +416,7 @@ func (i *Index) newFrame(path, name string) (*Frame, error) {
|
|||
return nil, err
|
||||
}
|
||||
f.LogOutput = i.LogOutput
|
||||
f.stats = i.stats.WithTags(fmt.Sprintf("frame:%s", name))
|
||||
f.Stats = i.Stats.WithTags(fmt.Sprintf("frame:%s", name))
|
||||
f.broadcaster = i.broadcaster
|
||||
return f, nil
|
||||
}
|
||||
|
|
@ -445,7 +445,7 @@ func (i *Index) DeleteFrame(name string) error {
|
|||
// Remove reference.
|
||||
delete(i.frames, name)
|
||||
|
||||
i.stats.Count("frameN", -1)
|
||||
i.Stats.Count("frameN", -1)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,18 +282,13 @@ func (s *Server) ReceiveMessage(pb proto.Message) error {
|
|||
// In a gossip implementation, memberlist.Delegate.LocalState() uses this.
|
||||
func (s *Server) LocalStatus() (proto.Message, error) {
|
||||
if s.Holder == nil {
|
||||
return nil, errors.New("Server.Holder is nil.")
|
||||
return nil, errors.New("Server.Holder is nil")
|
||||
}
|
||||
return &internal.NodeStatus{
|
||||
Host: s.Host,
|
||||
State: NodeStateUp,
|
||||
Indexes: encodeIndexes(s.Holder.Indexes()),
|
||||
|
||||
ns := internal.NodeState{
|
||||
}
|
||||
|
||||
s.Cluster.SetNodeState(&ns)
|
||||
return &ns, nil
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ClusterStatus returns the NodeState for all nodes in the cluster.
|
||||
|
|
|
|||
|
|
@ -2,30 +2,31 @@ package pilosa_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/pilosa/pilosa"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pilosa/pilosa"
|
||||
)
|
||||
|
||||
func TestStatsCount_TopN(t *testing.T) {
|
||||
idx := MustOpenIndex()
|
||||
defer idx.Close()
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth)
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth+2)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth+2)
|
||||
|
||||
// Execute query.
|
||||
called := false
|
||||
e := NewExecutor(idx.Index, NewCluster(1))
|
||||
e.Index.Stats = &MockStats{
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
e.Holder.Stats = &MockStats{
|
||||
mockCountWithTags: func(name string, value int64, tags []string) {
|
||||
if name != "TopN" {
|
||||
t.Errorf("Expected TopN, Results %s", name)
|
||||
}
|
||||
|
||||
if tags[0] != "db:d" {
|
||||
if tags[0] != "index:d" {
|
||||
t.Errorf("Expected db, Results %s", tags[0])
|
||||
}
|
||||
|
||||
|
|
@ -42,20 +43,20 @@ func TestStatsCount_TopN(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStatsCount_Bitmap(t *testing.T) {
|
||||
idx := MustOpenIndex()
|
||||
defer idx.Close()
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
called := false
|
||||
e := NewExecutor(idx.Index, NewCluster(1))
|
||||
e.Index.Stats = &MockStats{
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
e.Holder.Stats = &MockStats{
|
||||
mockCountWithTags: func(name string, value int64, tags []string) {
|
||||
if name != "Bitmap" {
|
||||
t.Errorf("Expected Bitmap, Results %s", name)
|
||||
}
|
||||
|
||||
if tags[0] != "db:d" {
|
||||
if tags[0] != "index:d" {
|
||||
t.Errorf("Expected db, Results %s", tags[0])
|
||||
}
|
||||
|
||||
|
|
@ -72,15 +73,15 @@ func TestStatsCount_Bitmap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStatsCount_SetBitmapAttrs(t *testing.T) {
|
||||
idx := MustOpenIndex()
|
||||
defer idx.Close()
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
|
||||
called := false
|
||||
e := NewExecutor(idx.Index, NewCluster(1))
|
||||
frame := e.Index.Frame("d", "f")
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
frame := e.Holder.Frame("d", "f")
|
||||
if frame == nil {
|
||||
t.Fatal("frame not found")
|
||||
}
|
||||
|
|
@ -94,7 +95,7 @@ func TestStatsCount_SetBitmapAttrs(t *testing.T) {
|
|||
return
|
||||
},
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "d", MustParse(`SetBitmapAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "d", MustParse(`SetRowAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !called {
|
||||
|
|
@ -103,20 +104,20 @@ func TestStatsCount_SetBitmapAttrs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
||||
idx := MustOpenIndex()
|
||||
defer idx.Close()
|
||||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
idx.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
|
||||
called := false
|
||||
e := NewExecutor(idx.Index, NewCluster(1))
|
||||
db := e.Index.DB("d")
|
||||
if db == nil {
|
||||
t.Fatal("db not found")
|
||||
e := NewExecutor(hldr.Holder, NewCluster(1))
|
||||
idx := e.Holder.Index("d")
|
||||
if idx == nil {
|
||||
t.Fatal("idex not found")
|
||||
}
|
||||
|
||||
db.Stats = &MockStats{
|
||||
idx.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64) {
|
||||
if name != "SetProfileAttrs" {
|
||||
t.Errorf("Expected SetProfilepAttrs, Results %s", name)
|
||||
|
|
@ -126,7 +127,7 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
|||
return
|
||||
},
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "d", MustParse(`SetProfileAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "d", MustParse(`SetColumnAttrs(id=10, frame=f, foo="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !called {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue