Skip to content

Commit

Permalink
work on unexporting View stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jaffee committed Jul 2, 2018
1 parent d691e93 commit 4182678
Show file tree
Hide file tree
Showing 14 changed files with 345 additions and 243 deletions.
6 changes: 3 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (api *API) UnmarshalFragment(ctx context.Context, indexName string, fieldNa
}

// Retrieve view.
view, err := f.CreateViewIfNotExists(ViewStandard)
view, err := f.createViewIfNotExists(ViewStandard)
if err != nil {
return errors.Wrap(err, "creating view")
}
Expand Down Expand Up @@ -528,7 +528,7 @@ func (api *API) Views(ctx context.Context, indexName string, fieldName string) (
}

// Fetch views.
views := f.Views()
views := f.views()
return views, nil
}

Expand All @@ -545,7 +545,7 @@ func (api *API) DeleteView(ctx context.Context, indexName string, fieldName stri
}

// Delete the view.
if err := f.DeleteView(viewName); err != nil {
if err := f.deleteView(viewName); err != nil {
// Ignore this error because views do not exist on all nodes due to shard distribution.
if err != ErrInvalidView {
return errors.Wrap(err, "deleting view")
Expand Down
4 changes: 2 additions & 2 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ func (c *cluster) fragsByHost(idx *Index) fragsByHost {
fieldViews := make(viewsByField)

for _, field := range idx.Fields() {
for _, view := range field.Views() {
for _, view := range field.views() {
fieldViews.addView(field.Name(), view.name)

}
Expand Down Expand Up @@ -1222,7 +1222,7 @@ func (c *cluster) followResizeInstruction(instr *internal.ResizeInstruction) err
}

// Create view.
v, err := f.CreateViewIfNotExists(src.View)
v, err := f.createViewIfNotExists(src.View)
if err != nil {
return errors.Wrap(err, "creating view")
}
Expand Down
4 changes: 2 additions & 2 deletions cluster_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func TestCluster_ResizeStates(t *testing.T) {
// Before starting the resize, get the CheckSum to use for
// comparison later.
node0Field := node0.holder.Field("i", "f")
node0View := node0Field.View("standard")
node0View := node0Field.view("standard")
node0Fragment := node0View.Fragment(1)
node0Checksum := node0Fragment.Checksum()

Expand Down Expand Up @@ -735,7 +735,7 @@ func TestCluster_ResizeStates(t *testing.T) {
// Bits
// Verify that node-1 contains the fragment (i/f/standard/1) transferred from node-0.
node1Field := node1.holder.Field("i", "f")
node1View := node1Field.View("standard")
node1View := node1Field.view("standard")
node1Fragment := node1View.Fragment(1)

// Ensure checksums are the same.
Expand Down
19 changes: 12 additions & 7 deletions executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,10 @@ func TestExecutor_Execute_TopN(t *testing.T) {
t.Fatal(err)
}

hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).RecalculateCache()
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).RecalculateCache()
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 5).RecalculateCache()
err := c[0].RecalculateCaches()
if err != nil {
t.Fatalf("recalculating caches: %v", err)
}

if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `TopN(f, n=2)`}); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -571,7 +572,10 @@ func TestExecutor_Execute_TopN(t *testing.T) {
t.Fatal(err)
}

hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).RecalculateCache()
err := c[0].RecalculateCaches()
if err != nil {
t.Fatalf("recalculating caches: %v", err)
}

if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `TopN(f, n=2)`}); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -664,9 +668,10 @@ func TestExecutor_Execute_TopN_Src(t *testing.T) {
hldr.SetBit("i", "other", 100, ShardWidth+1)
hldr.SetBit("i", "other", 100, ShardWidth+2)

hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).RecalculateCache()
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).RecalculateCache()
hldr.MustCreateRankedFragmentIfNotExists("i", "other", pilosa.ViewStandard, 1).RecalculateCache()
err := c[0].RecalculateCaches()
if err != nil {
t.Fatalf("recalculating caches: %v", err)
}

// Execute query.
if result, err := c[0].API.Query(context.Background(), &pilosa.QueryRequest{Index: "i", Query: `TopN(f, Row(other=100), n=3)`}); err != nil {
Expand Down
Loading

0 comments on commit 4182678

Please sign in to comment.