mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 04:17:51 +00:00
un-export Fragment.SetBit and Fragment.ClearBit.
adds methods to test.Holder to set/clear bits on a field.
This commit is contained in:
parent
15cb391570
commit
468ad57b6d
11 changed files with 202 additions and 239 deletions
|
|
@ -109,26 +109,26 @@ func TestClient_MultiNode(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetBits(100, baseBit0+10)
|
||||
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetBits(4, baseBit0+10, baseBit0+11, baseBit0+12)
|
||||
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetBits(4, baseBit0+10, baseBit0+11, baseBit0+12, baseBit0+13, baseBit0+14, baseBit0+15)
|
||||
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetBits(2, baseBit0+1, baseBit0+2, baseBit0+3, baseBit0+4)
|
||||
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetBits(3, baseBit0+1, baseBit0+2, baseBit0+3, baseBit0+4, baseBit0+5)
|
||||
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetBits(22, baseBit0+1, baseBit0+2, baseBit0+10)
|
||||
hldr[0].MustSetBits("i", "f", 100, baseBit0+10)
|
||||
hldr[0].MustSetBits("i", "f", 4, baseBit0+10, baseBit0+11, baseBit0+12)
|
||||
hldr[0].MustSetBits("i", "f", 4, baseBit0+10, baseBit0+11, baseBit0+12, baseBit0+13, baseBit0+14, baseBit0+15)
|
||||
hldr[0].MustSetBits("i", "f", 2, baseBit0+1, baseBit0+2, baseBit0+3, baseBit0+4)
|
||||
hldr[0].MustSetBits("i", "f", 3, baseBit0+1, baseBit0+2, baseBit0+3, baseBit0+4, baseBit0+5)
|
||||
hldr[0].MustSetBits("i", "f", 22, baseBit0+1, baseBit0+2, baseBit0+10)
|
||||
|
||||
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetBits(99, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4)
|
||||
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetBits(100, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5, baseBit1+6, baseBit1+7, baseBit1+8, baseBit1+9, baseBit1+10)
|
||||
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetBits(98, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5, baseBit1+6)
|
||||
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetBits(1, baseBit1+4)
|
||||
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetBits(22, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5)
|
||||
hldr[1].MustSetBits("i", "f", 99, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4)
|
||||
hldr[1].MustSetBits("i", "f", 100, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5, baseBit1+6, baseBit1+7, baseBit1+8, baseBit1+9, baseBit1+10)
|
||||
hldr[1].MustSetBits("i", "f", 98, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5, baseBit1+6)
|
||||
hldr[1].MustSetBits("i", "f", 1, baseBit1+4)
|
||||
hldr[1].MustSetBits("i", "f", 22, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5)
|
||||
|
||||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetBits(24, baseBit2+10, baseBit2+11, baseBit2+12, baseBit2+13, baseBit2+14)
|
||||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetBits(20, baseBit2+10, baseBit2+11, baseBit2+12, baseBit2+13)
|
||||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetBits(21, baseBit2+10)
|
||||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetBits(100, baseBit2+10)
|
||||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetBits(99, baseBit2+10, baseBit2+11, baseBit2+12)
|
||||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetBits(98, baseBit2+10, baseBit2+11)
|
||||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetBits(22, baseBit2+10, baseBit2+11, baseBit2+12)
|
||||
hldr[2].MustSetBits("i", "f", 24, baseBit2+10, baseBit2+11, baseBit2+12, baseBit2+13, baseBit2+14)
|
||||
hldr[2].MustSetBits("i", "f", 20, baseBit2+10, baseBit2+11, baseBit2+12, baseBit2+13)
|
||||
hldr[2].MustSetBits("i", "f", 21, baseBit2+10)
|
||||
hldr[2].MustSetBits("i", "f", 100, baseBit2+10)
|
||||
hldr[2].MustSetBits("i", "f", 99, baseBit2+10, baseBit2+11, baseBit2+12)
|
||||
hldr[2].MustSetBits("i", "f", 98, baseBit2+10, baseBit2+11)
|
||||
hldr[2].MustSetBits("i", "f", 22, baseBit2+10, baseBit2+11, baseBit2+12)
|
||||
|
||||
// Rebuild the RankCache.
|
||||
// We have to do this to avoid the 10-second cache invalidation delay
|
||||
|
|
@ -322,11 +322,11 @@ func TestClient_FragmentBlocks(t *testing.T) {
|
|||
defer hldr.Close()
|
||||
|
||||
// Set two bits on blocks 0 & 3.
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(pilosa.HashBlockSize*3, 100)
|
||||
hldr.SetBit("i", "f", 0, 1)
|
||||
hldr.SetBit("i", "f", pilosa.HashBlockSize*3, 100)
|
||||
|
||||
// Set a bit on a different slice.
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(0, 1)
|
||||
hldr.SetBit("i", "f", 0, 1)
|
||||
|
||||
s := test.NewServer()
|
||||
defer s.Close()
|
||||
|
|
|
|||
134
executor_test.go
134
executor_test.go
|
|
@ -107,11 +107,11 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
func TestExecutor_Execute_Difference(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 2)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 3)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 2)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 4)
|
||||
hldr.SetBit("i", "general", 10, 1)
|
||||
hldr.SetBit("i", "general", 10, 2)
|
||||
hldr.SetBit("i", "general", 10, 3)
|
||||
hldr.SetBit("i", "general", 11, 2)
|
||||
hldr.SetBit("i", "general", 11, 4)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Difference(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
|
|
@ -125,7 +125,7 @@ func TestExecutor_Execute_Difference(t *testing.T) {
|
|||
func TestExecutor_Execute_Empty_Difference(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 1)
|
||||
hldr.SetBit("i", "general", 10, 1)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Difference()`), nil, nil); err == nil {
|
||||
|
|
@ -137,13 +137,13 @@ func TestExecutor_Execute_Empty_Difference(t *testing.T) {
|
|||
func TestExecutor_Execute_Intersect(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+2)
|
||||
hldr.SetBit("i", "general", 10, 1)
|
||||
hldr.SetBit("i", "general", 10, SliceWidth+1)
|
||||
hldr.SetBit("i", "general", 10, SliceWidth+2)
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 2)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(11, SliceWidth+2)
|
||||
hldr.SetBit("i", "general", 11, 1)
|
||||
hldr.SetBit("i", "general", 11, 2)
|
||||
hldr.SetBit("i", "general", 11, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Intersect(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
|
|
@ -168,12 +168,12 @@ func TestExecutor_Execute_Empty_Intersect(t *testing.T) {
|
|||
func TestExecutor_Execute_Union(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+2)
|
||||
hldr.SetBit("i", "general", 10, 0)
|
||||
hldr.SetBit("i", "general", 10, SliceWidth+1)
|
||||
hldr.SetBit("i", "general", 10, SliceWidth+2)
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 2)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(11, SliceWidth+2)
|
||||
hldr.SetBit("i", "general", 11, 2)
|
||||
hldr.SetBit("i", "general", 11, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Union(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
|
|
@ -187,7 +187,7 @@ func TestExecutor_Execute_Union(t *testing.T) {
|
|||
func TestExecutor_Execute_Empty_Union(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 0)
|
||||
hldr.SetBit("i", "general", 10, 0)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Union()`), nil, nil); err != nil {
|
||||
|
|
@ -201,12 +201,12 @@ func TestExecutor_Execute_Empty_Union(t *testing.T) {
|
|||
func TestExecutor_Execute_Xor(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+2)
|
||||
hldr.SetBit("i", "general", 10, 0)
|
||||
hldr.SetBit("i", "general", 10, SliceWidth+1)
|
||||
hldr.SetBit("i", "general", 10, SliceWidth+2)
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 2)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(11, SliceWidth+2)
|
||||
hldr.SetBit("i", "general", 11, 2)
|
||||
hldr.SetBit("i", "general", 11, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Xor(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
|
|
@ -220,9 +220,9 @@ func TestExecutor_Execute_Xor(t *testing.T) {
|
|||
func TestExecutor_Execute_Count(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).MustSetBits(10, 3)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetBits(10, SliceWidth+2)
|
||||
hldr.SetBit("i", "f", 10, 3)
|
||||
hldr.SetBit("i", "f", 10, SliceWidth+1)
|
||||
hldr.SetBit("i", "f", 10, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, field=f))`), nil, nil); err != nil {
|
||||
|
|
@ -427,12 +427,12 @@ func TestExecutor_Execute_TopN_fill(t *testing.T) {
|
|||
defer hldr.Close()
|
||||
|
||||
// Set columns for rows 0, 10, & 20 across two slices.
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 2)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(1, SliceWidth+2)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(1, SliceWidth)
|
||||
hldr.SetBit("i", "f", 0, 0)
|
||||
hldr.SetBit("i", "f", 0, 1)
|
||||
hldr.SetBit("i", "f", 0, 2)
|
||||
hldr.SetBit("i", "f", 0, SliceWidth)
|
||||
hldr.SetBit("i", "f", 1, SliceWidth+2)
|
||||
hldr.SetBit("i", "f", 1, SliceWidth)
|
||||
|
||||
// Execute query.
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
|
|
@ -450,23 +450,23 @@ func TestExecutor_Execute_TopN_fill_small(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).SetBit(0, 2*SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 3).SetBit(0, 3*SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 4).SetBit(0, 4*SliceWidth)
|
||||
hldr.SetBit("i", "f", 0, 0)
|
||||
hldr.SetBit("i", "f", 0, SliceWidth)
|
||||
hldr.SetBit("i", "f", 0, 2*SliceWidth)
|
||||
hldr.SetBit("i", "f", 0, 3*SliceWidth)
|
||||
hldr.SetBit("i", "f", 0, 4*SliceWidth)
|
||||
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(1, 0)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(1, 1)
|
||||
hldr.SetBit("i", "f", 1, 0)
|
||||
hldr.SetBit("i", "f", 1, 1)
|
||||
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(2, SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(2, SliceWidth+1)
|
||||
hldr.SetBit("i", "f", 2, SliceWidth)
|
||||
hldr.SetBit("i", "f", 2, SliceWidth+1)
|
||||
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).SetBit(3, 2*SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).SetBit(3, 2*SliceWidth+1)
|
||||
hldr.SetBit("i", "f", 3, 2*SliceWidth)
|
||||
hldr.SetBit("i", "f", 3, 2*SliceWidth+1)
|
||||
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 3).SetBit(4, 3*SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 3).SetBit(4, 3*SliceWidth+1)
|
||||
hldr.SetBit("i", "f", 4, 3*SliceWidth)
|
||||
hldr.SetBit("i", "f", 4, 3*SliceWidth+1)
|
||||
|
||||
// Execute query.
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
|
|
@ -485,19 +485,19 @@ func TestExecutor_Execute_TopN_Src(t *testing.T) {
|
|||
defer hldr.Close()
|
||||
|
||||
// Set columns for rows 0, 10, & 20 across two slices.
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(0, SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(10, SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(10, SliceWidth+1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(20, SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(20, SliceWidth+1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(20, SliceWidth+2)
|
||||
hldr.SetBit("i", "f", 0, 0)
|
||||
hldr.SetBit("i", "f", 0, 1)
|
||||
hldr.SetBit("i", "f", 0, SliceWidth)
|
||||
hldr.SetBit("i", "f", 10, SliceWidth)
|
||||
hldr.SetBit("i", "f", 10, SliceWidth+1)
|
||||
hldr.SetBit("i", "f", 20, SliceWidth)
|
||||
hldr.SetBit("i", "f", 20, SliceWidth+1)
|
||||
hldr.SetBit("i", "f", 20, SliceWidth+2)
|
||||
|
||||
// Create an intersecting row.
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "other", pilosa.ViewStandard, 1).SetBit(100, SliceWidth)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "other", pilosa.ViewStandard, 1).SetBit(100, SliceWidth+1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "other", pilosa.ViewStandard, 1).SetBit(100, SliceWidth+2)
|
||||
hldr.SetBit("i", "other", 100, SliceWidth)
|
||||
hldr.SetBit("i", "other", 100, SliceWidth+1)
|
||||
hldr.SetBit("i", "other", 100, SliceWidth+2)
|
||||
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).RecalculateCache()
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).RecalculateCache()
|
||||
|
|
@ -521,9 +521,9 @@ func TestExecutor_Execute_TopN_Attr(t *testing.T) {
|
|||
//
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(10, SliceWidth)
|
||||
hldr.SetBit("i", "f", 0, 0)
|
||||
hldr.SetBit("i", "f", 0, 1)
|
||||
hldr.SetBit("i", "f", 10, SliceWidth)
|
||||
|
||||
if err := hldr.Field("i", "f").RowAttrStore().SetAttrs(10, map[string]interface{}{"category": int64(123)}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -544,9 +544,9 @@ func TestExecutor_Execute_TopN_Attr_Src(t *testing.T) {
|
|||
//
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).SetBit(10, SliceWidth)
|
||||
hldr.SetBit("i", "f", 0, 0)
|
||||
hldr.SetBit("i", "f", 0, 1)
|
||||
hldr.SetBit("i", "f", 10, SliceWidth)
|
||||
|
||||
if err := hldr.Field("i", "f").RowAttrStore().SetAttrs(10, map[string]interface{}{"category": uint64(123)}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -989,7 +989,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
s.Handler.API.Holder = hldr.Holder
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetBits(10, (1*SliceWidth)+1)
|
||||
hldr.SetBit("i", "f", 10, SliceWidth+1)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, nil); err != nil {
|
||||
|
|
@ -1023,8 +1023,8 @@ func TestExecutor_Execute_Remote_Count(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
s.Handler.API.Holder = hldr.Holder
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetBits(10, (2*SliceWidth)+1)
|
||||
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetBits(10, (2*SliceWidth)+2)
|
||||
hldr.SetBit("i", "f", 10, (2*SliceWidth)+1)
|
||||
hldr.SetBit("i", "f", 10, (2*SliceWidth)+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, field=f))`), nil, nil); err != nil {
|
||||
|
|
@ -1192,8 +1192,8 @@ func TestExecutor_Execute_Remote_TopN(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
s.Handler.API.Holder = hldr.Holder
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetBits(30, (2*SliceWidth)+1)
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 4).MustSetBits(30, (4*SliceWidth)+2)
|
||||
hldr.SetBit("i", "f", 30, (2*SliceWidth)+1)
|
||||
hldr.SetBit("i", "f", 30, (4*SliceWidth)+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=3)`), nil, nil); err != nil {
|
||||
|
|
|
|||
26
fragment.go
26
fragment.go
|
|
@ -361,15 +361,15 @@ func (f *Fragment) row(rowID uint64, checkRowCache bool, updateRowCache bool) *R
|
|||
return row
|
||||
}
|
||||
|
||||
// SetBit sets a bit for a given column & row within the fragment.
|
||||
// setBit sets a bit for a given column & row within the fragment.
|
||||
// This updates both the on-disk storage and the in-cache bitmap.
|
||||
func (f *Fragment) SetBit(rowID, columnID uint64) (changed bool, err error) {
|
||||
func (f *Fragment) setBit(rowID, columnID uint64) (changed bool, err error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.setBit(rowID, columnID)
|
||||
return f.unprotectedSetBit(rowID, columnID)
|
||||
}
|
||||
|
||||
func (f *Fragment) setBit(rowID, columnID uint64) (changed bool, err error) {
|
||||
func (f *Fragment) unprotectedSetBit(rowID, columnID uint64) (changed bool, err error) {
|
||||
changed = false
|
||||
// Determine the position of the bit in the storage.
|
||||
pos, err := f.pos(rowID, columnID)
|
||||
|
|
@ -413,15 +413,15 @@ func (f *Fragment) setBit(rowID, columnID uint64) (changed bool, err error) {
|
|||
return changed, nil
|
||||
}
|
||||
|
||||
// ClearBit clears a bit for a given column & row within the fragment.
|
||||
// clearBit clears a bit for a given column & row within the fragment.
|
||||
// This updates both the on-disk storage and the in-cache bitmap.
|
||||
func (f *Fragment) ClearBit(rowID, columnID uint64) (bool, error) {
|
||||
func (f *Fragment) clearBit(rowID, columnID uint64) (bool, error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
return f.clearBit(rowID, columnID)
|
||||
return f.unprotectedClearBit(rowID, columnID)
|
||||
}
|
||||
|
||||
func (f *Fragment) clearBit(rowID, columnID uint64) (changed bool, err error) {
|
||||
func (f *Fragment) unprotectedClearBit(rowID, columnID uint64) (changed bool, err error) {
|
||||
changed = false
|
||||
// Determine the position of the bit in the storage.
|
||||
pos, err := f.pos(rowID, columnID)
|
||||
|
|
@ -498,13 +498,13 @@ func (f *Fragment) setValue(columnID uint64, bitDepth uint, value uint64) (chang
|
|||
|
||||
for i := uint(0); i < bitDepth; i++ {
|
||||
if value&(1<<i) != 0 {
|
||||
if c, err := f.setBit(uint64(i), columnID); err != nil {
|
||||
if c, err := f.unprotectedSetBit(uint64(i), columnID); err != nil {
|
||||
return changed, err
|
||||
} else if c {
|
||||
changed = true
|
||||
}
|
||||
} else {
|
||||
if c, err := f.clearBit(uint64(i), columnID); err != nil {
|
||||
if c, err := f.unprotectedClearBit(uint64(i), columnID); err != nil {
|
||||
return changed, err
|
||||
} else if c {
|
||||
changed = true
|
||||
|
|
@ -513,7 +513,7 @@ func (f *Fragment) setValue(columnID uint64, bitDepth uint, value uint64) (chang
|
|||
}
|
||||
|
||||
// Mark value as set.
|
||||
if c, err := f.setBit(uint64(bitDepth), columnID); err != nil {
|
||||
if c, err := f.unprotectedSetBit(uint64(bitDepth), columnID); err != nil {
|
||||
return changed, errors.Wrap(err, "marking not-null")
|
||||
} else if c {
|
||||
changed = true
|
||||
|
|
@ -1281,14 +1281,14 @@ func (f *Fragment) mergeBlock(id int, data []pairSet) (sets, clears []pairSet, e
|
|||
|
||||
// Set local bits.
|
||||
for i := range sets[0].columnIDs {
|
||||
if _, err := f.setBit(sets[0].rowIDs[i], (f.slice*SliceWidth)+sets[0].columnIDs[i]); err != nil {
|
||||
if _, err := f.unprotectedSetBit(sets[0].rowIDs[i], (f.slice*SliceWidth)+sets[0].columnIDs[i]); err != nil {
|
||||
return nil, nil, errors.Wrap(err, "setting")
|
||||
}
|
||||
}
|
||||
|
||||
// Clear local bits.
|
||||
for i := range clears[0].columnIDs {
|
||||
if _, err := f.clearBit(clears[0].rowIDs[i], (f.slice*SliceWidth)+clears[0].columnIDs[i]); err != nil {
|
||||
if _, err := f.unprotectedClearBit(clears[0].rowIDs[i], (f.slice*SliceWidth)+clears[0].columnIDs[i]); err != nil {
|
||||
return nil, nil, errors.Wrap(err, "clearing")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ func TestFragment_SetBit(t *testing.T) {
|
|||
defer f.Close()
|
||||
|
||||
// Set bits on the fragment.
|
||||
if _, err := f.SetBit(120, 1); err != nil {
|
||||
if _, err := f.setBit(120, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(120, 6); err != nil {
|
||||
} else if _, err := f.setBit(120, 6); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(121, 0); err != nil {
|
||||
} else if _, err := f.setBit(121, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -71,11 +71,11 @@ func TestFragment_ClearBit(t *testing.T) {
|
|||
defer f.Close()
|
||||
|
||||
// Set and then clear bits on the fragment.
|
||||
if _, err := f.SetBit(1000, 1); err != nil {
|
||||
if _, err := f.setBit(1000, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(1000, 2); err != nil {
|
||||
} else if _, err := f.setBit(1000, 2); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.ClearBit(1000, 1); err != nil {
|
||||
} else if _, err := f.clearBit(1000, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -528,11 +528,11 @@ func TestFragment_Snapshot(t *testing.T) {
|
|||
defer f.Close()
|
||||
|
||||
// Set and then clear bits on the fragment.
|
||||
if _, err := f.SetBit(1000, 1); err != nil {
|
||||
if _, err := f.setBit(1000, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(1000, 2); err != nil {
|
||||
} else if _, err := f.setBit(1000, 2); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.ClearBit(1000, 1); err != nil {
|
||||
} else if _, err := f.clearBit(1000, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -557,11 +557,11 @@ func TestFragment_ForEachBit(t *testing.T) {
|
|||
defer f.Close()
|
||||
|
||||
// Set bits on the fragment.
|
||||
if _, err := f.SetBit(100, 20); err != nil {
|
||||
if _, err := f.setBit(100, 20); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(2, 38); err != nil {
|
||||
} else if _, err := f.setBit(2, 38); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(2, 37); err != nil {
|
||||
} else if _, err := f.setBit(2, 37); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -810,9 +810,9 @@ func TestFragment_Checksum(t *testing.T) {
|
|||
|
||||
// Retrieve checksum and set bits.
|
||||
orig := f.Checksum()
|
||||
if _, err := f.SetBit(1, 200); err != nil {
|
||||
if _, err := f.setBit(1, 200); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(HashBlockSize*2, 200); err != nil {
|
||||
} else if _, err := f.setBit(HashBlockSize*2, 200); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -831,7 +831,7 @@ func TestFragment_Blocks(t *testing.T) {
|
|||
var prev []FragmentBlock
|
||||
|
||||
// Set first bit.
|
||||
if _, err := f.SetBit(0, 0); err != nil {
|
||||
if _, err := f.setBit(0, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
blocks := f.Blocks()
|
||||
|
|
@ -841,7 +841,7 @@ func TestFragment_Blocks(t *testing.T) {
|
|||
prev = blocks
|
||||
|
||||
// Set bit on different row.
|
||||
if _, err := f.SetBit(20, 0); err != nil {
|
||||
if _, err := f.setBit(20, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
blocks = f.Blocks()
|
||||
|
|
@ -851,7 +851,7 @@ func TestFragment_Blocks(t *testing.T) {
|
|||
prev = blocks
|
||||
|
||||
// Set bit on different column.
|
||||
if _, err := f.SetBit(20, 100); err != nil {
|
||||
if _, err := f.setBit(20, 100); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
blocks = f.Blocks()
|
||||
|
|
@ -866,7 +866,7 @@ func TestFragment_Blocks_Empty(t *testing.T) {
|
|||
defer f.Close()
|
||||
|
||||
// Set bits on a different block.
|
||||
if _, err := f.SetBit(100, 1); err != nil {
|
||||
if _, err := f.setBit(100, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -885,7 +885,7 @@ func TestFragment_LRUCache_Persistence(t *testing.T) {
|
|||
|
||||
// Set bits on the fragment.
|
||||
for i := uint64(0); i < 1000; i++ {
|
||||
if _, err := f.SetBit(i, 0); err != nil {
|
||||
if _, err := f.setBit(i, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -935,7 +935,7 @@ func TestFragment_RankCache_Persistence(t *testing.T) {
|
|||
|
||||
// Set bits on the fragment.
|
||||
for i := uint64(0); i < 1000; i++ {
|
||||
if _, err := f.SetBit(i, 0); err != nil {
|
||||
if _, err := f.setBit(i, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -969,11 +969,11 @@ func TestFragment_WriteTo_ReadFrom(t *testing.T) {
|
|||
defer f0.Close()
|
||||
|
||||
// Set and then clear bits on the fragment.
|
||||
if _, err := f0.SetBit(1000, 1); err != nil {
|
||||
if _, err := f0.setBit(1000, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f0.SetBit(1000, 2); err != nil {
|
||||
} else if _, err := f0.setBit(1000, 2); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f0.ClearBit(1000, 1); err != nil {
|
||||
} else if _, err := f0.clearBit(1000, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -1045,12 +1045,12 @@ func BenchmarkFragment_IntersectionCount(b *testing.B) {
|
|||
|
||||
// Generate some intersecting data.
|
||||
for i := 0; i < 10000; i += 2 {
|
||||
if _, err := f.SetBit(1, uint64(i)); err != nil {
|
||||
if _, err := f.setBit(1, uint64(i)); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
for i := 0; i < 10000; i += 3 {
|
||||
if _, err := f.SetBit(2, uint64(i)); err != nil {
|
||||
if _, err := f.setBit(2, uint64(i)); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -1123,7 +1123,7 @@ func TestFragment_Snapshot_Run(t *testing.T) {
|
|||
|
||||
// Set bits on the fragment.
|
||||
for i := uint64(1); i < 3; i++ {
|
||||
if _, err := f.SetBit(1000, i); err != nil {
|
||||
if _, err := f.setBit(1000, i); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -1273,7 +1273,7 @@ func (f *Fragment) reopen() error {
|
|||
// This function does not accept a timestamp or quantum.
|
||||
func (f *Fragment) mustSetBits(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
if _, err := f.SetBit(rowID, columnID); err != nil {
|
||||
if _, err := f.setBit(rowID, columnID); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,13 +188,13 @@ func TestHandler_MaxSlices(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("i0", "f0", pilosa.ViewStandard, 1).MustSetBits(30, (1*SliceWidth)+1)
|
||||
hldr.MustCreateFragmentIfNotExists("i0", "f0", pilosa.ViewStandard, 1).MustSetBits(30, (1*SliceWidth)+2)
|
||||
hldr.MustCreateFragmentIfNotExists("i0", "f0", pilosa.ViewStandard, 3).MustSetBits(30, (3*SliceWidth)+4)
|
||||
hldr.SetBit("i0", "f0", 30, (1*SliceWidth)+1)
|
||||
hldr.SetBit("i0", "f0", 30, (1*SliceWidth)+2)
|
||||
hldr.SetBit("i0", "f0", 30, (3*SliceWidth)+4)
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("i1", "f1", pilosa.ViewStandard, 0).MustSetBits(40, (0*SliceWidth)+1)
|
||||
hldr.MustCreateFragmentIfNotExists("i1", "f1", pilosa.ViewStandard, 0).MustSetBits(40, (0*SliceWidth)+2)
|
||||
hldr.MustCreateFragmentIfNotExists("i1", "f1", pilosa.ViewStandard, 0).MustSetBits(40, (0*SliceWidth)+8)
|
||||
hldr.SetBit("i1", "f1", 40, (0*SliceWidth)+1)
|
||||
hldr.SetBit("i1", "f1", 40, (0*SliceWidth)+2)
|
||||
hldr.SetBit("i1", "f1", 40, (0*SliceWidth)+8)
|
||||
|
||||
h := test.MustNewHandler()
|
||||
h.API.Holder = hldr.Holder
|
||||
|
|
|
|||
|
|
@ -331,14 +331,8 @@ func TestHolder_DeleteIndex(t *testing.T) {
|
|||
defer hldr.Close()
|
||||
|
||||
// Write bits to separate indexes.
|
||||
f0 := hldr.MustCreateFragmentIfNotExists("i0", "f", pilosa.ViewStandard, 0)
|
||||
if _, err := f0.SetBit(100, 200); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f1 := hldr.MustCreateFragmentIfNotExists("i1", "f", pilosa.ViewStandard, 0)
|
||||
if _, err := f1.SetBit(100, 200); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr.SetBit("i0", "f", 100, 200)
|
||||
hldr.SetBit("i1", "f", 100, 200)
|
||||
|
||||
// Ensure i0 exists.
|
||||
if _, err := os.Stat(hldr.IndexPath("i0")); err != nil {
|
||||
|
|
@ -399,42 +393,23 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set data on the local holder.
|
||||
f := hldr0.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0)
|
||||
if _, err := f.SetBit(0, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(2, 20); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(120, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(200, 4); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr0.SetBit("i", "f", 0, 10)
|
||||
hldr0.SetBit("i", "f", 2, 20)
|
||||
hldr0.SetBit("i", "f", 120, 10)
|
||||
hldr0.SetBit("i", "f", 200, 4)
|
||||
|
||||
f = hldr0.MustCreateFragmentIfNotExists("i", "f0", pilosa.ViewStandard, 1)
|
||||
if _, err := f.SetBit(9, SliceWidth+5); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr0.SetBit("i", "f0", 9, SliceWidth+5)
|
||||
|
||||
hldr0.MustCreateFragmentIfNotExists("y", "z", pilosa.ViewStandard, 0)
|
||||
|
||||
// Set data on the remote holder.
|
||||
f = hldr1.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0)
|
||||
if _, err := f.SetBit(0, 4000); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(3, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(120, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr1.SetBit("i", "f", 0, 4000)
|
||||
hldr1.SetBit("i", "f", 3, 10)
|
||||
hldr1.SetBit("i", "f", 120, 10)
|
||||
|
||||
f = hldr1.MustCreateFragmentIfNotExists("y", "z", pilosa.ViewStandard, 3)
|
||||
if _, err := f.SetBit(10, (3*SliceWidth)+4); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(10, (3*SliceWidth)+5); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(10, (3*SliceWidth)+7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr1.SetBit("y", "z", 10, (3*SliceWidth)+4)
|
||||
hldr1.SetBit("y", "z", 10, (3*SliceWidth)+5)
|
||||
hldr1.SetBit("y", "z", 10, (3*SliceWidth)+7)
|
||||
|
||||
// Set highest slice.
|
||||
hldr0.Index("i").SetRemoteMaxSlice(1)
|
||||
|
|
@ -469,10 +444,6 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
}
|
||||
|
||||
f = hldr.Fragment("i", "f0", pilosa.ViewStandard, 1)
|
||||
a := f.Row(9).Columns()
|
||||
if !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected columns(%d/i/f0): %+v", i, a)
|
||||
}
|
||||
if a := f.Row(9).Columns(); !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected columns(%d/d/f0): %+v", i, a)
|
||||
}
|
||||
|
|
@ -504,34 +475,18 @@ func TestHolderCleaner_CleanHolder(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set data on the local holder.
|
||||
f := hldr0.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0)
|
||||
if _, err := f.SetBit(0, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(0, 4000); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(2, 20); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(3, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(120, 10); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(200, 4); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr0.SetBit("i", "f", 0, 10)
|
||||
hldr0.SetBit("i", "f", 0, 4000)
|
||||
hldr0.SetBit("i", "f", 2, 20)
|
||||
hldr0.SetBit("i", "f", 3, 10)
|
||||
hldr0.SetBit("i", "f", 120, 10)
|
||||
hldr0.SetBit("i", "f", 200, 4)
|
||||
|
||||
f = hldr0.MustCreateFragmentIfNotExists("i", "f0", pilosa.ViewStandard, 1)
|
||||
if _, err := f.SetBit(9, SliceWidth+5); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr0.SetBit("i", "f0", 9, SliceWidth+5)
|
||||
|
||||
f = hldr0.MustCreateFragmentIfNotExists("y", "z", pilosa.ViewStandard, 2)
|
||||
if _, err := f.SetBit(10, (2*SliceWidth)+4); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(10, (2*SliceWidth)+5); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := f.SetBit(10, (2*SliceWidth)+7); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hldr0.SetBit("y", "z", 10, (2*SliceWidth)+4)
|
||||
hldr0.SetBit("y", "z", 10, (2*SliceWidth)+5)
|
||||
hldr0.SetBit("y", "z", 10, (2*SliceWidth)+7)
|
||||
|
||||
// Set highest slice.
|
||||
hldr0.Index("i").SetRemoteMaxSlice(1)
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ func TestMultiStatClient_Expvar(t *testing.T) {
|
|||
ms[0] = c
|
||||
hldr.Stats = ms
|
||||
|
||||
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)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).ClearBit(0, 1)
|
||||
hldr.SetBit("d", "f", 0, 0)
|
||||
hldr.SetBit("d", "f", 0, 1)
|
||||
hldr.SetBit("d", "f", 0, SliceWidth)
|
||||
hldr.SetBit("d", "f", 0, SliceWidth+2)
|
||||
hldr.ClearBit("d", "f", 0, 1)
|
||||
|
||||
if pilosa.Expvar.String() != `{"index:d": {"field:f": {"view:standard": {"slice:0": {"clearBit": 1, "rows": 0, "setBit": 2}, "slice:1": {"rows": 0, "setBit": 2}}}}}` {
|
||||
t.Fatalf("unexpected expvar : %s", pilosa.Expvar.String())
|
||||
|
|
@ -88,10 +88,10 @@ func TestStatsCount_TopN(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
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)
|
||||
hldr.SetBit("d", "f", 0, 0)
|
||||
hldr.SetBit("d", "f", 0, 1)
|
||||
hldr.SetBit("d", "f", 0, SliceWidth)
|
||||
hldr.SetBit("d", "f", 0, SliceWidth+2)
|
||||
|
||||
// Execute query.
|
||||
called := false
|
||||
|
|
@ -121,8 +121,8 @@ func TestStatsCount_Bitmap(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(0, 1)
|
||||
hldr.SetBit("d", "f", 0, 0)
|
||||
hldr.SetBit("d", "f", 0, 1)
|
||||
called := false
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
e.Holder.Stats = &MockStats{
|
||||
|
|
@ -150,8 +150,8 @@ func TestStatsCount_SetColumnAttrs(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
hldr.SetBit("d", "f", 10, 0)
|
||||
hldr.SetBit("d", "f", 10, 1)
|
||||
|
||||
called := false
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
|
|
@ -180,8 +180,8 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 0)
|
||||
hldr.MustCreateFragmentIfNotExists("d", "f", pilosa.ViewStandard, 0).SetBit(10, 1)
|
||||
hldr.SetBit("d", "f", 10, 0)
|
||||
hldr.SetBit("d", "f", 10, 1)
|
||||
|
||||
called := false
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
|
|
|
|||
|
|
@ -26,13 +26,3 @@ type Fragment struct {
|
|||
*pilosa.Fragment
|
||||
RowAttrStore pilosa.AttrStore
|
||||
}
|
||||
|
||||
// MustSetBits sets columns on a row. Panic on error.
|
||||
// This function does not accept a timestamp or quantum.
|
||||
func (f *Fragment) MustSetBits(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
if _, err := f.SetBit(rowID, columnID); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,3 +124,31 @@ func (h *Holder) MustCreateRankedFragmentIfNotExists(index, field, view string,
|
|||
}
|
||||
return &Fragment{Fragment: frag}
|
||||
}
|
||||
|
||||
// SetBit clears a bit on the given field.
|
||||
func (h *Holder) SetBit(index, field string, rowID, columnID uint64) {
|
||||
idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{})
|
||||
f, err := idx.CreateFieldIfNotExists(field, pilosa.FieldOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f.SetBit(pilosa.ViewStandard, rowID, columnID, nil)
|
||||
}
|
||||
|
||||
// ClearBit clears a bit on the given field.
|
||||
func (h *Holder) ClearBit(index, field string, rowID, columnID uint64) {
|
||||
idx := h.MustCreateIndexIfNotExists(index, pilosa.IndexOptions{})
|
||||
f, err := idx.CreateFieldIfNotExists(field, pilosa.FieldOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f.ClearBit(pilosa.ViewStandard, rowID, columnID, nil)
|
||||
}
|
||||
|
||||
// MustSetBits sets columns on a row. Panic on error.
|
||||
// This function does not accept a timestamp or quantum.
|
||||
func (h *Holder) MustSetBits(index, field string, rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
h.SetBit(index, field, rowID, columnID)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
view.go
4
view.go
|
|
@ -310,7 +310,7 @@ func (v *View) SetBit(rowID, columnID uint64) (changed bool, err error) {
|
|||
if err != nil {
|
||||
return changed, err
|
||||
}
|
||||
return frag.SetBit(rowID, columnID)
|
||||
return frag.setBit(rowID, columnID)
|
||||
}
|
||||
|
||||
// ClearBit clears a bit within the view.
|
||||
|
|
@ -320,7 +320,7 @@ func (v *View) ClearBit(rowID, columnID uint64) (changed bool, err error) {
|
|||
if err != nil {
|
||||
return changed, err
|
||||
}
|
||||
return frag.ClearBit(rowID, columnID)
|
||||
return frag.clearBit(rowID, columnID)
|
||||
}
|
||||
|
||||
// value uses a column of bits to read a multi-bit value.
|
||||
|
|
|
|||
10
view_test.go
10
view_test.go
|
|
@ -72,16 +72,6 @@ func (v *View) Reopen() error {
|
|||
return v.Open()
|
||||
}
|
||||
|
||||
// MustSetBits sets columns on a row. Panic on error.
|
||||
// This function does not accept a timestamp or quantum.
|
||||
func (v *View) MustSetBits(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
if _, err := v.SetBit(rowID, columnID); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MustClearColumns clears columns on a row. Panic on error.
|
||||
func (v *View) MustClearBits(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue