mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-10 21:07:53 +00:00
Fixes up a few overlooked d := Index()
This commit is contained in:
parent
2ad322c2c7
commit
1343979308
6 changed files with 43 additions and 43 deletions
|
|
@ -195,11 +195,11 @@ func TestClient_ImportInverseEnabled(t *testing.T) {
|
|||
hldr := MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
d := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
frameOpts := pilosa.FrameOptions{
|
||||
InverseEnabled: true,
|
||||
}
|
||||
frame, err := d.CreateFrameIfNotExists("f", frameOpts)
|
||||
frame, err := idx.CreateFrameIfNotExists("f", frameOpts)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
40
executor.go
40
executor.go
|
|
@ -160,11 +160,11 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
bm, _ := other.(*Bitmap)
|
||||
if c.Name == "Bitmap" {
|
||||
|
||||
d := e.Holder.Index(index)
|
||||
if d != nil {
|
||||
columnLabel := d.ColumnLabel()
|
||||
idx := e.Holder.Index(index)
|
||||
if idx != nil {
|
||||
columnLabel := idx.ColumnLabel()
|
||||
if columnID, ok, err := c.UintArg(columnLabel); ok && err == nil {
|
||||
attrs, err := d.ColumnAttrStore().Attrs(columnID)
|
||||
attrs, err := idx.ColumnAttrStore().Attrs(columnID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
return nil, err
|
||||
} else {
|
||||
frame, _ := c.Args["frame"].(string)
|
||||
if fr := d.Frame(frame); fr != nil {
|
||||
if fr := idx.Frame(frame); fr != nil {
|
||||
rowLabel := fr.RowLabel()
|
||||
rowID, _, err := c.UintArg(rowLabel)
|
||||
if err != nil {
|
||||
|
|
@ -362,11 +362,11 @@ func (e *Executor) executeDifferenceSlice(ctx context.Context, index string, c *
|
|||
|
||||
func (e *Executor) executeBitmapSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (*Bitmap, error) {
|
||||
// Fetch column label from index.
|
||||
d := e.Holder.Index(index)
|
||||
if d == nil {
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil, ErrIndexNotFound
|
||||
}
|
||||
columnLabel := d.ColumnLabel()
|
||||
columnLabel := idx.ColumnLabel()
|
||||
|
||||
// Fetch frame & row label based on argument.
|
||||
frame, _ := c.Args["frame"].(string)
|
||||
|
|
@ -548,17 +548,17 @@ func (e *Executor) executeClearBit(ctx context.Context, index string, c *pql.Cal
|
|||
}
|
||||
|
||||
// Retrieve frame.
|
||||
d := e.Holder.Index(index)
|
||||
if d == nil {
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return false, ErrIndexNotFound
|
||||
}
|
||||
f := d.Frame(frame)
|
||||
f := idx.Frame(frame)
|
||||
if f == nil {
|
||||
return false, ErrFrameNotFound
|
||||
}
|
||||
|
||||
// Retrieve labels.
|
||||
columnLabel := d.ColumnLabel()
|
||||
columnLabel := idx.ColumnLabel()
|
||||
rowLabel := f.RowLabel()
|
||||
|
||||
// Read fields using labels.
|
||||
|
|
@ -642,17 +642,17 @@ func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call,
|
|||
}
|
||||
|
||||
// Retrieve frame.
|
||||
d := e.Holder.Index(index)
|
||||
if d == nil {
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return false, ErrIndexNotFound
|
||||
}
|
||||
f := d.Frame(frame)
|
||||
f := idx.Frame(frame)
|
||||
if f == nil {
|
||||
return false, ErrFrameNotFound
|
||||
}
|
||||
|
||||
// Retrieve labels.
|
||||
columnLabel := d.ColumnLabel()
|
||||
columnLabel := idx.ColumnLabel()
|
||||
rowLabel := f.RowLabel()
|
||||
|
||||
// Read fields using labels.
|
||||
|
|
@ -886,8 +886,8 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal
|
|||
// executeSetColumnAttrs executes a SetColumnAttrs() call.
|
||||
func (e *Executor) executeSetColumnAttrs(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error {
|
||||
// Retrieve index.
|
||||
d := e.Holder.Index(index)
|
||||
if d == nil {
|
||||
idx := e.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return ErrIndexNotFound
|
||||
}
|
||||
|
||||
|
|
@ -895,7 +895,7 @@ func (e *Executor) executeSetColumnAttrs(ctx context.Context, index string, c *p
|
|||
id, okID, errID := c.UintArg("id")
|
||||
if errID != nil || !okID {
|
||||
// Retrieve columnLabel
|
||||
columnLabel := d.columnLabel
|
||||
columnLabel := idx.columnLabel
|
||||
col, okCol, errCol := c.UintArg(columnLabel)
|
||||
if errCol != nil || !okCol {
|
||||
return fmt.Errorf("reading SetColumnAttrs() id/columnLabel errs: %v/%v found %v/%v", errID, errCol, okID, okCol)
|
||||
|
|
@ -911,7 +911,7 @@ func (e *Executor) executeSetColumnAttrs(ctx context.Context, index string, c *p
|
|||
delete(attrs, colName)
|
||||
|
||||
// Set attributes.
|
||||
if err := d.ColumnAttrStore().SetAttrs(id, attrs); err != nil {
|
||||
if err := idx.ColumnAttrStore().SetAttrs(id, attrs); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -648,8 +648,8 @@ func TestHandler_Frame_AttrStore_Diff(t *testing.T) {
|
|||
defer s.Close()
|
||||
|
||||
// Set attributes on the index.
|
||||
d := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
f, err := d.CreateFrameIfNotExists("meta", pilosa.FrameOptions{})
|
||||
idx := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
f, err := idx.CreateFrameIfNotExists("meta", pilosa.FrameOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -701,7 +701,7 @@ func TestHandler_Fragment_BackupRestore(t *testing.T) {
|
|||
f0 := hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0)
|
||||
f0.MustSetBits(100, 1, 2, 3)
|
||||
|
||||
// Begin backing up from slice d/f/0.
|
||||
// Begin backing up from slice i/f/0.
|
||||
resp, err := http.Get(s.URL + "/fragment/data?index=i&frame=f&view=standard&slice=0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
16
holder.go
16
holder.go
|
|
@ -281,11 +281,11 @@ func (h *Holder) DeleteIndex(name string) error {
|
|||
|
||||
// Frame returns the frame for an index and name.
|
||||
func (h *Holder) Frame(index, name string) *Frame {
|
||||
d := h.Index(index)
|
||||
if d == nil {
|
||||
idx := h.Index(index)
|
||||
if idx == nil {
|
||||
return nil
|
||||
}
|
||||
return d.Frame(name)
|
||||
return idx.Frame(name)
|
||||
}
|
||||
|
||||
// View returns the view for an index, frame, and name.
|
||||
|
|
@ -423,13 +423,13 @@ func (s *HolderSyncer) SyncHolder() error {
|
|||
// syncIndex synchronizes index attributes with the rest of the cluster.
|
||||
func (s *HolderSyncer) syncIndex(index string) error {
|
||||
// Retrieve index reference.
|
||||
d := s.Holder.Index(index)
|
||||
if d == nil {
|
||||
idx := s.Holder.Index(index)
|
||||
if idx == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Read block checksums.
|
||||
blks, err := d.ColumnAttrStore().Blocks()
|
||||
blks, err := idx.ColumnAttrStore().Blocks()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -451,12 +451,12 @@ func (s *HolderSyncer) syncIndex(index string) error {
|
|||
}
|
||||
|
||||
// Update local copy.
|
||||
if err := d.ColumnAttrStore().SetBulkAttrs(m); err != nil {
|
||||
if err := idx.ColumnAttrStore().SetBulkAttrs(m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Recompute blocks.
|
||||
blks, err = d.ColumnAttrStore().Blocks()
|
||||
blks, err = idx.ColumnAttrStore().Blocks()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
f = hldr.Fragment("i", "f0", pilosa.ViewStandard, 1)
|
||||
a := f.Row(9).Bits()
|
||||
if !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected bits(%d/d/f0): %+v", i, a)
|
||||
t.Fatalf("unexpected bits(%d/i/f0): %+v", i, a)
|
||||
}
|
||||
if a := f.Row(9).Bits(); !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected bits(%d/d/f0): %+v", i, a)
|
||||
|
|
@ -199,11 +199,11 @@ func (h *Holder) Close() error {
|
|||
|
||||
// MustCreateIndexIfNotExists returns a given index. Panic on error.
|
||||
func (h *Holder) MustCreateIndexIfNotExists(index string, opt pilosa.IndexOptions) *Index {
|
||||
d, err := h.Holder.CreateIndexIfNotExists(index, opt)
|
||||
idx, err := h.Holder.CreateIndexIfNotExists(index, opt)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &Index{Index: d}
|
||||
return &Index{Index: idx}
|
||||
}
|
||||
|
||||
// MustCreateFrameIfNotExists returns a given frame. Panic on error.
|
||||
|
|
@ -217,8 +217,8 @@ func (h *Holder) MustCreateFrameIfNotExists(index, frame string) *Frame {
|
|||
|
||||
// MustCreateFragmentIfNotExists returns a given fragment. Panic on error.
|
||||
func (h *Holder) MustCreateFragmentIfNotExists(index, frame, view string, slice uint64) *Fragment {
|
||||
d := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{})
|
||||
f, err := d.CreateFrameIfNotExists(frame, pilosa.FrameOptions{})
|
||||
idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{})
|
||||
f, err := idx.CreateFrameIfNotExists(frame, pilosa.FrameOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
10
server.go
10
server.go
|
|
@ -240,11 +240,11 @@ func (s *Server) monitorMaxSlices() {
|
|||
func (s *Server) ReceiveMessage(pb proto.Message) error {
|
||||
switch obj := pb.(type) {
|
||||
case *internal.CreateSliceMessage:
|
||||
d := s.Holder.Index(obj.Index)
|
||||
if d == nil {
|
||||
idx := s.Holder.Index(obj.Index)
|
||||
if idx == nil {
|
||||
return fmt.Errorf("Local Index not found: %s", obj.Index)
|
||||
}
|
||||
d.SetRemoteMaxSlice(obj.Slice)
|
||||
idx.SetRemoteMaxSlice(obj.Slice)
|
||||
case *internal.CreateIndexMessage:
|
||||
opt := IndexOptions{ColumnLabel: obj.Meta.ColumnLabel}
|
||||
_, err := s.Holder.CreateIndex(obj.Index, opt)
|
||||
|
|
@ -300,7 +300,7 @@ func (s *Server) mergeRemoteState(ns *internal.NodeState) error {
|
|||
ColumnLabel: index.Meta.ColumnLabel,
|
||||
TimeQuantum: TimeQuantum(index.Meta.TimeQuantum),
|
||||
}
|
||||
d, err := s.Holder.CreateIndexIfNotExists(index.Name, opt)
|
||||
idx, err := s.Holder.CreateIndexIfNotExists(index.Name, opt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ func (s *Server) mergeRemoteState(ns *internal.NodeState) error {
|
|||
TimeQuantum: TimeQuantum(f.Meta.TimeQuantum),
|
||||
CacheSize: f.Meta.CacheSize,
|
||||
}
|
||||
_, err := d.CreateFrameIfNotExists(f.Name, opt)
|
||||
_, err := idx.CreateFrameIfNotExists(f.Name, opt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue