revert to old labels on BSI; revert MustSetColumns

This commit is contained in:
Todd Gruben 2018-05-24 12:48:24 -05:00
parent de4de2ba2e
commit e3da6efe3c
12 changed files with 299 additions and 299 deletions

View file

@ -279,15 +279,15 @@ func (c *InternalHTTPClient) QueryNode(ctx context.Context, uri *URI, index stri
return qresp, nil
}
// Import bulk imports columns for a single slice to a host.
func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, slice uint64, columns []Bit) error {
// Import bulk imports bits for a single slice to a host.
func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, slice uint64, bits []Bit) error {
if index == "" {
return ErrIndexRequired
} else if frame == "" {
return ErrFrameRequired
}
buf, err := marshalImportPayload(index, frame, slice, columns)
buf, err := marshalImportPayload(index, frame, slice, bits)
if err != nil {
return fmt.Errorf("Error Creating Payload: %s", err)
}
@ -350,11 +350,11 @@ func (c *InternalHTTPClient) EnsureFrame(ctx context.Context, indexName string,
}
// marshalImportPayload marshalls the import parameters into a protobuf byte slice.
func marshalImportPayload(index, frame string, slice uint64, columns []Bit) ([]byte, error) {
func marshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte, error) {
// Separate row and column IDs to reduce allocations.
rowIDs := Columns(columns).RowIDs()
columnIDs := Columns(columns).ColumnIDs()
timestamps := Columns(columns).Timestamps()
rowIDs := Bits(bits).RowIDs()
columnIDs := Bits(bits).ColumnIDs()
timestamps := Bits(bits).Timestamps()
// Marshal columns to protobufs.
buf, err := proto.Marshal(&internal.ImportRequest{
@ -372,11 +372,11 @@ func marshalImportPayload(index, frame string, slice uint64, columns []Bit) ([]b
}
// marshalImportPayloadK marshalls the import parameters into a protobuf byte slice.
func marshalImportPayloadK(index, frame string, columns []Bit) ([]byte, error) {
func marshalImportPayloadK(index, frame string, bits []Bit) ([]byte, error) {
// Separate row and column IDs to reduce allocations.
rowKeys := Columns(columns).RowKeys()
columnKeys := Columns(columns).ColumnKeys()
timestamps := Columns(columns).Timestamps()
rowKeys := Bits(bits).RowKeys()
columnKeys := Bits(bits).ColumnKeys()
timestamps := Bits(bits).Timestamps()
// Marshal columns to protobufs.
buf, err := proto.Marshal(&internal.ImportRequest{
@ -1140,7 +1140,7 @@ func (c *InternalHTTPClient) SendMessage(ctx context.Context, uri *URI, pb proto
return nil
}
// Bit represents the location of a single column.
// Bit represents the location of a the intersection of a row and a column.
type Bit struct {
RowID uint64
ColumnID uint64
@ -1149,13 +1149,13 @@ type Bit struct {
Timestamp int64
}
// Columns represents a slice of columns.
type Columns []Bit
// Bits represents a slice of Bit.
type Bits []Bit
func (p Columns) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p Columns) Len() int { return len(p) }
func (p Bits) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p Bits) Len() int { return len(p) }
func (p Columns) Less(i, j int) bool {
func (p Bits) Less(i, j int) bool {
if p[i].RowID == p[j].RowID {
if p[i].ColumnID < p[j].ColumnID {
return p[i].Timestamp < p[j].Timestamp
@ -1166,7 +1166,7 @@ func (p Columns) Less(i, j int) bool {
}
// RowIDs returns a slice of all the row IDs.
func (p Columns) RowIDs() []uint64 {
func (p Bits) RowIDs() []uint64 {
other := make([]uint64, len(p))
for i := range p {
other[i] = p[i].RowID
@ -1175,7 +1175,7 @@ func (p Columns) RowIDs() []uint64 {
}
// ColumnIDs returns a slice of all the column IDs.
func (p Columns) ColumnIDs() []uint64 {
func (p Bits) ColumnIDs() []uint64 {
other := make([]uint64, len(p))
for i := range p {
other[i] = p[i].ColumnID
@ -1184,7 +1184,7 @@ func (p Columns) ColumnIDs() []uint64 {
}
// RowKeys returns a slice of all the row keys.
func (p Columns) RowKeys() []string {
func (p Bits) RowKeys() []string {
other := make([]string, len(p))
for i := range p {
other[i] = p[i].RowKey
@ -1193,7 +1193,7 @@ func (p Columns) RowKeys() []string {
}
// ColumnKeys returns a slice of all the column keys.
func (p Columns) ColumnKeys() []string {
func (p Bits) ColumnKeys() []string {
other := make([]string, len(p))
for i := range p {
other[i] = p[i].ColumnKey
@ -1202,7 +1202,7 @@ func (p Columns) ColumnKeys() []string {
}
// Timestamps returns a slice of all the timestamps.
func (p Columns) Timestamps() []int64 {
func (p Bits) Timestamps() []int64 {
other := make([]int64, len(p))
for i := range p {
other[i] = p[i].Timestamp
@ -1211,7 +1211,7 @@ func (p Columns) Timestamps() []int64 {
}
// GroupBySlice returns a map of columns by slice.
func (p Columns) GroupBySlice() map[uint64][]Bit {
func (p Bits) GroupBySlice() map[uint64][]Bit {
m := make(map[uint64][]Bit)
for _, column := range p {
slice := column.ColumnID / SliceWidth
@ -1219,7 +1219,7 @@ func (p Columns) GroupBySlice() map[uint64][]Bit {
}
for slice, columns := range m {
sort.Sort(Columns(columns))
sort.Sort(Bits(columns))
m[slice] = columns
}
@ -1277,12 +1277,12 @@ func (p FieldValues) GroupBySlice() map[uint64][]FieldValue {
return m
}
// ColumnsByPos represents a slice of columns sorted by internal position.
type ColumnsByPos []Bit
// BitsByPos represents a slice of columns sorted by internal position.
type BitsByPos []Bit
func (p ColumnsByPos) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p ColumnsByPos) Len() int { return len(p) }
func (p ColumnsByPos) Less(i, j int) bool {
func (p BitsByPos) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p BitsByPos) Len() int { return len(p) }
func (p BitsByPos) Less(i, j int) bool {
p0, p1 := Pos(p[i].RowID, p[i].ColumnID), Pos(p[j].RowID, p[j].ColumnID)
if p0 == p1 {
return p[i].Timestamp < p[j].Timestamp
@ -1320,8 +1320,8 @@ type InternalClient interface {
FragmentNodes(ctx context.Context, index string, slice uint64) ([]*Node, error)
Query(ctx context.Context, index string, queryRequest *internal.QueryRequest) (*internal.QueryResponse, error)
QueryNode(ctx context.Context, uri *URI, index string, queryRequest *internal.QueryRequest) (*internal.QueryResponse, error)
Import(ctx context.Context, index, frame string, slice uint64, columns []Bit) error
ImportK(ctx context.Context, index, frame string, columns []Bit) error
Import(ctx context.Context, index, frame string, slice uint64, bits []Bit) error
ImportK(ctx context.Context, index, frame string, bits []Bit) error
EnsureIndex(ctx context.Context, name string, options IndexOptions) error
EnsureFrame(ctx context.Context, indexName string, frameName string, options FrameOptions) error
ImportValue(ctx context.Context, index, frame, field string, slice uint64, vals []FieldValue) error

View file

@ -110,26 +110,26 @@ func TestClient_MultiNode(t *testing.T) {
}
}
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetColumns(100, baseBit0+10)
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetColumns(4, baseBit0+10, baseBit0+11, baseBit0+12)
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetColumns(4, baseBit0+10, baseBit0+11, baseBit0+12, baseBit0+13, baseBit0+14, baseBit0+15)
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetColumns(2, baseBit0+1, baseBit0+2, baseBit0+3, baseBit0+4)
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetColumns(3, baseBit0+1, baseBit0+2, baseBit0+3, baseBit0+4, baseBit0+5)
hldr[0].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[0]).MustSetColumns(22, baseBit0+1, baseBit0+2, baseBit0+10)
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[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetColumns(99, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4)
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetColumns(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]).MustSetColumns(98, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5, baseBit1+6)
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetColumns(1, baseBit1+4)
hldr[1].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[1]).MustSetColumns(22, baseBit1+1, baseBit1+2, baseBit1+3, baseBit1+4, baseBit1+5)
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[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetColumns(24, baseBit2+10, baseBit2+11, baseBit2+12, baseBit2+13, baseBit2+14)
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetColumns(20, baseBit2+10, baseBit2+11, baseBit2+12, baseBit2+13)
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetColumns(21, baseBit2+10)
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetColumns(100, baseBit2+10)
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetColumns(99, baseBit2+10, baseBit2+11, baseBit2+12)
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetColumns(98, baseBit2+10, baseBit2+11)
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).MustSetColumns(22, baseBit2+10, baseBit2+11, baseBit2+12)
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)
// Rebuild the RankCache.
// We have to do this to avoid the 10-second cache invalidation delay
@ -375,10 +375,10 @@ func TestClient_BackupRestore(t *testing.T) {
hldr := test.MustOpenHolder()
defer hldr.Close()
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).MustSetColumns(100, 1, 2, 3, SliceWidth-1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetColumns(100, SliceWidth, SliceWidth+2)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 5).MustSetColumns(100, (5*SliceWidth)+1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).MustSetColumns(200, 20000)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).MustSetBits(100, 1, 2, 3, SliceWidth-1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetBits(100, SliceWidth, SliceWidth+2)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 5).MustSetBits(100, (5*SliceWidth)+1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).MustSetBits(200, 20000)
s := test.NewServer()
defer s.Close()
@ -479,7 +479,7 @@ func TestClient_BackupInvalidView(t *testing.T) {
hldr := test.MustOpenHolder()
defer hldr.Close()
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).MustSetColumns(100, 1, 2, 3, SliceWidth-1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).MustSetBits(100, 1, 2, 3, SliceWidth-1)
s := test.NewServer()
defer s.Close()

View file

@ -228,21 +228,21 @@ func (cmd *ImportCommand) bufferColumns(ctx context.Context, path string) error
}
// importColumns sends batches of columns to the server.
func (cmd *ImportCommand) importColumns(ctx context.Context, columns []pilosa.Bit) error {
func (cmd *ImportCommand) importColumns(ctx context.Context, bits []pilosa.Bit) error {
logger := log.New(cmd.Stderr, "", log.LstdFlags)
// Group columns by slice.
logger.Printf("grouping %d columns", len(columns))
columnsBySlice := pilosa.Columns(columns).GroupBySlice()
logger.Printf("grouping %d columns", len(bits))
bitsBySlice := pilosa.Bits(bits).GroupBySlice()
// Parse path into columns.
for slice, columns := range columnsBySlice {
for slice, chunk := range bitsBySlice {
if cmd.Sort {
sort.Sort(pilosa.ColumnsByPos(columns))
sort.Sort(pilosa.BitsByPos(chunk))
}
logger.Printf("importing slice: %d, n=%d", slice, len(columns))
if err := cmd.Client.Import(ctx, cmd.Index, cmd.Frame, slice, columns); err != nil {
logger.Printf("importing slice: %d, n=%d", slice, len(chunk))
if err := cmd.Client.Import(ctx, cmd.Index, cmd.Frame, slice, chunk); err != nil {
return errors.Wrap(err, "importing")
}
}

View file

@ -1319,7 +1319,7 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql.
if err := frame.RowAttrStore().SetAttrs(rowID, attrs); err != nil {
return err
}
frame.Stats.Count("SetColumnAttrs", 1, 1.0)
frame.Stats.Count("SetRowAttrs", 1, 1.0)
// Do not forward call if this is already being forwarded.
if opt.Remote {

View file

@ -54,8 +54,8 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, nil); err != nil {
t.Fatal(err)
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{3, SliceWidth + 1}) {
t.Fatalf("unexpected columns: %+v", columns)
} else if bits := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(bits, []uint64{3, SliceWidth + 1}) {
t.Fatalf("unexpected columns: %+v", bits)
} else if attrs := res[0].(*pilosa.Row).Attrs; !reflect.DeepEqual(attrs, map[string]interface{}{"foo": "bar", "baz": int64(123)}) {
t.Fatalf("unexpected attrs: %s", spew.Sdump(attrs))
}
@ -115,11 +115,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).MustSetColumns(10, 1)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(10, 2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(10, 3)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(11, 2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(11, 4)
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)
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 {
@ -133,7 +133,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).MustSetColumns(10, 1)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(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 {
@ -145,13 +145,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).MustSetColumns(10, 1)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+1)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+2)
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.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(11, 1)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(11, 2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(11, 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)
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 {
@ -176,12 +176,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).MustSetColumns(10, 0)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+1)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+2)
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.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(11, 2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(11, SliceWidth+2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(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 {
@ -195,7 +195,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).MustSetColumns(10, 0)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(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 {
@ -209,12 +209,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).MustSetColumns(10, 0)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+1)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+2)
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.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetColumns(11, 2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetColumns(11, SliceWidth+2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 0).MustSetBits(11, 2)
hldr.MustCreateFragmentIfNotExists("i", "general", pilosa.ViewStandard, 1).MustSetBits(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 {
@ -228,9 +228,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).MustSetColumns(10, 3)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetColumns(10, SliceWidth+2)
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)
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, frame=f))`), nil, nil); err != nil {
@ -1013,7 +1013,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).MustSetColumns(10, (1*SliceWidth)+1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).MustSetBits(10, (1*SliceWidth)+1)
e := test.NewExecutor(hldr.Holder, c)
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, nil); err != nil {
@ -1047,8 +1047,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).MustSetColumns(10, (2*SliceWidth)+1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetColumns(10, (2*SliceWidth)+2)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetBits(10, (2*SliceWidth)+1)
hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetBits(10, (2*SliceWidth)+2)
e := test.NewExecutor(hldr.Holder, c)
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, frame=f))`), nil, nil); err != nil {
@ -1216,8 +1216,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).MustSetColumns(30, (2*SliceWidth)+1)
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 4).MustSetColumns(30, (4*SliceWidth)+2)
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 2).MustSetBits(30, (2*SliceWidth)+1)
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 4).MustSetBits(30, (4*SliceWidth)+2)
e := test.NewExecutor(hldr.Holder, c)
if res, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(frame=f, n=3)`), nil, nil); err != nil {

View file

@ -478,7 +478,7 @@ func (f *Fragment) clearBit(rowID, columnID uint64) (changed bool, err error) {
return changed, nil
}
func (f *Fragment) column(rowID, columnID uint64) (bool, error) {
func (f *Fragment) bit(rowID, columnID uint64) (bool, error) {
pos, err := f.pos(rowID, columnID)
if err != nil {
return false, err
@ -486,22 +486,22 @@ func (f *Fragment) column(rowID, columnID uint64) (bool, error) {
return f.storage.Contains(pos), nil
}
// FieldValue uses a column of columns to read a multi-column value.
func (f *Fragment) FieldValue(columnID uint64, columnDepth uint) (value uint64, exists bool, err error) {
// FieldValue uses a column of bits to read a multi-bit value.
func (f *Fragment) FieldValue(columnID uint64, bitDepth uint) (value uint64, exists bool, err error) {
f.mu.Lock()
defer f.mu.Unlock()
// If existence column is unset then ignore remaining columns.
if v, err := f.column(uint64(columnDepth), columnID); err != nil {
return 0, false, errors.Wrap(err, "getting existence column")
// If existence bit is unset then ignore remaining bits.
if v, err := f.bit(uint64(bitDepth), columnID); err != nil {
return 0, false, errors.Wrap(err, "getting existence bit")
} else if !v {
return 0, false, nil
}
// Compute other columns into a value.
for i := uint(0); i < columnDepth; i++ {
if v, err := f.column(uint64(i), columnID); err != nil {
return 0, false, errors.Wrapf(err, "getting value column %d", i)
// Compute other bits into a value.
for i := uint(0); i < bitDepth; i++ {
if v, err := f.bit(uint64(i), columnID); err != nil {
return 0, false, errors.Wrapf(err, "getting value bit %d", i)
} else if v {
value |= (1 << i)
}
@ -510,12 +510,12 @@ func (f *Fragment) FieldValue(columnID uint64, columnDepth uint) (value uint64,
return value, true, nil
}
// SetFieldValue uses a column of columns to set a multi-column value.
func (f *Fragment) SetFieldValue(columnID uint64, columnDepth uint, value uint64) (changed bool, err error) {
// SetFieldValue uses a column of bits to set a multi-bit value.
func (f *Fragment) SetFieldValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) {
f.mu.Lock()
defer f.mu.Unlock()
for i := uint(0); i < columnDepth; i++ {
for i := uint(0); i < bitDepth; i++ {
if value&(1<<i) != 0 {
if c, err := f.setBit(uint64(i), columnID); err != nil {
return changed, err
@ -532,7 +532,7 @@ func (f *Fragment) SetFieldValue(columnID uint64, columnDepth uint, value uint64
}
// Mark value as set.
if c, err := f.setBit(uint64(columnDepth), columnID); err != nil {
if c, err := f.setBit(uint64(bitDepth), columnID); err != nil {
return changed, errors.Wrap(err, "marking not-null")
} else if c {
changed = true
@ -542,25 +542,25 @@ func (f *Fragment) SetFieldValue(columnID uint64, columnDepth uint, value uint64
}
// importSetFieldValue is a more efficient SetFieldValue just for imports.
func (f *Fragment) importSetFieldValue(columnID uint64, columnDepth uint, value uint64) (changed bool, err error) {
func (f *Fragment) importSetFieldValue(columnID uint64, bitDepth uint, value uint64) (changed bool, err error) {
for i := uint(0); i < columnDepth; i++ {
for i := uint(0); i < bitDepth; i++ {
if value&(1<<i) != 0 {
column, err := f.pos(uint64(i), columnID)
bit, err := f.pos(uint64(i), columnID)
if err != nil {
return changed, errors.Wrap(err, "getting set pos")
}
if c, err := f.storage.Add(column); err != nil {
if c, err := f.storage.Add(bit); err != nil {
return changed, errors.Wrap(err, "adding")
} else if c {
changed = true
}
} else {
column, err := f.pos(uint64(i), columnID)
bit, err := f.pos(uint64(i), columnID)
if err != nil {
return changed, errors.Wrap(err, "getting clear pos")
}
if c, err := f.storage.Remove(column); err != nil {
if c, err := f.storage.Remove(bit); err != nil {
return changed, errors.Wrap(err, "removing")
} else if c {
changed = true
@ -569,7 +569,7 @@ func (f *Fragment) importSetFieldValue(columnID uint64, columnDepth uint, value
}
// Mark value as set.
p, err := f.pos(uint64(columnDepth), columnID)
p, err := f.pos(uint64(bitDepth), columnID)
if err != nil {
return changed, errors.Wrap(err, "marking not-null")
}
@ -582,25 +582,25 @@ func (f *Fragment) importSetFieldValue(columnID uint64, columnDepth uint, value
return changed, nil
}
// FieldSum returns the sum of a given field as well as the number of columns involved.
// FieldSum returns the sum of a given field as well as the number of bits involved.
// A bitmap can be passed in to optionally filter the computed columns.
func (f *Fragment) FieldSum(filter *Row, columnDepth uint) (sum, count uint64, err error) {
func (f *Fragment) FieldSum(filter *Row, bitDepth uint) (sum, count uint64, err error) {
// Compute count based on the existence column.
row := f.Row(uint64(columnDepth))
row := f.Row(uint64(bitDepth))
if filter != nil {
count = row.IntersectionCount(filter)
} else {
count = row.Count()
}
// Compute the sum based on the column count of each row multiplied by the
// place value of each row. For example, 10 columns in the 1's place plus
// 4 columns in the 2's place plus 3 columns in the 4's place equals a total
// Compute the sum based on the bit count of each row multiplied by the
// place value of each row. For example, 10 bits in the 1's place plus
// 4 bits in the 2's place plus 3 bits in the 4's place equals a total
// sum of 30:
//
// 10*(2^0) + 4*(2^1) + 3*(2^2) = 30
//
for i := uint(0); i < columnDepth; i++ {
for i := uint(0); i < bitDepth; i++ {
row := f.Row(uint64(i))
cnt := uint64(0)
if filter != nil {
@ -614,11 +614,11 @@ func (f *Fragment) FieldSum(filter *Row, columnDepth uint) (sum, count uint64, e
return sum, count, nil
}
// FieldMin returns the min of a given field as well as the number of columns involved.
// FieldMin returns the min of a given field as well as the number of bits involved.
// A bitmap can be passed in to optionally filter the computed columns.
func (f *Fragment) FieldMin(filter *Row, columnDepth uint) (min, count uint64, err error) {
func (f *Fragment) FieldMin(filter *Row, bitDepth uint) (min, count uint64, err error) {
consider := f.Row(uint64(columnDepth))
consider := f.Row(uint64(bitDepth))
if filter != nil {
consider = consider.Intersect(filter)
}
@ -628,8 +628,8 @@ func (f *Fragment) FieldMin(filter *Row, columnDepth uint) (min, count uint64, e
return 0, 0, nil
}
for i := columnDepth; i > uint(0); i-- {
ii := i - 1 // allow for uint range: (columndepth-1) to 0
for i := bitDepth; i > uint(0); i-- {
ii := i - 1 // allow for uint range: (bitDepth-1) to 0
row := f.Row(uint64(ii))
x := consider.Difference(row)
@ -647,21 +647,21 @@ func (f *Fragment) FieldMin(filter *Row, columnDepth uint) (min, count uint64, e
return min, count, nil
}
// FieldMax returns the max of a given field as well as the number of columns involved.
// A bitmap can be passed in to optionally filter the computed columns.
func (f *Fragment) FieldMax(filter *Row, columnDepth uint) (max, count uint64, err error) {
// FieldMax returns the max of a given field as well as the number of bits involved.
// A bitmap can be passed in to optionally filter the computed bits.
func (f *Fragment) FieldMax(filter *Row, bitDepth uint) (max, count uint64, err error) {
consider := f.Row(uint64(columnDepth))
consider := f.Row(uint64(bitDepth))
if filter != nil {
consider = consider.Intersect(filter)
}
// If there are no columns to consider, return early.
// If there are no bits to consider, return early.
if consider.Count() == 0 {
return 0, 0, nil
}
for i := columnDepth; i > uint(0); i-- {
for i := bitDepth; i > uint(0); i-- {
ii := i - 1 // allow for uint range: (columndepth-1) to 0
row := f.Row(uint64(ii))
@ -679,31 +679,31 @@ func (f *Fragment) FieldMax(filter *Row, columnDepth uint) (max, count uint64, e
}
// FieldRange returns bitmaps with a field value encoding matching the predicate.
func (f *Fragment) FieldRange(op pql.Token, columnDepth uint, predicate uint64) (*Row, error) {
func (f *Fragment) FieldRange(op pql.Token, bitDepth uint, predicate uint64) (*Row, error) {
switch op {
case pql.EQ:
return f.fieldRangeEQ(columnDepth, predicate)
return f.fieldRangeEQ(bitDepth, predicate)
case pql.NEQ:
return f.fieldRangeNEQ(columnDepth, predicate)
return f.fieldRangeNEQ(bitDepth, predicate)
case pql.LT, pql.LTE:
return f.fieldRangeLT(columnDepth, predicate, op == pql.LTE)
return f.fieldRangeLT(bitDepth, predicate, op == pql.LTE)
case pql.GT, pql.GTE:
return f.fieldRangeGT(columnDepth, predicate, op == pql.GTE)
return f.fieldRangeGT(bitDepth, predicate, op == pql.GTE)
default:
return nil, ErrInvalidRangeOperation
}
}
func (f *Fragment) fieldRangeEQ(columnDepth uint, predicate uint64) (*Row, error) {
func (f *Fragment) fieldRangeEQ(bitDepth uint, predicate uint64) (*Row, error) {
// Start with set of columns with values set.
b := f.Row(uint64(columnDepth))
b := f.Row(uint64(bitDepth))
// Filter any columns that don't match the current column value.
for i := int(columnDepth - 1); i >= 0; i-- {
for i := int(bitDepth - 1); i >= 0; i-- {
row := f.Row(uint64(i))
column := (predicate >> uint(i)) & 1
bit := (predicate >> uint(i)) & 1
if column == 1 {
if bit == 1 {
b = b.Intersect(row)
} else {
b = b.Difference(row)
@ -713,12 +713,12 @@ func (f *Fragment) fieldRangeEQ(columnDepth uint, predicate uint64) (*Row, error
return b, nil
}
func (f *Fragment) fieldRangeNEQ(columnDepth uint, predicate uint64) (*Row, error) {
func (f *Fragment) fieldRangeNEQ(bitDepth uint, predicate uint64) (*Row, error) {
// Start with set of columns with values set.
b := f.Row(uint64(columnDepth))
b := f.Row(uint64(bitDepth))
// Get the equal bitmap.
eq, err := f.fieldRangeEQ(columnDepth, predicate)
eq, err := f.fieldRangeEQ(bitDepth, predicate)
if err != nil {
return nil, err
}
@ -729,21 +729,21 @@ func (f *Fragment) fieldRangeNEQ(columnDepth uint, predicate uint64) (*Row, erro
return b, nil
}
func (f *Fragment) fieldRangeLT(columnDepth uint, predicate uint64, allowEquality bool) (*Row, error) {
func (f *Fragment) fieldRangeLT(bitDepth uint, predicate uint64, allowEquality bool) (*Row, error) {
keep := NewRow()
// Start with set of columns with values set.
b := f.Row(uint64(columnDepth))
b := f.Row(uint64(bitDepth))
// Filter any columns that don't match the current column value.
leadingZeros := true
for i := int(columnDepth - 1); i >= 0; i-- {
for i := int(bitDepth - 1); i >= 0; i-- {
row := f.Row(uint64(i))
column := (predicate >> uint(i)) & 1
bit := (predicate >> uint(i)) & 1
// Remove any columns with higher columns set.
if leadingZeros {
if column == 0 {
if bit == 0 {
b = b.Difference(row)
continue
} else {
@ -755,19 +755,19 @@ func (f *Fragment) fieldRangeLT(columnDepth uint, predicate uint64, allowEqualit
// If column is zero then return only already kept columns.
// If column is one then remove any one columns.
if i == 0 && !allowEquality {
if column == 0 {
if bit == 0 {
return keep, nil
}
return b.Difference(row.Difference(keep)), nil
}
// If column is zero then remove all set columns not in excluded bitmap.
if column == 0 {
// If bit is zero then remove all set columns not in excluded bitmap.
if bit == 0 {
b = b.Difference(row.Difference(keep))
continue
}
// If column is set then add columns for set columns to exclude.
// If bit is set then add bits for set bits to exclude.
// Don't bother to compute this on the final iteration.
if i > 0 {
keep = keep.Union(b.Difference(row))
@ -777,32 +777,32 @@ func (f *Fragment) fieldRangeLT(columnDepth uint, predicate uint64, allowEqualit
return b, nil
}
func (f *Fragment) fieldRangeGT(columnDepth uint, predicate uint64, allowEquality bool) (*Row, error) {
b := f.Row(uint64(columnDepth))
func (f *Fragment) fieldRangeGT(bitDepth uint, predicate uint64, allowEquality bool) (*Row, error) {
b := f.Row(uint64(bitDepth))
keep := NewRow()
// Filter any columns that don't match the current column value.
for i := int(columnDepth - 1); i >= 0; i-- {
for i := int(bitDepth - 1); i >= 0; i-- {
row := f.Row(uint64(i))
column := (predicate >> uint(i)) & 1
bit := (predicate >> uint(i)) & 1
// Handle last column differently.
// If column is one then return only already kept columns.
// If column is zero then remove any unset columns.
// Handle last bit differently.
// If bit is one then return only already kept bits.
// If bit is zero then remove any unset bits.
if i == 0 && !allowEquality {
if column == 1 {
if bit == 1 {
return keep, nil
}
return b.Difference(b.Difference(row).Difference(keep)), nil
}
// If column is set then remove all unset columns not already kept.
if column == 1 {
// If bit is set then remove all unset bits not already kept.
if bit == 1 {
b = b.Difference(b.Difference(row).Difference(keep))
continue
}
// If column is unset then add columns with set column to keep.
// If bit is unset then add bits with set bit to keep.
// Don't bother to compute this on the final iteration.
if i > 0 {
keep = keep.Union(b.Intersect(row))
@ -812,29 +812,29 @@ func (f *Fragment) fieldRangeGT(columnDepth uint, predicate uint64, allowEqualit
return b, nil
}
// FieldNotNull returns the not-null row (stored at columnDepth).
func (f *Fragment) FieldNotNull(columnDepth uint) (*Row, error) {
return f.Row(uint64(columnDepth)), nil
// FieldNotNull returns the not-null row (stored at bitDepth).
func (f *Fragment) FieldNotNull(bitDepth uint) (*Row, error) {
return f.Row(uint64(bitDepth)), nil
}
// FieldRangeBetween returns bitmaps with a field value encoding matching any value between predicateMin and predicateMax.
func (f *Fragment) FieldRangeBetween(columnDepth uint, predicateMin, predicateMax uint64) (*Row, error) {
b := f.Row(uint64(columnDepth))
func (f *Fragment) FieldRangeBetween(bitDepth uint, predicateMin, predicateMax uint64) (*Row, error) {
b := f.Row(uint64(bitDepth))
keep1 := NewRow() // GTE
keep2 := NewRow() // LTE
// Filter any columns that don't match the current column value.
for i := int(columnDepth - 1); i >= 0; i-- {
for i := int(bitDepth - 1); i >= 0; i-- {
row := f.Row(uint64(i))
column1 := (predicateMin >> uint(i)) & 1
column2 := (predicateMax >> uint(i)) & 1
bit1 := (predicateMin >> uint(i)) & 1
bit2 := (predicateMax >> uint(i)) & 1
// GTE predicateMin
// If column is set then remove all unset columns not already kept.
if column1 == 1 {
// If bit is set then remove all unset bits not already kept.
if bit1 == 1 {
b = b.Difference(b.Difference(row).Difference(keep1))
} else {
// If column is unset then add columns with set column to keep.
// If bit is unset then add bits with set bit to keep.
// Don't bother to compute this on the final iteration.
if i > 0 {
keep1 = keep1.Union(b.Intersect(row))
@ -842,11 +842,11 @@ func (f *Fragment) FieldRangeBetween(columnDepth uint, predicateMin, predicateMa
}
// LTE predicateMin
// If column is zero then remove all set columns not in excluded bitmap.
if column2 == 0 {
// If bit is zero then remove all set bits not in excluded bitmap.
if bit2 == 0 {
b = b.Difference(row.Difference(keep2))
} else {
// If column is set then add columns for set columns to exclude.
// If bit is set then add bits for set bits to exclude.
// Don't bother to compute this on the final iteration.
if i > 0 {
keep2 = keep2.Union(b.Difference(row))
@ -867,7 +867,7 @@ func (f *Fragment) pos(rowID, columnID uint64) (uint64, error) {
return Pos(rowID, columnID), nil
}
// ForEachBit executes fn for every column set in the fragment.
// ForEachBit executes fn for every bit set in the fragment.
// Errors returned from fn are passed through.
func (f *Fragment) ForEachBit(fn func(rowID, columnID uint64) error) error {
f.mu.Lock()

View file

@ -38,12 +38,12 @@ var (
// SliceWidth is a helper reference to use when testing.
const SliceWidth = pilosa.SliceWidth
// Ensure a fragment can set a column and retrieve it.
// Ensure a fragment can set a bit and retrieve it.
func TestFragment_SetBit(t *testing.T) {
f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "")
defer f.Close()
// Set columns on the fragment.
// Set bits on the fragment.
if _, err := f.SetBit(120, 1); err != nil {
t.Fatal(err)
} else if _, err := f.SetBit(120, 6); err != nil {
@ -69,12 +69,12 @@ func TestFragment_SetBit(t *testing.T) {
}
}
// Ensure a fragment can clear a set column.
// Ensure a fragment can clear a set bits.
func TestFragment_ClearBit(t *testing.T) {
f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "")
defer f.Close()
// Set and then clear columns on the fragment.
// Set and then clear bits on the fragment.
if _, err := f.SetBit(1000, 1); err != nil {
t.Fatal(err)
} else if _, err := f.SetBit(1000, 2); err != nil {
@ -137,7 +137,7 @@ func TestFragment_SetFieldValue(t *testing.T) {
t.Fatal("expected change")
}
// Overwriting value should overwrite all columns.
// Overwriting value should overwrite all bits.
if changed, err := f.SetFieldValue(100, 16, 2028); err != nil {
t.Fatal(err)
} else if !changed {
@ -176,13 +176,13 @@ func TestFragment_SetFieldValue(t *testing.T) {
})
t.Run("QuickCheck", func(t *testing.T) {
if err := quick.Check(func(columnDepth uint, columnN uint64, values []uint64) bool {
// Limit column depth & maximum values.
columnDepth = (columnDepth % 62) + 1
columnN = (columnN % 99) + 1
if err := quick.Check(func(bitDepth uint, bitN uint64, values []uint64) bool {
// Limit bit depth & maximum values.
bitDepth = (bitDepth % 62) + 1
bitN = (bitN % 99) + 1
for i := range values {
values[i] = values[i] % (1 << columnDepth)
values[i] = values[i] % (1 << bitDepth)
}
f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "")
@ -191,24 +191,24 @@ func TestFragment_SetFieldValue(t *testing.T) {
// Set values.
m := make(map[uint64]int64)
for _, value := range values {
columnID := value % columnN
bit_index := value % bitN
m[columnID] = int64(value)
m[bit_index] = int64(value)
if _, err := f.SetFieldValue(columnID, columnDepth, value); err != nil {
if _, err := f.SetFieldValue(bit_index, bitDepth, value); err != nil {
t.Fatal(err)
}
}
// Ensure values are set.
for columnID, value := range m {
v, exists, err := f.FieldValue(columnID, columnDepth)
for bit_index, value := range m {
v, exists, err := f.FieldValue(bit_index, bitDepth)
if err != nil {
t.Fatal(err)
} else if value != int64(v) {
t.Fatalf("value mismatch: column=%d, columndepth=%d, value: %d != %d", columnID, columnDepth, value, v)
t.Fatalf("value mismatch: bit_index=%d, bitdepth=%d, value: %d != %d", bit_index, bitDepth, value, v)
} else if !exists {
t.Fatalf("value should exist: column=%d", columnID)
t.Fatalf("value should exist: bit_index=%d", bit_index)
}
}
@ -221,24 +221,24 @@ func TestFragment_SetFieldValue(t *testing.T) {
// Ensure a fragment can sum field values.
func TestFragment_FieldSum(t *testing.T) {
const columnDepth = 16
const bitDepth = 16
f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "")
defer f.Close()
// Set values.
if _, err := f.SetFieldValue(1000, columnDepth, 382); err != nil {
if _, err := f.SetFieldValue(1000, bitDepth, 382); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(2000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(2000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(3000, columnDepth, 2818); err != nil {
} else if _, err := f.SetFieldValue(3000, bitDepth, 2818); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(4000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(4000, bitDepth, 300); err != nil {
t.Fatal(err)
}
t.Run("NoFilter", func(t *testing.T) {
if sum, n, err := f.FieldSum(nil, columnDepth); err != nil {
if sum, n, err := f.FieldSum(nil, bitDepth); err != nil {
t.Fatal(err)
} else if n != 4 {
t.Fatalf("unexpected count: %d", n)
@ -248,7 +248,7 @@ func TestFragment_FieldSum(t *testing.T) {
})
t.Run("WithFilter", func(t *testing.T) {
if sum, n, err := f.FieldSum(pilosa.NewRow(2000, 4000, 5000), columnDepth); err != nil {
if sum, n, err := f.FieldSum(pilosa.NewRow(2000, 4000, 5000), bitDepth); err != nil {
t.Fatal(err)
} else if n != 2 {
t.Fatalf("unexpected count: %d", n)
@ -260,25 +260,25 @@ func TestFragment_FieldSum(t *testing.T) {
// Ensure a fragment can find the min and max of field values.
func TestFragment_FieldMinMax(t *testing.T) {
const columnDepth = 16
const bitDepth = 16
f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "")
defer f.Close()
// Set values.
if _, err := f.SetFieldValue(1000, columnDepth, 382); err != nil {
if _, err := f.SetFieldValue(1000, bitDepth, 382); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(2000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(2000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(3000, columnDepth, 2818); err != nil {
} else if _, err := f.SetFieldValue(3000, bitDepth, 2818); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(4000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(4000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(5000, columnDepth, 2818); err != nil {
} else if _, err := f.SetFieldValue(5000, bitDepth, 2818); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(6000, columnDepth, 2817); err != nil {
} else if _, err := f.SetFieldValue(6000, bitDepth, 2817); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(7000, columnDepth, 0); err != nil {
} else if _, err := f.SetFieldValue(7000, bitDepth, 0); err != nil {
t.Fatal(err)
}
@ -296,7 +296,7 @@ func TestFragment_FieldMinMax(t *testing.T) {
{filter: pilosa.NewRow(7000), exp: 0, cnt: 1},
}
for i, test := range tests {
if min, cnt, err := f.FieldMin(test.filter, columnDepth); err != nil {
if min, cnt, err := f.FieldMin(test.filter, bitDepth); err != nil {
t.Fatal(err)
} else if min != test.exp {
t.Errorf("test %d expected min: %v, but got: %v", i, test.exp, min)
@ -320,7 +320,7 @@ func TestFragment_FieldMinMax(t *testing.T) {
{filter: pilosa.NewRow(7000), exp: 0, cnt: 1},
}
for i, test := range tests {
if max, cnt, err := f.FieldMax(test.filter, columnDepth); err != nil {
if max, cnt, err := f.FieldMax(test.filter, bitDepth); err != nil {
t.Fatal(err)
} else if max != test.exp {
t.Errorf("test %d expected max: %v, but got: %v", i, test.exp, max)
@ -333,25 +333,25 @@ func TestFragment_FieldMinMax(t *testing.T) {
// Ensure a fragment query for matching fields.
func TestFragment_FieldRange(t *testing.T) {
const columnDepth = 16
const bitDepth = 16
t.Run("EQ", func(t *testing.T) {
f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, "")
defer f.Close()
// Set values.
if _, err := f.SetFieldValue(1000, columnDepth, 382); err != nil {
if _, err := f.SetFieldValue(1000, bitDepth, 382); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(2000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(2000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(3000, columnDepth, 2818); err != nil {
} else if _, err := f.SetFieldValue(3000, bitDepth, 2818); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(4000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(4000, bitDepth, 300); err != nil {
t.Fatal(err)
}
// Query for equality.
if b, err := f.FieldRange(pql.EQ, columnDepth, 300); err != nil {
if b, err := f.FieldRange(pql.EQ, bitDepth, 300); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
@ -363,18 +363,18 @@ func TestFragment_FieldRange(t *testing.T) {
defer f.Close()
// Set values.
if _, err := f.SetFieldValue(1000, columnDepth, 382); err != nil {
if _, err := f.SetFieldValue(1000, bitDepth, 382); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(2000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(2000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(3000, columnDepth, 2818); err != nil {
} else if _, err := f.SetFieldValue(3000, bitDepth, 2818); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(4000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(4000, bitDepth, 300); err != nil {
t.Fatal(err)
}
// Query for inequality.
if b, err := f.FieldRange(pql.NEQ, columnDepth, 300); err != nil {
if b, err := f.FieldRange(pql.NEQ, bitDepth, 300); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
@ -386,43 +386,43 @@ func TestFragment_FieldRange(t *testing.T) {
defer f.Close()
// Set values.
if _, err := f.SetFieldValue(1000, columnDepth, 382); err != nil {
if _, err := f.SetFieldValue(1000, bitDepth, 382); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(2000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(2000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(3000, columnDepth, 2817); err != nil {
} else if _, err := f.SetFieldValue(3000, bitDepth, 2817); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(4000, columnDepth, 301); err != nil {
} else if _, err := f.SetFieldValue(4000, bitDepth, 301); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(5000, columnDepth, 1); err != nil {
} else if _, err := f.SetFieldValue(5000, bitDepth, 1); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(6000, columnDepth, 0); err != nil {
} else if _, err := f.SetFieldValue(6000, bitDepth, 0); err != nil {
t.Fatal(err)
}
// Query for fields less than (ending with set column).
if b, err := f.FieldRange(pql.LT, columnDepth, 301); err != nil {
if b, err := f.FieldRange(pql.LT, bitDepth, 301); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 5000, 6000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields less than (ending with unset column).
if b, err := f.FieldRange(pql.LT, columnDepth, 300); err != nil {
if b, err := f.FieldRange(pql.LT, bitDepth, 300); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{5000, 6000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields less than or equal to (ending with set column).
if b, err := f.FieldRange(pql.LTE, columnDepth, 301); err != nil {
if b, err := f.FieldRange(pql.LTE, bitDepth, 301); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 4000, 5000, 6000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields less than or equal to (ending with unset column).
if b, err := f.FieldRange(pql.LTE, columnDepth, 300); err != nil {
if b, err := f.FieldRange(pql.LTE, bitDepth, 300); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 5000, 6000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
@ -434,43 +434,43 @@ func TestFragment_FieldRange(t *testing.T) {
defer f.Close()
// Set values.
if _, err := f.SetFieldValue(1000, columnDepth, 382); err != nil {
if _, err := f.SetFieldValue(1000, bitDepth, 382); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(2000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(2000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(3000, columnDepth, 2817); err != nil {
} else if _, err := f.SetFieldValue(3000, bitDepth, 2817); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(4000, columnDepth, 301); err != nil {
} else if _, err := f.SetFieldValue(4000, bitDepth, 301); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(5000, columnDepth, 1); err != nil {
} else if _, err := f.SetFieldValue(5000, bitDepth, 1); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(6000, columnDepth, 0); err != nil {
} else if _, err := f.SetFieldValue(6000, bitDepth, 0); err != nil {
t.Fatal(err)
}
// Query for fields greater than (ending with unset column).
if b, err := f.FieldRange(pql.GT, columnDepth, 300); err != nil {
if b, err := f.FieldRange(pql.GT, bitDepth, 300); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields greater than (ending with set column).
if b, err := f.FieldRange(pql.GT, columnDepth, 301); err != nil {
if b, err := f.FieldRange(pql.GT, bitDepth, 301); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields greater than or equal to (ending with unset column).
if b, err := f.FieldRange(pql.GTE, columnDepth, 300); err != nil {
if b, err := f.FieldRange(pql.GTE, bitDepth, 300); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 3000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields greater than or equal to (ending with set column).
if b, err := f.FieldRange(pql.GTE, columnDepth, 301); err != nil {
if b, err := f.FieldRange(pql.GTE, bitDepth, 301); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
@ -482,43 +482,43 @@ func TestFragment_FieldRange(t *testing.T) {
defer f.Close()
// Set values.
if _, err := f.SetFieldValue(1000, columnDepth, 382); err != nil {
if _, err := f.SetFieldValue(1000, bitDepth, 382); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(2000, columnDepth, 300); err != nil {
} else if _, err := f.SetFieldValue(2000, bitDepth, 300); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(3000, columnDepth, 2817); err != nil {
} else if _, err := f.SetFieldValue(3000, bitDepth, 2817); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(4000, columnDepth, 301); err != nil {
} else if _, err := f.SetFieldValue(4000, bitDepth, 301); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(5000, columnDepth, 1); err != nil {
} else if _, err := f.SetFieldValue(5000, bitDepth, 1); err != nil {
t.Fatal(err)
} else if _, err := f.SetFieldValue(6000, columnDepth, 0); err != nil {
} else if _, err := f.SetFieldValue(6000, bitDepth, 0); err != nil {
t.Fatal(err)
}
// Query for fields greater than (ending with unset column).
if b, err := f.FieldRangeBetween(columnDepth, 300, 2817); err != nil {
if b, err := f.FieldRangeBetween(bitDepth, 300, 2817); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 3000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields greater than (ending with set column).
if b, err := f.FieldRangeBetween(columnDepth, 301, 2817); err != nil {
if b, err := f.FieldRangeBetween(bitDepth, 301, 2817); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields greater than or equal to (ending with unset column).
if b, err := f.FieldRangeBetween(columnDepth, 301, 2816); err != nil {
if b, err := f.FieldRangeBetween(bitDepth, 301, 2816); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
}
// Query for fields greater than or equal to (ending with set column).
if b, err := f.FieldRangeBetween(columnDepth, 300, 2816); err != nil {
if b, err := f.FieldRangeBetween(bitDepth, 300, 2816); err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 4000}) {
t.Fatalf("unexpected columns: %+v", b.Columns())
@ -589,9 +589,9 @@ func TestFragment_Top(t *testing.T) {
f := test.MustOpenFragment("i", "f", pilosa.ViewStandard, 0, pilosa.CacheTypeRanked)
defer f.Close()
// Set columns on the rows 100, 101, & 102.
f.MustSetColumns(100, 1, 3, 200)
f.MustSetColumns(101, 1)
f.MustSetColumns(102, 1, 2)
f.MustSetBits(100, 1, 3, 200)
f.MustSetBits(101, 1)
f.MustSetBits(102, 1, 2)
f.RecalculateCache()
// Retrieve top rows.
@ -612,9 +612,9 @@ func TestFragment_Top_Filter(t *testing.T) {
defer f.Close()
// Set columns on the rows 100, 101, & 102.
f.MustSetColumns(100, 1, 3, 200)
f.MustSetColumns(101, 1)
f.MustSetColumns(102, 1, 2)
f.MustSetBits(100, 1, 3, 200)
f.MustSetBits(101, 1)
f.MustSetBits(102, 1, 2)
f.RecalculateCache()
// Assign attributes.
f.RowAttrStore.SetAttrs(101, map[string]interface{}{"x": uint64(10)})
@ -645,10 +645,10 @@ func TestFragment_TopN_Intersect(t *testing.T) {
src := pilosa.NewRow(1, 2, 3)
// Set columns on various rows.
f.MustSetColumns(100, 1, 10, 11, 12) // one intersection
f.MustSetColumns(101, 1, 2, 3, 4) // three intersections
f.MustSetColumns(102, 1, 2, 4, 5, 6) // two intersections
f.MustSetColumns(103, 1000, 1001, 1002) // no intersection
f.MustSetBits(100, 1, 10, 11, 12) // one intersection
f.MustSetBits(101, 1, 2, 3, 4) // three intersections
f.MustSetBits(102, 1, 2, 4, 5, 6) // two intersections
f.MustSetBits(103, 1000, 1001, 1002) // no intersection
f.RecalculateCache()
// Retrieve top rows.
@ -681,7 +681,7 @@ func TestFragment_TopN_Intersect_Large(t *testing.T) {
// Set columns on rows 0 - 999. Higher rows have higher column counts.
for i := uint64(0); i < 1000; i++ {
for j := uint64(0); j < i; j++ {
f.MustSetColumns(i, j)
f.MustSetBits(i, j)
}
}
f.RecalculateCache()
@ -711,9 +711,9 @@ func TestFragment_TopN_IDs(t *testing.T) {
defer f.Close()
// Set columns on various rows.
f.MustSetColumns(100, 1, 2, 3)
f.MustSetColumns(101, 4, 5, 6, 7)
f.MustSetColumns(102, 8, 9, 10, 11, 12)
f.MustSetBits(100, 1, 2, 3)
f.MustSetBits(101, 4, 5, 6, 7)
f.MustSetBits(102, 8, 9, 10, 11, 12)
// Retrieve top rows.
if pairs, err := f.Top(pilosa.TopOptions{RowIDs: []uint64{100, 101, 200}}); err != nil {
@ -732,9 +732,9 @@ func TestFragment_TopN_NopCache(t *testing.T) {
defer f.Close()
// Set columns on various rows.
f.MustSetColumns(100, 1, 2, 3)
f.MustSetColumns(101, 4, 5, 6, 7)
f.MustSetColumns(102, 8, 9, 10, 11, 12)
f.MustSetBits(100, 1, 2, 3)
f.MustSetBits(101, 4, 5, 6, 7)
f.MustSetBits(102, 8, 9, 10, 11, 12)
// Retrieve top rows.
if pairs, err := f.Top(pilosa.TopOptions{RowIDs: []uint64{100, 101, 200}}); err != nil {
@ -784,12 +784,12 @@ func TestFragment_TopN_CacheSize(t *testing.T) {
defer f.Close()
// Set columns on various rows.
f.MustSetColumns(100, 1, 2, 3)
f.MustSetColumns(101, 4, 5, 6, 7)
f.MustSetColumns(102, 8, 9, 10, 11, 12)
f.MustSetColumns(103, 8, 9, 10, 11, 12, 13)
f.MustSetColumns(104, 8, 9, 10, 11, 12, 13, 14)
f.MustSetColumns(105, 10, 11)
f.MustSetBits(100, 1, 2, 3)
f.MustSetBits(101, 4, 5, 6, 7)
f.MustSetBits(102, 8, 9, 10, 11, 12)
f.MustSetBits(103, 8, 9, 10, 11, 12, 13)
f.MustSetBits(104, 8, 9, 10, 11, 12, 13, 14)
f.MustSetBits(105, 10, 11)
f.RecalculateCache()
@ -1084,9 +1084,9 @@ func TestFragment_Tanimoto(t *testing.T) {
src := pilosa.NewRow(1, 2, 3)
// Set columns on the rows 100, 101, & 102.
f.MustSetColumns(100, 1, 3, 2, 200)
f.MustSetColumns(101, 1, 3)
f.MustSetColumns(102, 1, 2, 10, 12)
f.MustSetBits(100, 1, 3, 2, 200)
f.MustSetBits(101, 1, 3)
f.MustSetBits(102, 1, 2, 10, 12)
f.RecalculateCache()
if pairs, err := f.Top(pilosa.TopOptions{TanimotoThreshold: 50, Src: src}); err != nil {
@ -1107,9 +1107,9 @@ func TestFragment_Zero_Tanimoto(t *testing.T) {
src := pilosa.NewRow(1, 2, 3)
// Set columns on the rows 100, 101, & 102.
f.MustSetColumns(100, 1, 3, 2, 200)
f.MustSetColumns(101, 1, 3)
f.MustSetColumns(102, 1, 2, 10, 12)
f.MustSetBits(100, 1, 3, 2, 200)
f.MustSetBits(101, 1, 3)
f.MustSetBits(102, 1, 2, 10, 12)
f.RecalculateCache()
if pairs, err := f.Top(pilosa.TopOptions{TanimotoThreshold: 0, Src: src}); err != nil {

View file

@ -194,13 +194,13 @@ func TestHandler_MaxSlices(t *testing.T) {
hldr := test.MustOpenHolder()
defer hldr.Close()
hldr.MustCreateFragmentIfNotExists("i0", "f0", pilosa.ViewStandard, 1).MustSetColumns(30, (1*SliceWidth)+1)
hldr.MustCreateFragmentIfNotExists("i0", "f0", pilosa.ViewStandard, 1).MustSetColumns(30, (1*SliceWidth)+2)
hldr.MustCreateFragmentIfNotExists("i0", "f0", pilosa.ViewStandard, 3).MustSetColumns(30, (3*SliceWidth)+4)
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.MustCreateFragmentIfNotExists("i1", "f1", pilosa.ViewStandard, 0).MustSetColumns(40, (0*SliceWidth)+1)
hldr.MustCreateFragmentIfNotExists("i1", "f1", pilosa.ViewStandard, 0).MustSetColumns(40, (0*SliceWidth)+2)
hldr.MustCreateFragmentIfNotExists("i1", "f1", pilosa.ViewStandard, 0).MustSetColumns(40, (0*SliceWidth)+8)
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)
h := test.NewHandler()
h.API.Holder = hldr.Holder
@ -1112,7 +1112,7 @@ func TestHandler_Fragment_BackupRestore(t *testing.T) {
// Set columns in the index.
f0 := hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0)
f0.MustSetColumns(100, 1, 2, 3)
f0.MustSetBits(100, 1, 2, 3)
// Begin backing up from slice i/f/0.
resp, err := http.Get(s.URL + "/fragment/data?index=i&frame=f&view=standard&slice=0")

View file

@ -85,9 +85,9 @@ func (f *Fragment) Reopen() error {
return nil
}
// MustSetColumns sets columns on a row. Panic on error.
// MustSetBits sets columns on a row. Panic on error.
// This function does not accept a timestamp or quantum.
func (f *Fragment) MustSetColumns(rowID uint64, columnIDs ...uint64) {
func (f *Fragment) MustSetBits(rowID uint64, columnIDs ...uint64) {
for _, columnID := range columnIDs {
if _, err := f.SetBit(rowID, columnID); err != nil {
panic(err)

View file

@ -75,7 +75,7 @@ func (f *Frame) Reopen() error {
return nil
}
// MustSetBit sets a column on the frame. Panic on error.
// MustSetBit sets a bit on the frame. Panic on error.
func (f *Frame) MustSetBit(view string, rowID, columnID uint64, t *time.Time) (changed bool) {
changed, err := f.SetBit(view, rowID, columnID, t)
if err != nil {

View file

@ -65,7 +65,7 @@ func TestViewByTimeUnit(t *testing.T) {
})
}
// Ensure all applicable frame names can be generated when mutating a time column.
// Ensure all applicable frame names can be generated when mutating a time bit.
func TestViewsByTime(t *testing.T) {
ts := time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC)

View file

@ -72,9 +72,9 @@ func (v *View) Reopen() error {
return v.Open()
}
// MustSetColumns sets columns on a row. Panic on error.
// MustSetBits sets columns on a row. Panic on error.
// This function does not accept a timestamp or quantum.
func (v *View) MustSetColumns(rowID uint64, columnIDs ...uint64) {
func (v *View) MustSetBits(rowID uint64, columnIDs ...uint64) {
for _, columnID := range columnIDs {
if _, err := v.SetBit(rowID, columnID); err != nil {
panic(err)