mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #1326 from tgruben/bitsToColumn
Change bits terminolgy to column
This commit is contained in:
commit
63e440bb74
22 changed files with 374 additions and 373 deletions
16
api.go
16
api.go
|
|
@ -99,9 +99,9 @@ func (api *API) Query(ctx context.Context, req *QueryRequest) (QueryResponse, er
|
|||
return resp, errors.Wrap(err, "parsing")
|
||||
}
|
||||
execOpts := &ExecOptions{
|
||||
Remote: req.Remote,
|
||||
ExcludeAttrs: req.ExcludeAttrs,
|
||||
ExcludeBits: req.ExcludeBits,
|
||||
Remote: req.Remote,
|
||||
ExcludeRowAttrs: req.ExcludeRowAttrs,
|
||||
ExcludeColumns: req.ExcludeColumns,
|
||||
}
|
||||
results, err := api.Executor.Execute(ctx, req.Index, q, req.Slices, execOpts)
|
||||
if err != nil {
|
||||
|
|
@ -110,7 +110,7 @@ func (api *API) Query(ctx context.Context, req *QueryRequest) (QueryResponse, er
|
|||
resp.Results = results
|
||||
|
||||
// Fill column attributes if requested.
|
||||
if req.ColumnAttrs && !req.ExcludeBits {
|
||||
if req.ColumnAttrs && !req.ExcludeColumns {
|
||||
// Consolidate all column ids across all calls.
|
||||
var columnIDs []uint64
|
||||
for _, result := range results {
|
||||
|
|
@ -118,7 +118,7 @@ func (api *API) Query(ctx context.Context, req *QueryRequest) (QueryResponse, er
|
|||
if !ok {
|
||||
continue
|
||||
}
|
||||
columnIDs = uint64Slice(columnIDs).merge(bm.Bits())
|
||||
columnIDs = uint64Slice(columnIDs).merge(bm.Columns())
|
||||
}
|
||||
|
||||
// Retrieve column attributes across all calls.
|
||||
|
|
@ -305,7 +305,7 @@ func (api *API) ExportCSV(ctx context.Context, indexName string, frameName strin
|
|||
// Wrap writer with a CSV writer.
|
||||
cw := csv.NewWriter(w)
|
||||
|
||||
// Iterate over each bit.
|
||||
// Iterate over each column.
|
||||
if err := f.ForEachBit(func(rowID, columnID uint64) error {
|
||||
return cw.Write([]string{
|
||||
strconv.FormatUint(rowID, 10),
|
||||
|
|
@ -784,7 +784,7 @@ func (api *API) Import(ctx context.Context, req internal.ImportRequest) error {
|
|||
// Import into fragment.
|
||||
err = frame.Import(req.RowIDs, req.ColumnIDs, timestamps)
|
||||
if err != nil {
|
||||
api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, bits=%d, err=%s", req.Index, req.Frame, req.Slice, len(req.ColumnIDs), err)
|
||||
api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, columns=%d, err=%s", req.Index, req.Frame, req.Slice, len(req.ColumnIDs), err)
|
||||
}
|
||||
return errors.Wrap(err, "importing")
|
||||
}
|
||||
|
|
@ -803,7 +803,7 @@ func (api *API) ImportValue(ctx context.Context, req internal.ImportValueRequest
|
|||
// Import into fragment.
|
||||
err = frame.ImportValue(req.Field, req.ColumnIDs, req.Values)
|
||||
if err != nil {
|
||||
api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, field=%s, bits=%d, err=%s", req.Index, req.Frame, req.Slice, req.Field, len(req.ColumnIDs), err)
|
||||
api.Logger.Printf("import error: index=%s, frame=%s, slice=%d, field=%s, columns=%d, err=%s", req.Index, req.Frame, req.Slice, req.Field, len(req.ColumnIDs), err)
|
||||
}
|
||||
return errors.Wrap(err, "importing")
|
||||
}
|
||||
|
|
|
|||
4
cache.go
4
cache.go
|
|
@ -168,7 +168,7 @@ func NewRankCache(maxEntries uint32) *RankCache {
|
|||
func (c *RankCache) Add(id uint64, n uint64) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
// Ignore if the bit count is below the threshold.
|
||||
// Ignore if the column count is below the threshold.
|
||||
if n < c.thresholdValue {
|
||||
return
|
||||
}
|
||||
|
|
@ -469,7 +469,7 @@ type BitmapCache interface {
|
|||
|
||||
// SimpleCache implements BitmapCache
|
||||
// it is meant to be a short-lived cache for cases where writes are continuing to access
|
||||
// the same bit within a short time frame (i.e. good for write-heavy loads)
|
||||
// the same row within a short time frame (i.e. good for write-heavy loads)
|
||||
// A read-heavy use case would cause the cache to get bigger, potentially causing the
|
||||
// node to run out of memory.
|
||||
type SimpleCache struct {
|
||||
|
|
|
|||
19
client.go
19
client.go
|
|
@ -308,15 +308,15 @@ func (c *InternalHTTPClient) Import(ctx context.Context, index, frame string, sl
|
|||
return nil
|
||||
}
|
||||
|
||||
// ImportK bulk imports bits to a host.
|
||||
func (c *InternalHTTPClient) ImportK(ctx context.Context, index, frame string, bits []Bit) error {
|
||||
// ImportK bulk imports bits specified by string keys to a host.
|
||||
func (c *InternalHTTPClient) ImportK(ctx context.Context, index, frame string, columns []Bit) error {
|
||||
if index == "" {
|
||||
return ErrIndexRequired
|
||||
} else if frame == "" {
|
||||
return ErrFrameRequired
|
||||
}
|
||||
|
||||
buf, err := marshalImportPayloadK(index, frame, bits)
|
||||
buf, err := marshalImportPayloadK(index, frame, columns)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error Creating Payload: %s", err)
|
||||
}
|
||||
|
|
@ -356,7 +356,7 @@ func marshalImportPayload(index, frame string, slice uint64, bits []Bit) ([]byte
|
|||
columnIDs := Bits(bits).ColumnIDs()
|
||||
timestamps := Bits(bits).Timestamps()
|
||||
|
||||
// Marshal bits to protobufs.
|
||||
// Marshal data to protobuf.
|
||||
buf, err := proto.Marshal(&internal.ImportRequest{
|
||||
Index: index,
|
||||
Frame: frame,
|
||||
|
|
@ -378,7 +378,7 @@ func marshalImportPayloadK(index, frame string, bits []Bit) ([]byte, error) {
|
|||
columnKeys := Bits(bits).ColumnKeys()
|
||||
timestamps := Bits(bits).Timestamps()
|
||||
|
||||
// Marshal bits to protobufs.
|
||||
// Marshal data to protobuf.
|
||||
buf, err := proto.Marshal(&internal.ImportRequest{
|
||||
Index: index,
|
||||
Frame: frame,
|
||||
|
|
@ -465,7 +465,7 @@ func marshalImportValuePayload(index, frame, field string, slice uint64, vals []
|
|||
columnIDs := FieldValues(vals).ColumnIDs()
|
||||
values := FieldValues(vals).Values()
|
||||
|
||||
// Marshal bits to protobufs.
|
||||
// Marshal data to protobuf.
|
||||
buf, err := proto.Marshal(&internal.ImportValueRequest{
|
||||
Index: index,
|
||||
Frame: frame,
|
||||
|
|
@ -1140,7 +1140,8 @@ func (c *InternalHTTPClient) SendMessage(ctx context.Context, uri *URI, pb proto
|
|||
return nil
|
||||
}
|
||||
|
||||
// Bit represents the location of a single bit.
|
||||
// Bit represents the intersection of a row and a column. It can be specifed by
|
||||
// integer ids or string keys.
|
||||
type Bit struct {
|
||||
RowID uint64
|
||||
ColumnID uint64
|
||||
|
|
@ -1149,7 +1150,7 @@ type Bit struct {
|
|||
Timestamp int64
|
||||
}
|
||||
|
||||
// Bits represents a slice of bits.
|
||||
// Bits is a slice of Bit.
|
||||
type Bits []Bit
|
||||
|
||||
func (p Bits) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
|
@ -1277,7 +1278,7 @@ func (p FieldValues) GroupBySlice() map[uint64][]FieldValue {
|
|||
return m
|
||||
}
|
||||
|
||||
// BitsByPos represents a slice of bits sorted by internal position.
|
||||
// BitsByPos is a slice of bits sorted row then column.
|
||||
type BitsByPos []Bit
|
||||
|
||||
func (p BitsByPos) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
|
|
|||
|
|
@ -232,11 +232,11 @@ func TestClient_Import(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify data.
|
||||
if a := f.Row(0).Bits(); !reflect.DeepEqual(a, []uint64{1, 5}) {
|
||||
t.Fatalf("unexpected bits: %+v", a)
|
||||
if a := f.Row(0).Columns(); !reflect.DeepEqual(a, []uint64{1, 5}) {
|
||||
t.Fatalf("unexpected columns: %+v", a)
|
||||
}
|
||||
if a := f.Row(200).Bits(); !reflect.DeepEqual(a, []uint64{6}) {
|
||||
t.Fatalf("unexpected bits: %+v", a)
|
||||
if a := f.Row(200).Columns(); !reflect.DeepEqual(a, []uint64{6}) {
|
||||
t.Fatalf("unexpected columns: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -283,14 +283,14 @@ func TestClient_ImportInverseEnabled(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify data.
|
||||
if a := f.Row(1).Bits(); !reflect.DeepEqual(a, []uint64{0}) {
|
||||
t.Fatalf("unexpected bits: %+v", a)
|
||||
if a := f.Row(1).Columns(); !reflect.DeepEqual(a, []uint64{0}) {
|
||||
t.Fatalf("unexpected columns: %+v", a)
|
||||
}
|
||||
if a := f.Row(5).Bits(); !reflect.DeepEqual(a, []uint64{0, 200}) {
|
||||
t.Fatalf("unexpected bits: %+v", a)
|
||||
if a := f.Row(5).Columns(); !reflect.DeepEqual(a, []uint64{0, 200}) {
|
||||
t.Fatalf("unexpected columns: %+v", a)
|
||||
}
|
||||
if a := f.Row(6).Bits(); !reflect.DeepEqual(a, []uint64{200}) {
|
||||
t.Fatalf("unexpected bits: %+v", a)
|
||||
if a := f.Row(6).Columns(); !reflect.DeepEqual(a, []uint64{200}) {
|
||||
t.Fatalf("unexpected columns: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -403,17 +403,17 @@ func TestClient_BackupRestore(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify data.
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 0).Row(100).Bits(); !reflect.DeepEqual(a, []uint64{1, 2, 3, SliceWidth - 1}) {
|
||||
t.Fatalf("unexpected bits(0): %+v", a)
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 0).Row(100).Columns(); !reflect.DeepEqual(a, []uint64{1, 2, 3, SliceWidth - 1}) {
|
||||
t.Fatalf("unexpected columns(0): %+v", a)
|
||||
}
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 1).Row(100).Bits(); !reflect.DeepEqual(a, []uint64{SliceWidth, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected bits(0): %+v", a)
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 1).Row(100).Columns(); !reflect.DeepEqual(a, []uint64{SliceWidth, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected columns(0): %+v", a)
|
||||
}
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 5).Row(100).Bits(); !reflect.DeepEqual(a, []uint64{(5 * SliceWidth) + 1}) {
|
||||
t.Fatalf("unexpected bits(0): %+v", a)
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 5).Row(100).Columns(); !reflect.DeepEqual(a, []uint64{(5 * SliceWidth) + 1}) {
|
||||
t.Fatalf("unexpected columns(0): %+v", a)
|
||||
}
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 0).Row(200).Bits(); !reflect.DeepEqual(a, []uint64{20000}) {
|
||||
t.Fatalf("unexpected bits: %+v", a)
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewStandard, 0).Row(200).Columns(); !reflect.DeepEqual(a, []uint64{20000}) {
|
||||
t.Fatalf("unexpected columns: %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -468,8 +468,8 @@ func TestClient_BackupInverseView(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify data.
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewInverse, 0).Row(100).Bits(); !reflect.DeepEqual(a, []uint64{1, 2, 3, SliceWidth - 1}) {
|
||||
t.Fatalf("unexpected bits(0): %+v", a)
|
||||
if a := hldr.Fragment("x", "y", pilosa.ViewInverse, 0).Row(100).Columns(); !reflect.DeepEqual(a, []uint64{1, 2, 3, SliceWidth - 1}) {
|
||||
t.Fatalf("unexpected columns(0): %+v", a)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func NewImportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command
|
|||
importCmd := &cobra.Command{
|
||||
Use: "import",
|
||||
Short: "Bulk load data into pilosa.",
|
||||
Long: `Bulk imports one or more CSV files to a host's index and frame. The bits
|
||||
Long: `Bulk imports one or more CSV files to a host's index and frame. The data
|
||||
of the CSV file are grouped by slice for the most efficient import.
|
||||
|
||||
The format of the CSV file is:
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ func (cmd *ImportCommand) Run(ctx context.Context) error {
|
|||
|
||||
// Import each path and import by slice.
|
||||
for _, path := range cmd.Paths {
|
||||
// Parse path into bits.
|
||||
logger.Printf("parsing: %s", path)
|
||||
if err := cmd.importPath(ctx, path); err != nil {
|
||||
return err
|
||||
|
|
@ -236,13 +235,13 @@ func (cmd *ImportCommand) importBits(ctx context.Context, bits []pilosa.Bit) err
|
|||
bitsBySlice := pilosa.Bits(bits).GroupBySlice()
|
||||
|
||||
// Parse path into bits.
|
||||
for slice, bits := range bitsBySlice {
|
||||
for slice, chunk := range bitsBySlice {
|
||||
if cmd.Sort {
|
||||
sort.Sort(pilosa.BitsByPos(bits))
|
||||
sort.Sort(pilosa.BitsByPos(chunk))
|
||||
}
|
||||
|
||||
logger.Printf("importing slice: %d, n=%d", slice, len(bits))
|
||||
if err := cmd.Client.Import(ctx, cmd.Index, cmd.Frame, slice, bits); 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")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
14
executor.go
14
executor.go
|
|
@ -336,7 +336,7 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
// If the row label is used then return bitmap attributes.
|
||||
row, _ := other.(*Row)
|
||||
if c.Name == "Bitmap" {
|
||||
if opt.ExcludeAttrs {
|
||||
if opt.ExcludeRowAttrs {
|
||||
row.Attrs = map[string]interface{}{}
|
||||
} else {
|
||||
idx := e.Holder.Index(index)
|
||||
|
|
@ -367,7 +367,7 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
}
|
||||
}
|
||||
|
||||
if opt.ExcludeBits {
|
||||
if opt.ExcludeColumns {
|
||||
row.segments = []RowSegment{}
|
||||
}
|
||||
|
||||
|
|
@ -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("SetBitmapAttrs", 1, 1.0)
|
||||
frame.Stats.Count("SetRowAttrs", 1, 1.0)
|
||||
|
||||
// Do not forward call if this is already being forwarded.
|
||||
if opt.Remote {
|
||||
|
|
@ -1404,7 +1404,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal
|
|||
if err := frame.RowAttrStore().SetBulkAttrs(frameMap); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
frame.Stats.Count("SetBitmapAttrs", 1, 1.0)
|
||||
frame.Stats.Count("SetRowAttrs", 1, 1.0)
|
||||
}
|
||||
|
||||
// Do not forward call if this is already being forwarded.
|
||||
|
|
@ -1700,9 +1700,9 @@ type mapResponse struct {
|
|||
|
||||
// ExecOptions represents an execution context for a single Execute() call.
|
||||
type ExecOptions struct {
|
||||
Remote bool
|
||||
ExcludeAttrs bool
|
||||
ExcludeBits bool
|
||||
Remote bool
|
||||
ExcludeRowAttrs bool
|
||||
ExcludeColumns bool
|
||||
}
|
||||
|
||||
// decodeError returns an error representation of s if s is non-blank.
|
||||
|
|
|
|||
112
executor_test.go
112
executor_test.go
|
|
@ -54,26 +54,26 @@ 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 bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{3, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} 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))
|
||||
}
|
||||
|
||||
// Inhibit bits.
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, &pilosa.ExecOptions{ExcludeBits: true}); err != nil {
|
||||
// Inhibit columns attributes.
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, &pilosa.ExecOptions{ExcludeColumns: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
} 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))
|
||||
}
|
||||
|
||||
// Inhibit attributes.
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, &pilosa.ExecOptions{ExcludeAttrs: true}); err != nil {
|
||||
// Inhibit row attributes.
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, frame=f)`), nil, &pilosa.ExecOptions{ExcludeRowAttrs: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{3, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{3, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
} else if attrs := res[0].(*pilosa.Row).Attrs; !reflect.DeepEqual(attrs, map[string]interface{}{}) {
|
||||
t.Fatalf("unexpected attrs: %s", spew.Sdump(attrs))
|
||||
}
|
||||
|
|
@ -103,8 +103,8 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(fmt.Sprintf(`Bitmap(col=%d, frame=f)`, SliceWidth+1)), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{10, 20}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{10, 20}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
} 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))
|
||||
}
|
||||
|
|
@ -124,8 +124,8 @@ func TestExecutor_Execute_Difference(t *testing.T) {
|
|||
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 {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{1, 3}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, 3}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,8 +156,8 @@ func TestExecutor_Execute_Intersect(t *testing.T) {
|
|||
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 {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{1, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,8 +186,8 @@ func TestExecutor_Execute_Union(t *testing.T) {
|
|||
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 {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{0, 2, SliceWidth + 1, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{0, 2, SliceWidth + 1, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,8 +200,8 @@ func TestExecutor_Execute_Empty_Union(t *testing.T) {
|
|||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Union()`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,8 +219,8 @@ func TestExecutor_Execute_Xor(t *testing.T) {
|
|||
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 {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{0, 2, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{0, 2, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ func TestExecutor_Execute_SetBit(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
} else {
|
||||
if !res[0].(bool) {
|
||||
t.Fatalf("expected bit changed")
|
||||
t.Fatalf("expected column changed")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ func TestExecutor_Execute_SetBit(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
} else {
|
||||
if res[0].(bool) {
|
||||
t.Fatalf("expected bit unchanged")
|
||||
t.Fatalf("expected column unchanged")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -409,7 +409,7 @@ func TestExecutor_Execute_TopN(t *testing.T) {
|
|||
defer hldr.Close()
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
|
||||
// Set bits for rows 0, 10, & 20 across two slices.
|
||||
// Set columns for rows 0, 10, & 20 across two slices.
|
||||
if idx, err := hldr.CreateIndex("i", pilosa.IndexOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := idx.CreateFrame("f", pilosa.FrameOptions{InverseEnabled: true}); err != nil {
|
||||
|
|
@ -462,7 +462,7 @@ func TestExecutor_Execute_TopN_fill(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
// Set bits for rows 0, 10, & 20 across two slices.
|
||||
// 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)
|
||||
|
|
@ -520,7 +520,7 @@ func TestExecutor_Execute_TopN_Src(t *testing.T) {
|
|||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
// Set bits for rows 0, 10, & 20 across two slices.
|
||||
// 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)
|
||||
|
|
@ -765,7 +765,7 @@ func TestExecutor_Execute_Range(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Set bits.
|
||||
// Set columns.
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`
|
||||
SetBit(frame=f, row=1, col=2, timestamp="1999-12-31T00:00")
|
||||
SetBit(frame=f, row=1, col=3, timestamp="2000-01-01T00:00")
|
||||
|
|
@ -784,8 +784,8 @@ func TestExecutor_Execute_Range(t *testing.T) {
|
|||
t.Run("Standard", func(t *testing.T) {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Range(row=1, frame=f, start="1999-12-31T00:00", end="2002-01-01T03:00")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{2, 3, 4, 5, 6, 7}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{2, 3, 4, 5, 6, 7}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -793,8 +793,8 @@ func TestExecutor_Execute_Range(t *testing.T) {
|
|||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Range(col=2, frame=f, start="1999-01-01T00:00", end="2003-01-01T00:00")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{1, 10}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, 10}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -854,7 +854,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("EQ", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo == 20)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{50, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{50, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -863,28 +863,28 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
// NEQ null
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo != null)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
// NEQ <int>
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo != 20)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1, SliceWidth + 2}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1, SliceWidth + 2}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
// NEQ -<int>
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo != -20)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) {
|
||||
//t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
t.Fatalf("unexpected result: %v", result[0].(*pilosa.Row).Bits())
|
||||
t.Fatalf("unexpected result: %v", result[0].(*pilosa.Row).Columns())
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("LT", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo < 20)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{SliceWidth + 2}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{SliceWidth + 2}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -892,7 +892,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("LTE", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo <= 20)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{50, SliceWidth + 2, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{50, SliceWidth + 2, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -900,7 +900,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("GT", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo > 20)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{SliceWidth, SliceWidth + 1}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -908,7 +908,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("GTE", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo >= 20)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{50, SliceWidth, SliceWidth + 1, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{50, SliceWidth, SliceWidth + 1, (5 * SliceWidth) + 100}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -916,7 +916,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("BETWEEN", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo >< [1, 1000])`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -925,7 +925,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("FieldNotNull", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=other, foo >< [0, 1000])`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -933,7 +933,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("BelowMin", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo == 0)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -941,7 +941,7 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("AboveMax", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=f, foo == 200)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Bits()) {
|
||||
} else if !reflect.DeepEqual([]uint64{}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
}
|
||||
})
|
||||
|
|
@ -949,16 +949,16 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
t.Run("LTAboveMax", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, foo < 200)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Bits()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Bits()))
|
||||
} else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Columns()))
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("GTBelowMin", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(frame=edge, foo > -200)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Bits()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Bits()))
|
||||
} else if !reflect.DeepEqual([]uint64{0, 1}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result[0].(*pilosa.Row).Columns()))
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -999,7 +999,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
|
|||
t.Fatalf("unexpected slices: %+v", slices)
|
||||
}
|
||||
|
||||
// Set bits in slice 0 & 2.
|
||||
// Set columns in slice 0 & 2.
|
||||
r := pilosa.NewRow(
|
||||
(0*SliceWidth)+1,
|
||||
(0*SliceWidth)+2,
|
||||
|
|
@ -1018,8 +1018,8 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
|
|||
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 {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Bits(); !reflect.DeepEqual(bits, []uint64{1, 2, 2*SliceWidth + 4}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, 2, 2*SliceWidth + 4}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1058,7 +1058,7 @@ func TestExecutor_Execute_Remote_Count(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure a remote query can set bits on multiple nodes.
|
||||
// Ensure a remote query can set columns on multiple nodes.
|
||||
func TestExecutor_Execute_Remote_SetBit(t *testing.T) {
|
||||
c := test.NewCluster(2)
|
||||
c.ReplicaN = 2
|
||||
|
|
@ -1101,7 +1101,7 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Verify that one bit is set on both node's holder.
|
||||
// Verify that one column is set on both node's holder.
|
||||
if n := hldr.MustCreateFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).Row(10).Count(); n != 1 {
|
||||
t.Fatalf("unexpected local count: %d", n)
|
||||
}
|
||||
|
|
@ -1110,7 +1110,7 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure a remote query can set bits on multiple nodes.
|
||||
// Ensure a remote query can set columns on multiple nodes.
|
||||
func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) {
|
||||
c := test.NewCluster(2)
|
||||
c.ReplicaN = 2
|
||||
|
|
@ -1155,7 +1155,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Verify that one bit is set on both node's holder.
|
||||
// Verify that one column is set on both node's holder.
|
||||
if n := hldr.MustCreateFragmentIfNotExists("i", "f", "standard_2016", 0).Row(10).Count(); n != 1 {
|
||||
t.Fatalf("unexpected local count: %d", n)
|
||||
}
|
||||
|
|
|
|||
14
fragment.go
14
fragment.go
|
|
@ -393,7 +393,7 @@ func (f *Fragment) setBit(rowID, columnID uint64) (changed bool, err error) {
|
|||
// Determine the position of the bit in the storage.
|
||||
pos, err := f.pos(rowID, columnID)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "getting bit ops")
|
||||
return false, errors.Wrap(err, "getting bit pos")
|
||||
}
|
||||
|
||||
// Write to storage.
|
||||
|
|
@ -585,7 +585,7 @@ func (f *Fragment) importSetFieldValue(columnID uint64, bitDepth uint, value uin
|
|||
// FieldSum returns the sum 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) FieldSum(filter *Row, bitDepth uint) (sum, count uint64, err error) {
|
||||
// Compute count based on the existence bit.
|
||||
// Compute count based on the existence row.
|
||||
row := f.Row(uint64(bitDepth))
|
||||
if filter != nil {
|
||||
count = row.IntersectionCount(filter)
|
||||
|
|
@ -629,7 +629,7 @@ func (f *Fragment) FieldMin(filter *Row, bitDepth uint) (min, count uint64, err
|
|||
}
|
||||
|
||||
for i := bitDepth; i > uint(0); i-- {
|
||||
ii := i - 1 // allow for uint range: (bitdepth-1) to 0
|
||||
ii := i - 1 // allow for uint range: (bitDepth-1) to 0
|
||||
row := f.Row(uint64(ii))
|
||||
|
||||
x := consider.Difference(row)
|
||||
|
|
@ -662,7 +662,7 @@ func (f *Fragment) FieldMax(filter *Row, bitDepth uint) (max, count uint64, err
|
|||
}
|
||||
|
||||
for i := bitDepth; i > uint(0); i-- {
|
||||
ii := i - 1 // allow for uint range: (bitdepth-1) to 0
|
||||
ii := i - 1 // allow for uint range: (bitDepth-1) to 0
|
||||
row := f.Row(uint64(ii))
|
||||
|
||||
x := row.Intersect(consider)
|
||||
|
|
@ -842,7 +842,7 @@ func (f *Fragment) FieldRangeBetween(bitDepth uint, predicateMin, predicateMax u
|
|||
}
|
||||
|
||||
// LTE predicateMin
|
||||
// If bit is zero then remove all set columns not in excluded bitmap.
|
||||
// If bit is zero then remove all set bits not in excluded bitmap.
|
||||
if bit2 == 0 {
|
||||
b = b.Difference(row.Difference(keep2))
|
||||
} else {
|
||||
|
|
@ -996,13 +996,13 @@ func (f *Fragment) Top(opt TopOptions) ([]Pair, error) {
|
|||
// If it's too low then don't try finding anymore pairs.
|
||||
threshold := results.Pairs[0].Count
|
||||
|
||||
// If the row doesn't have enough bits set before the intersection
|
||||
// If the row doesn't have enough columns set before the intersection
|
||||
// then we can assume that any remaining rows also have a count too low.
|
||||
if threshold < opt.MinThreshold || cnt < threshold {
|
||||
break
|
||||
}
|
||||
|
||||
// Calculate the intersecting bit count and skip if it's below our
|
||||
// Calculate the intersecting column count and skip if it's below our
|
||||
// last row in our current result set.
|
||||
count := opt.Src.IntersectionCount(f.Row(rowID))
|
||||
if count < threshold {
|
||||
|
|
|
|||
|
|
@ -176,10 +176,10 @@ func TestFragment_SetFieldValue(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("QuickCheck", func(t *testing.T) {
|
||||
if err := quick.Check(func(bitDepth uint, columnN uint64, values []uint64) bool {
|
||||
if err := quick.Check(func(bitDepth uint, bitN uint64, values []uint64) bool {
|
||||
// Limit bit depth & maximum values.
|
||||
bitDepth = (bitDepth % 62) + 1
|
||||
columnN = (columnN % 99) + 1
|
||||
bitN = (bitN % 99) + 1
|
||||
|
||||
for i := range values {
|
||||
values[i] = values[i] % (1 << bitDepth)
|
||||
|
|
@ -191,7 +191,7 @@ func TestFragment_SetFieldValue(t *testing.T) {
|
|||
// Set values.
|
||||
m := make(map[uint64]int64)
|
||||
for _, value := range values {
|
||||
columnID := value % columnN
|
||||
columnID := value % bitN
|
||||
|
||||
m[columnID] = int64(value)
|
||||
|
||||
|
|
@ -206,9 +206,9 @@ func TestFragment_SetFieldValue(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if value != int64(v) {
|
||||
t.Fatalf("value mismatch: column=%d, bitdepth=%d, value: %d != %d", columnID, bitDepth, value, v)
|
||||
t.Fatalf("value mismatch: columnID=%d, bitdepth=%d, value: %d != %d", columnID, bitDepth, value, v)
|
||||
} else if !exists {
|
||||
t.Fatalf("value should exist: column=%d", columnID)
|
||||
t.Fatalf("value should exist: columnID=%d", columnID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -353,8 +353,8 @@ func TestFragment_FieldRange(t *testing.T) {
|
|||
// Query for equality.
|
||||
if b, err := f.FieldRange(pql.EQ, bitDepth, 300); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{2000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 4000}) {
|
||||
t.Fatalf("unexpected columns: %+v", b.Columns())
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -376,8 +376,8 @@ func TestFragment_FieldRange(t *testing.T) {
|
|||
// Query for inequality.
|
||||
if b, err := f.FieldRange(pql.NEQ, bitDepth, 300); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 3000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000}) {
|
||||
t.Fatalf("unexpected columns: %+v", b.Columns())
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -400,32 +400,32 @@ func TestFragment_FieldRange(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Query for fields less than (ending with set bit).
|
||||
// Query for fields less than (ending with set column).
|
||||
if b, err := f.FieldRange(pql.LT, bitDepth, 301); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{2000, 5000, 6000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
// Query for fields less than (ending with unset column).
|
||||
if b, err := f.FieldRange(pql.LT, bitDepth, 300); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{5000, 6000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
// Query for fields less than or equal to (ending with set column).
|
||||
if b, err := f.FieldRange(pql.LTE, bitDepth, 301); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{2000, 4000, 5000, 6000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
// Query for fields less than or equal to (ending with unset column).
|
||||
if b, err := f.FieldRange(pql.LTE, bitDepth, 300); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{2000, 5000, 6000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} else if !reflect.DeepEqual(b.Columns(), []uint64{2000, 5000, 6000}) {
|
||||
t.Fatalf("unexpected columns: %+v", b.Columns())
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -451,29 +451,29 @@ func TestFragment_FieldRange(t *testing.T) {
|
|||
// Query for fields greater than (ending with unset bit).
|
||||
if b, err := f.FieldRange(pql.GT, bitDepth, 300); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 3000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
if b, err := f.FieldRange(pql.GT, bitDepth, 301); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 3000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
if b, err := f.FieldRange(pql.GTE, bitDepth, 300); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 2000, 3000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
if b, err := f.FieldRange(pql.GTE, bitDepth, 301); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 3000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 3000, 4000}) {
|
||||
t.Fatalf("unexpected columns: %+v", b.Columns())
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -496,32 +496,32 @@ func TestFragment_FieldRange(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Query for fields greater than (ending with unset bit).
|
||||
// Query for fields greater than (ending with unset column).
|
||||
if b, err := f.FieldRangeBetween(bitDepth, 300, 2817); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 2000, 3000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
// Query for fields greater than (ending with set column).
|
||||
if b, err := f.FieldRangeBetween(bitDepth, 301, 2817); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 3000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
// Query for fields greater than or equal to (ending with unset column).
|
||||
if b, err := f.FieldRangeBetween(bitDepth, 301, 2816); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} 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 bit).
|
||||
// Query for fields greater than or equal to (ending with set column).
|
||||
if b, err := f.FieldRangeBetween(bitDepth, 300, 2816); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(b.Bits(), []uint64{1000, 2000, 4000}) {
|
||||
t.Fatalf("unexpected bits: %+v", b.Bits())
|
||||
} else if !reflect.DeepEqual(b.Columns(), []uint64{1000, 2000, 4000}) {
|
||||
t.Fatalf("unexpected columns: %+v", b.Columns())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -663,7 +663,7 @@ func TestFragment_TopN_Intersect(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure a fragment can return top rows that have many bits set.
|
||||
// Ensure a fragment can return top rows that have many columns set.
|
||||
func TestFragment_TopN_Intersect_Large(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("short mode")
|
||||
|
|
@ -1011,8 +1011,8 @@ func TestFragment_WriteTo_ReadFrom(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify data in other fragment.
|
||||
if a := f1.Row(1000).Bits(); !reflect.DeepEqual(a, []uint64{2}) {
|
||||
t.Fatalf("unexpected bits: %+v", a)
|
||||
if a := f1.Row(1000).Columns(); !reflect.DeepEqual(a, []uint64{2}) {
|
||||
t.Fatalf("unexpected columns: %+v", a)
|
||||
}
|
||||
|
||||
// Close and reopen the fragment & verify the data.
|
||||
|
|
@ -1020,8 +1020,8 @@ func TestFragment_WriteTo_ReadFrom(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
} else if n := f1.Cache().Len(); n != 1 {
|
||||
t.Fatalf("unexpected cache size (reopen): %d", n)
|
||||
} else if a := f1.Row(1000).Bits(); !reflect.DeepEqual(a, []uint64{2}) {
|
||||
t.Fatalf("unexpected bits (reopen): %+v", a)
|
||||
} else if a := f1.Row(1000).Columns(); !reflect.DeepEqual(a, []uint64{2}) {
|
||||
t.Fatalf("unexpected columns (reopen): %+v", a)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
30
handler.go
30
handler.go
|
|
@ -82,7 +82,7 @@ func (h *Handler) populateValidators() {
|
|||
h.validators = map[string]*queryValidationSpec{}
|
||||
h.validators["GetFragmentNodes"] = queryValidationSpecRequired("slice", "index")
|
||||
h.validators["GetSliceMax"] = queryValidationSpecRequired().Optional("inverse")
|
||||
h.validators["PostQuery"] = queryValidationSpecRequired().Optional("slices", "columnAttrs", "excludeAttrs", "excludeBits")
|
||||
h.validators["PostQuery"] = queryValidationSpecRequired().Optional("slices", "columnAttrs", "excludeRowAttrs", "excludeColumns")
|
||||
h.validators["GetExport"] = queryValidationSpecRequired("index", "frame", "view", "slice")
|
||||
h.validators["GetFragmentData"] = queryValidationSpecRequired("index", "frame", "view", "slice")
|
||||
h.validators["PostFragmentData"] = queryValidationSpecRequired("index", "frame", "view", "slice")
|
||||
|
|
@ -821,11 +821,11 @@ func (h *Handler) readURLQueryRequest(r *http.Request) (*QueryRequest, error) {
|
|||
}
|
||||
|
||||
return &QueryRequest{
|
||||
Query: query,
|
||||
Slices: slices,
|
||||
ColumnAttrs: q.Get("columnAttrs") == "true",
|
||||
ExcludeAttrs: q.Get("excludeAttrs") == "true",
|
||||
ExcludeBits: q.Get("excludeBits") == "true",
|
||||
Query: query,
|
||||
Slices: slices,
|
||||
ColumnAttrs: q.Get("columnAttrs") == "true",
|
||||
ExcludeRowAttrs: q.Get("excludeRowAttrs") == "true",
|
||||
ExcludeColumns: q.Get("excludeColumns") == "true",
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -1181,10 +1181,10 @@ type QueryRequest struct {
|
|||
ColumnAttrs bool
|
||||
|
||||
// Do not return row attributes, if true.
|
||||
ExcludeAttrs bool
|
||||
ExcludeRowAttrs bool
|
||||
|
||||
// Do not return bits, if true.
|
||||
ExcludeBits bool
|
||||
// Do not return columns, if true.
|
||||
ExcludeColumns bool
|
||||
|
||||
// If true, indicates that query is part of a larger distributed query.
|
||||
// If false, this request is on the originating node.
|
||||
|
|
@ -1193,12 +1193,12 @@ type QueryRequest struct {
|
|||
|
||||
func decodeQueryRequest(pb *internal.QueryRequest) *QueryRequest {
|
||||
req := &QueryRequest{
|
||||
Query: pb.Query,
|
||||
Slices: pb.Slices,
|
||||
ColumnAttrs: pb.ColumnAttrs,
|
||||
Remote: pb.Remote,
|
||||
ExcludeAttrs: pb.ExcludeAttrs,
|
||||
ExcludeBits: pb.ExcludeBits,
|
||||
Query: pb.Query,
|
||||
Slices: pb.Slices,
|
||||
ColumnAttrs: pb.ColumnAttrs,
|
||||
Remote: pb.Remote,
|
||||
ExcludeRowAttrs: pb.ExcludeRowAttrs,
|
||||
ExcludeColumns: pb.ExcludeColumns,
|
||||
}
|
||||
|
||||
return req
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ func TestHandler_Query_Bitmap_JSON(t *testing.T) {
|
|||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader("Bitmap(id=100)")))
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"results":[{"attrs":{"a":"b","c":1,"d":true},"bits":[1,3,66,1048577]}]}`+"\n" {
|
||||
} else if body := w.Body.String(); body != `{"results":[{"attrs":{"a":"b","c":1,"d":true},"columns":[1,3,66,1048577]}]}`+"\n" {
|
||||
t.Fatalf("unexpected body: %s", body)
|
||||
}
|
||||
}
|
||||
|
|
@ -452,7 +452,7 @@ func TestHandler_Query_Row_ColumnAttrs_JSON(t *testing.T) {
|
|||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query?columnAttrs=true", strings.NewReader("Bitmap(id=100)")))
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"results":[{"attrs":{"a":"b","c":1,"d":true},"bits":[1,3,66,1048577]}],"columnAttrs":[{"id":3,"attrs":{"x":"y"}},{"id":66,"attrs":{"y":123,"z":false}}]}`+"\n" {
|
||||
} else if body := w.Body.String(); body != `{"results":[{"attrs":{"a":"b","c":1,"d":true},"columns":[1,3,66,1048577]}],"columnAttrs":[{"id":3,"attrs":{"x":"y"}},{"id":66,"attrs":{"y":123,"z":false}}]}`+"\n" {
|
||||
t.Fatalf("unexpected body: %s", body)
|
||||
}
|
||||
}
|
||||
|
|
@ -484,8 +484,8 @@ func TestHandler_Query_Row_Protobuf(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
} else if rt := resp.Results[0].Type; rt != pilosa.QueryResultTypeRow {
|
||||
t.Fatalf("unexpected response type: %d", resp.Results[0].Type)
|
||||
} else if bits := resp.Results[0].Row.Bits; !reflect.DeepEqual(bits, []uint64{1, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
} else if columns := resp.Results[0].Row.Columns; !reflect.DeepEqual(columns, []uint64{1, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
} else if attrs := resp.Results[0].Row.Attrs; len(attrs) != 3 {
|
||||
t.Fatalf("unexpected attr length: %d", len(attrs))
|
||||
} else if k, v := attrs[0].Key, attrs[0].StringValue; k != "a" || v != "b" {
|
||||
|
|
@ -541,8 +541,8 @@ func TestHandler_Query_Row_ColumnAttrs_Protobuf(t *testing.T) {
|
|||
if err := proto.Unmarshal(w.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if bits := resp.Results[0].Row.Bits; !reflect.DeepEqual(bits, []uint64{1, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected bits: %+v", bits)
|
||||
if columns := resp.Results[0].Row.Columns; !reflect.DeepEqual(columns, []uint64{1, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
} else if rt := resp.Results[0].Type; rt != pilosa.QueryResultTypeRow {
|
||||
t.Fatalf("unexpected response type: %d", resp.Results[0].Type)
|
||||
} else if attrs := resp.Results[0].Row.Attrs; len(attrs) != 3 {
|
||||
|
|
@ -1145,8 +1145,8 @@ func TestHandler_Fragment_BackupRestore(t *testing.T) {
|
|||
f1 := hldr.Fragment("x", "y", pilosa.ViewStandard, 0)
|
||||
if f1 == nil {
|
||||
t.Fatal("fragment x/y/standard/0 not created")
|
||||
} else if bits := f1.Row(100).Bits(); !reflect.DeepEqual(bits, []uint64{1, 2, 3}) {
|
||||
t.Fatalf("unexpected restored bits: %+v", bits)
|
||||
} else if columns := f1.Row(100).Columns(); !reflect.DeepEqual(columns, []uint64{1, 2, 3}) {
|
||||
t.Fatalf("unexpected restored columns: %+v", columns)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -456,29 +456,29 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
// Verify data is the same on both nodes.
|
||||
for i, hldr := range []*test.Holder{hldr0, hldr1} {
|
||||
f := hldr.Fragment("i", "f", pilosa.ViewStandard, 0)
|
||||
if a := f.Row(0).Bits(); !reflect.DeepEqual(a, []uint64{10, 4000}) {
|
||||
t.Fatalf("unexpected bits(%d/0): %+v", i, a)
|
||||
} else if a := f.Row(2).Bits(); !reflect.DeepEqual(a, []uint64{20}) {
|
||||
t.Fatalf("unexpected bits(%d/2): %+v", i, a)
|
||||
} else if a := f.Row(3).Bits(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected bits(%d/3): %+v", i, a)
|
||||
} else if a := f.Row(120).Bits(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected bits(%d/120): %+v", i, a)
|
||||
} else if a := f.Row(200).Bits(); !reflect.DeepEqual(a, []uint64{4}) {
|
||||
t.Fatalf("unexpected bits(%d/200): %+v", i, a)
|
||||
if a := f.Row(0).Columns(); !reflect.DeepEqual(a, []uint64{10, 4000}) {
|
||||
t.Fatalf("unexpected columns(%d/0): %+v", i, a)
|
||||
} else if a := f.Row(2).Columns(); !reflect.DeepEqual(a, []uint64{20}) {
|
||||
t.Fatalf("unexpected columns(%d/2): %+v", i, a)
|
||||
} else if a := f.Row(3).Columns(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected columns(%d/3): %+v", i, a)
|
||||
} else if a := f.Row(120).Columns(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected columns(%d/120): %+v", i, a)
|
||||
} else if a := f.Row(200).Columns(); !reflect.DeepEqual(a, []uint64{4}) {
|
||||
t.Fatalf("unexpected columns(%d/200): %+v", i, a)
|
||||
}
|
||||
|
||||
f = hldr.Fragment("i", "f0", pilosa.ViewStandard, 1)
|
||||
a := f.Row(9).Bits()
|
||||
a := f.Row(9).Columns()
|
||||
if !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected bits(%d/i/f0): %+v", i, a)
|
||||
t.Fatalf("unexpected columns(%d/i/f0): %+v", i, a)
|
||||
}
|
||||
if a := f.Row(9).Bits(); !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected bits(%d/d/f0): %+v", i, a)
|
||||
if a := f.Row(9).Columns(); !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected columns(%d/d/f0): %+v", i, a)
|
||||
}
|
||||
f = hldr.Fragment("y", "z", pilosa.ViewStandard, 3)
|
||||
if a := f.Row(10).Bits(); !reflect.DeepEqual(a, []uint64{(3 * SliceWidth) + 4, (3 * SliceWidth) + 5, (3 * SliceWidth) + 7}) {
|
||||
t.Fatalf("unexpected bits(%d/y/z): %+v", i, a)
|
||||
if a := f.Row(10).Columns(); !reflect.DeepEqual(a, []uint64{(3 * SliceWidth) + 4, (3 * SliceWidth) + 5, (3 * SliceWidth) + 7}) {
|
||||
t.Fatalf("unexpected columns(%d/y/z): %+v", i, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -554,29 +554,29 @@ func TestHolderCleaner_CleanHolder(t *testing.T) {
|
|||
// Verify data is the same on both nodes.
|
||||
for i, hldr := range []*test.Holder{hldr0} {
|
||||
f := hldr.Fragment("i", "f", pilosa.ViewStandard, 0)
|
||||
if a := f.Row(0).Bits(); !reflect.DeepEqual(a, []uint64{10, 4000}) {
|
||||
t.Fatalf("unexpected bits(%d/0): %+v", i, a)
|
||||
} else if a := f.Row(2).Bits(); !reflect.DeepEqual(a, []uint64{20}) {
|
||||
t.Fatalf("unexpected bits(%d/2): %+v", i, a)
|
||||
} else if a := f.Row(3).Bits(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected bits(%d/3): %+v", i, a)
|
||||
} else if a := f.Row(120).Bits(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected bits(%d/120): %+v", i, a)
|
||||
} else if a := f.Row(200).Bits(); !reflect.DeepEqual(a, []uint64{4}) {
|
||||
t.Fatalf("unexpected bits(%d/200): %+v", i, a)
|
||||
if a := f.Row(0).Columns(); !reflect.DeepEqual(a, []uint64{10, 4000}) {
|
||||
t.Fatalf("unexpected columns(%d/0): %+v", i, a)
|
||||
} else if a := f.Row(2).Columns(); !reflect.DeepEqual(a, []uint64{20}) {
|
||||
t.Fatalf("unexpected columns(%d/2): %+v", i, a)
|
||||
} else if a := f.Row(3).Columns(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected columns(%d/3): %+v", i, a)
|
||||
} else if a := f.Row(120).Columns(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected columns(%d/120): %+v", i, a)
|
||||
} else if a := f.Row(200).Columns(); !reflect.DeepEqual(a, []uint64{4}) {
|
||||
t.Fatalf("unexpected columns(%d/200): %+v", i, a)
|
||||
}
|
||||
|
||||
f = hldr.Fragment("i", "f0", pilosa.ViewStandard, 1)
|
||||
a := f.Row(9).Bits()
|
||||
a := f.Row(9).Columns()
|
||||
if !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected bits(%d/i/f0): %+v", i, a)
|
||||
t.Fatalf("unexpected columns(%d/i/f0): %+v", i, a)
|
||||
}
|
||||
if a := f.Row(9).Bits(); !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected bits(%d/d/f0): %+v", i, a)
|
||||
if a := f.Row(9).Columns(); !reflect.DeepEqual(a, []uint64{SliceWidth + 5}) {
|
||||
t.Fatalf("unexpected columns(%d/d/f0): %+v", i, a)
|
||||
}
|
||||
f = hldr.Fragment("y", "z", pilosa.ViewStandard, 2)
|
||||
if a := f.Row(10).Bits(); !reflect.DeepEqual(a, []uint64{(2 * SliceWidth) + 4, (2 * SliceWidth) + 5, (2 * SliceWidth) + 7}) {
|
||||
t.Fatalf("unexpected bits(%d/y/z): %+v", i, a)
|
||||
if a := f.Row(10).Columns(); !reflect.DeepEqual(a, []uint64{(2 * SliceWidth) + 4, (2 * SliceWidth) + 5, (2 * SliceWidth) + 7}) {
|
||||
t.Fatalf("unexpected columns(%d/y/z): %+v", i, a)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -597,16 +597,16 @@ func TestHolderCleaner_CleanHolder(t *testing.T) {
|
|||
// Verify data is the same on both nodes.
|
||||
for i, hldr := range []*test.Holder{hldr0} {
|
||||
f := hldr.Fragment("i", "f", pilosa.ViewStandard, 0)
|
||||
if a := f.Row(0).Bits(); !reflect.DeepEqual(a, []uint64{10, 4000}) {
|
||||
t.Fatalf("unexpected bits(%d/0): %+v", i, a)
|
||||
} else if a := f.Row(2).Bits(); !reflect.DeepEqual(a, []uint64{20}) {
|
||||
t.Fatalf("unexpected bits(%d/2): %+v", i, a)
|
||||
} else if a := f.Row(3).Bits(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected bits(%d/3): %+v", i, a)
|
||||
} else if a := f.Row(120).Bits(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected bits(%d/120): %+v", i, a)
|
||||
} else if a := f.Row(200).Bits(); !reflect.DeepEqual(a, []uint64{4}) {
|
||||
t.Fatalf("unexpected bits(%d/200): %+v", i, a)
|
||||
if a := f.Row(0).Columns(); !reflect.DeepEqual(a, []uint64{10, 4000}) {
|
||||
t.Fatalf("unexpected columns(%d/0): %+v", i, a)
|
||||
} else if a := f.Row(2).Columns(); !reflect.DeepEqual(a, []uint64{20}) {
|
||||
t.Fatalf("unexpected columns(%d/2): %+v", i, a)
|
||||
} else if a := f.Row(3).Columns(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected columns(%d/3): %+v", i, a)
|
||||
} else if a := f.Row(120).Columns(); !reflect.DeepEqual(a, []uint64{10}) {
|
||||
t.Fatalf("unexpected columns(%d/120): %+v", i, a)
|
||||
} else if a := f.Row(200).Columns(); !reflect.DeepEqual(a, []uint64{4}) {
|
||||
t.Fatalf("unexpected columns(%d/200): %+v", i, a)
|
||||
}
|
||||
|
||||
f = hldr.Fragment("i", "f0", pilosa.ViewStandard, 1)
|
||||
|
|
@ -615,8 +615,8 @@ func TestHolderCleaner_CleanHolder(t *testing.T) {
|
|||
}
|
||||
|
||||
f = hldr.Fragment("y", "z", pilosa.ViewStandard, 2)
|
||||
if a := f.Row(10).Bits(); !reflect.DeepEqual(a, []uint64{(2 * SliceWidth) + 4, (2 * SliceWidth) + 5, (2 * SliceWidth) + 7}) {
|
||||
t.Fatalf("unexpected bits(%d/y/z): %+v", i, a)
|
||||
if a := f.Row(10).Columns(); !reflect.DeepEqual(a, []uint64{(2 * SliceWidth) + 4, (2 * SliceWidth) + 5, (2 * SliceWidth) + 7}) {
|
||||
t.Fatalf("unexpected columns(%d/y/z): %+v", i, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ var _ = math.Inf
|
|||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type Row struct {
|
||||
Bits []uint64 `protobuf:"varint,1,rep,packed,name=Bits" json:"Bits,omitempty"`
|
||||
Keys []string `protobuf:"bytes,3,rep,name=Keys" json:"Keys,omitempty"`
|
||||
Attrs []*Attr `protobuf:"bytes,2,rep,name=Attrs" json:"Attrs,omitempty"`
|
||||
Columns []uint64 `protobuf:"varint,1,rep,packed,name=Columns" json:"Columns,omitempty"`
|
||||
Keys []string `protobuf:"bytes,3,rep,name=Keys" json:"Keys,omitempty"`
|
||||
Attrs []*Attr `protobuf:"bytes,2,rep,name=Attrs" json:"Attrs,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Row) Reset() { *m = Row{} }
|
||||
|
|
@ -53,9 +53,9 @@ func (m *Row) String() string { return proto.CompactTextString(m) }
|
|||
func (*Row) ProtoMessage() {}
|
||||
func (*Row) Descriptor() ([]byte, []int) { return fileDescriptorPublic, []int{0} }
|
||||
|
||||
func (m *Row) GetBits() []uint64 {
|
||||
func (m *Row) GetColumns() []uint64 {
|
||||
if m != nil {
|
||||
return m.Bits
|
||||
return m.Columns
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -267,12 +267,12 @@ func (m *AttrMap) GetAttrs() []*Attr {
|
|||
}
|
||||
|
||||
type QueryRequest struct {
|
||||
Query string `protobuf:"bytes,1,opt,name=Query,proto3" json:"Query,omitempty"`
|
||||
Slices []uint64 `protobuf:"varint,2,rep,packed,name=Slices" json:"Slices,omitempty"`
|
||||
ColumnAttrs bool `protobuf:"varint,3,opt,name=ColumnAttrs,proto3" json:"ColumnAttrs,omitempty"`
|
||||
Remote bool `protobuf:"varint,5,opt,name=Remote,proto3" json:"Remote,omitempty"`
|
||||
ExcludeAttrs bool `protobuf:"varint,6,opt,name=ExcludeAttrs,proto3" json:"ExcludeAttrs,omitempty"`
|
||||
ExcludeBits bool `protobuf:"varint,7,opt,name=ExcludeBits,proto3" json:"ExcludeBits,omitempty"`
|
||||
Query string `protobuf:"bytes,1,opt,name=Query,proto3" json:"Query,omitempty"`
|
||||
Slices []uint64 `protobuf:"varint,2,rep,packed,name=Slices" json:"Slices,omitempty"`
|
||||
ColumnAttrs bool `protobuf:"varint,3,opt,name=ColumnAttrs,proto3" json:"ColumnAttrs,omitempty"`
|
||||
Remote bool `protobuf:"varint,5,opt,name=Remote,proto3" json:"Remote,omitempty"`
|
||||
ExcludeRowAttrs bool `protobuf:"varint,6,opt,name=ExcludeRowAttrs,proto3" json:"ExcludeRowAttrs,omitempty"`
|
||||
ExcludeColumns bool `protobuf:"varint,7,opt,name=ExcludeColumns,proto3" json:"ExcludeColumns,omitempty"`
|
||||
}
|
||||
|
||||
func (m *QueryRequest) Reset() { *m = QueryRequest{} }
|
||||
|
|
@ -308,16 +308,16 @@ func (m *QueryRequest) GetRemote() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (m *QueryRequest) GetExcludeAttrs() bool {
|
||||
func (m *QueryRequest) GetExcludeRowAttrs() bool {
|
||||
if m != nil {
|
||||
return m.ExcludeAttrs
|
||||
return m.ExcludeRowAttrs
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *QueryRequest) GetExcludeBits() bool {
|
||||
func (m *QueryRequest) GetExcludeColumns() bool {
|
||||
if m != nil {
|
||||
return m.ExcludeBits
|
||||
return m.ExcludeColumns
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
@ -575,10 +575,10 @@ func (m *Row) MarshalTo(dAtA []byte) (int, error) {
|
|||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Bits) > 0 {
|
||||
dAtA2 := make([]byte, len(m.Bits)*10)
|
||||
if len(m.Columns) > 0 {
|
||||
dAtA2 := make([]byte, len(m.Columns)*10)
|
||||
var j1 int
|
||||
for _, num := range m.Bits {
|
||||
for _, num := range m.Columns {
|
||||
for num >= 1<<7 {
|
||||
dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80)
|
||||
num >>= 7
|
||||
|
|
@ -902,20 +902,20 @@ func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error) {
|
|||
}
|
||||
i++
|
||||
}
|
||||
if m.ExcludeAttrs {
|
||||
if m.ExcludeRowAttrs {
|
||||
dAtA[i] = 0x30
|
||||
i++
|
||||
if m.ExcludeAttrs {
|
||||
if m.ExcludeRowAttrs {
|
||||
dAtA[i] = 1
|
||||
} else {
|
||||
dAtA[i] = 0
|
||||
}
|
||||
i++
|
||||
}
|
||||
if m.ExcludeBits {
|
||||
if m.ExcludeColumns {
|
||||
dAtA[i] = 0x38
|
||||
i++
|
||||
if m.ExcludeBits {
|
||||
if m.ExcludeColumns {
|
||||
dAtA[i] = 1
|
||||
} else {
|
||||
dAtA[i] = 0
|
||||
|
|
@ -1263,9 +1263,9 @@ func encodeVarintPublic(dAtA []byte, offset int, v uint64) int {
|
|||
func (m *Row) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Bits) > 0 {
|
||||
if len(m.Columns) > 0 {
|
||||
l = 0
|
||||
for _, e := range m.Bits {
|
||||
for _, e := range m.Columns {
|
||||
l += sovPublic(uint64(e))
|
||||
}
|
||||
n += 1 + sovPublic(uint64(l)) + l
|
||||
|
|
@ -1405,10 +1405,10 @@ func (m *QueryRequest) Size() (n int) {
|
|||
if m.Remote {
|
||||
n += 2
|
||||
}
|
||||
if m.ExcludeAttrs {
|
||||
if m.ExcludeRowAttrs {
|
||||
n += 2
|
||||
}
|
||||
if m.ExcludeBits {
|
||||
if m.ExcludeColumns {
|
||||
n += 2
|
||||
}
|
||||
return n
|
||||
|
|
@ -1615,7 +1615,7 @@ func (m *Row) Unmarshal(dAtA []byte) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
m.Bits = append(m.Bits, v)
|
||||
m.Columns = append(m.Columns, v)
|
||||
} else if wireType == 2 {
|
||||
var packedLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
|
|
@ -1655,10 +1655,10 @@ func (m *Row) Unmarshal(dAtA []byte) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
m.Bits = append(m.Bits, v)
|
||||
m.Columns = append(m.Columns, v)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Bits", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Columns", wireType)
|
||||
}
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
|
|
@ -2602,7 +2602,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
|
|||
m.Remote = bool(v != 0)
|
||||
case 6:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ExcludeAttrs", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ExcludeRowAttrs", wireType)
|
||||
}
|
||||
var v int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
|
|
@ -2619,10 +2619,10 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
m.ExcludeAttrs = bool(v != 0)
|
||||
m.ExcludeRowAttrs = bool(v != 0)
|
||||
case 7:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ExcludeBits", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ExcludeColumns", wireType)
|
||||
}
|
||||
var v int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
|
|
@ -2639,7 +2639,7 @@ func (m *QueryRequest) Unmarshal(dAtA []byte) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
m.ExcludeBits = bool(v != 0)
|
||||
m.ExcludeColumns = bool(v != 0)
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipPublic(dAtA[iNdEx:])
|
||||
|
|
@ -3795,50 +3795,50 @@ var (
|
|||
func init() { proto.RegisterFile("public.proto", fileDescriptorPublic) }
|
||||
|
||||
var fileDescriptorPublic = []byte{
|
||||
// 707 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6e, 0xd3, 0x4a,
|
||||
0x14, 0xbe, 0x13, 0x3b, 0x7f, 0x27, 0x49, 0x55, 0x8d, 0xee,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4, 0xd8, 0x82, 0x91, 0x09, 0x71, 0xf0, 0x8d, 0xc1, 0x68, 0xbe, 0xcc, 0x54,
|
||||
0xae, 0x1b, 0xc1, 0x98, 0xa7, 0x57, 0xf2, 0xc6, 0x06, 0x83, 0x00, 0xb2, 0xc7, 0x79, 0xb4, 0x34,
|
||||
0x13, 0xd0, 0x17, 0x06, 0x20, 0x4b, 0x01, 0xa1, 0x40, 0xb8, 0xc2, 0x00, 0x8a, 0x02, 0xce, 0x78,
|
||||
0xe1, 0xb9, 0x26, 0x44, 0x06, 0x61, 0xe4, 0xed, 0x88, 0x17, 0x5e, 0x9b, 0xa4, 0x9a, 0xc0, 0xc8,
|
||||
0x6f, 0x66, 0x1c, 0x63, 0xe2, 0x84, 0x8e, 0x68, 0x30, 0xf8, 0x0e, 0x42, 0xad, 0xe8, 0x87, 0xad,
|
||||
0x4b, 0x3f, 0x6c, 0x16, 0xe2, 0x49, 0x53, 0x86, 0xc4, 0x1e, 0x89, 0x0d, 0x26, 0xf8, 0xc4, 0x80,
|
||||
0x1b, 0x8f, 0x34, 0x3c, 0x7f, 0xce, 0x28, 0xee, 0x8d, 0x65, 0x62, 0x1a, 0x83, 0x7b, 0x11, 0xfc,
|
||||
0xc2, 0xe6, 0x1e, 0x74, 0xe8, 0x16, 0xd6, 0x62, 0x85, 0xee, 0x98, 0xe8, 0xde, 0x35, 0x31, 0xdb,
|
||||
0xfd, 0x7c, 0x3b, 0x66, 0x5f, 0x6e, 0xc7, 0xec, 0xeb, 0xed, 0x98, 0xbd, 0xfb, 0x3e, 0xfe, 0xeb,
|
||||
0xa2, 0x43, 0x7f, 0x1c, 0x8f, 0x7e, 0x04, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x35, 0x66, 0x28, 0x48,
|
||||
0x06, 0x00, 0x00,
|
||||
// 709 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xc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 0x9e, 0xb0, 0x90, 0x4f, 0xea, 0xf9, 0xa4, 0x06, 0x0c, 0xa6, 0xbc, 0x2e,
|
||||
0x61, 0x15, 0x51, 0xcf, 0xb0, 0x0d, 0x34, 0xf6, 0x62, 0x68, 0x02, 0x1d, 0x7c, 0x67, 0x30, 0x9c,
|
||||
0xcd, 0x33, 0x95, 0xeb, 0x46, 0x48, 0x66, 0xe9, 0x85, 0xbc, 0xb2, 0x21, 0x21, 0x80, 0xec, 0x41,
|
||||
0x1e, 0xcd, 0xcd, 0x34, 0xf4, 0x85, 0x01, 0xc8, 0x52, 0x58, 0x28, 0x1c, 0xae, 0x30, 0x80, 0x62,
|
||||
0x81, 0xf3, 0x5e, 0x78, 0xae, 0x09, 0x94, 0x41, 0x18, 0x7f, 0x3b, 0xee, 0x85, 0xd7, 0x26, 0xa9,
|
||||
0x26, 0x30, 0xfe, 0xab, 0x79, 0xc7, 0xbc, 0x38, 0xa1, 0x23, 0x1a, 0x0c, 0xbe, 0x83, 0x50, 0x0b,
|
||||
0xfa, 0xc8, 0x75, 0xe9, 0x23, 0x67, 0x21, 0x9e, 0x34, 0x65, 0x48, 0xec, 0x91, 0xd8, 0x60, 0x82,
|
||||
0x2f, 0x0c, 0xb8, 0xf1, 0x48, 0x83, 0xf4, 0xf7, 0x8c, 0xe2, 0xde, 0x58, 0x26, 0xa6, 0x31, 0xb8,
|
||||
0x17, 0xc1, 0x6f, 0x6c, 0x6e, 0x41, 0x87, 0x6e, 0x61, 0x2d, 0x56, 0x68, 0xcd, 0x44, 0x77, 0xdd,
|
||||
0xc4, 0xce, 0xe6, 0xf5, 0xcd, 0x98, 0x7d, 0xbd, 0x19, 0xb3, 0x6f, 0x37, 0x63, 0xf6, 0xf1, 0xc7,
|
||||
0xf8, 0x9f, 0xb3, 0x0e, 0xfd, 0x95, 0x3c, 0xf9, 0x19, 0x00, 0x00, 0xff, 0xff, 0x03, 0x56, 0xc7,
|
||||
0xa4, 0x5a, 0x06, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ syntax = "proto3";
|
|||
package internal;
|
||||
|
||||
message Row {
|
||||
repeated uint64 Bits = 1;
|
||||
repeated uint64 Columns = 1;
|
||||
repeated string Keys = 3;
|
||||
repeated Attr Attrs = 2;
|
||||
}
|
||||
|
|
@ -49,8 +49,8 @@ message QueryRequest {
|
|||
repeated uint64 Slices = 2;
|
||||
bool ColumnAttrs = 3;
|
||||
bool Remote = 5;
|
||||
bool ExcludeAttrs = 6;
|
||||
bool ExcludeBits = 7;
|
||||
bool ExcludeRowAttrs = 6;
|
||||
bool ExcludeColumns = 7;
|
||||
}
|
||||
|
||||
message QueryResponse {
|
||||
|
|
|
|||
41
row.go
41
row.go
|
|
@ -22,7 +22,8 @@ import (
|
|||
"github.com/pilosa/pilosa/roaring"
|
||||
)
|
||||
|
||||
// Row represents a set of bits.
|
||||
// Row is a set of integers (the associated columns), and attributes which are
|
||||
// arbitrary key/value pairs storing metadata about what the row represents.
|
||||
type Row struct {
|
||||
segments []RowSegment
|
||||
|
||||
|
|
@ -31,9 +32,9 @@ type Row struct {
|
|||
}
|
||||
|
||||
// NewRow returns a new instance of Row.
|
||||
func NewRow(bits ...uint64) *Row {
|
||||
func NewRow(columns ...uint64) *Row {
|
||||
r := &Row{}
|
||||
for _, i := range bits {
|
||||
for _, i := range columns {
|
||||
r.SetBit(i)
|
||||
}
|
||||
return r
|
||||
|
|
@ -151,12 +152,12 @@ func (r *Row) Difference(other *Row) *Row {
|
|||
return &Row{segments: segments}
|
||||
}
|
||||
|
||||
// SetBit sets the i-th bit of the row.
|
||||
// SetBit sets the i-th column of the row.
|
||||
func (r *Row) SetBit(i uint64) (changed bool) {
|
||||
return r.createSegmentIfNotExists(i / SliceWidth).SetBit(i)
|
||||
}
|
||||
|
||||
// ClearBit clears the i-th bit of the row.
|
||||
// ClearBit clears the i-th column of the row.
|
||||
func (r *Row) ClearBit(i uint64) (changed bool) {
|
||||
s := r.segment(i / SliceWidth)
|
||||
if s == nil {
|
||||
|
|
@ -226,7 +227,7 @@ func (r *Row) DecrementCount(i uint64) {
|
|||
}
|
||||
}
|
||||
|
||||
// Count returns the number of set bits in the row.
|
||||
// Count returns the number of columns in the row.
|
||||
func (r *Row) Count() uint64 {
|
||||
var n uint64
|
||||
for i := range r.segments {
|
||||
|
|
@ -238,10 +239,10 @@ func (r *Row) Count() uint64 {
|
|||
// MarshalJSON returns a JSON-encoded byte slice of r.
|
||||
func (r *Row) MarshalJSON() ([]byte, error) {
|
||||
var o struct {
|
||||
Attrs map[string]interface{} `json:"attrs"`
|
||||
Bits []uint64 `json:"bits"`
|
||||
Attrs map[string]interface{} `json:"attrs"`
|
||||
Columns []uint64 `json:"columns"`
|
||||
}
|
||||
o.Bits = r.Bits()
|
||||
o.Columns = r.Columns()
|
||||
|
||||
o.Attrs = r.Attrs
|
||||
if o.Attrs == nil {
|
||||
|
|
@ -251,11 +252,11 @@ func (r *Row) MarshalJSON() ([]byte, error) {
|
|||
return json.Marshal(&o)
|
||||
}
|
||||
|
||||
// Bits returns the bits in r as a slice of ints.
|
||||
func (r *Row) Bits() []uint64 {
|
||||
// Columns returns the columns in r as a slice of ints.
|
||||
func (r *Row) Columns() []uint64 {
|
||||
a := make([]uint64, 0, r.Count())
|
||||
for i := range r.segments {
|
||||
a = append(a, r.segments[i].Bits()...)
|
||||
a = append(a, r.segments[i].Columns()...)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
|
@ -267,8 +268,8 @@ func encodeRow(r *Row) *internal.Row {
|
|||
}
|
||||
|
||||
return &internal.Row{
|
||||
Bits: r.Bits(),
|
||||
Attrs: encodeAttrs(r.Attrs),
|
||||
Columns: r.Columns(),
|
||||
Attrs: encodeAttrs(r.Attrs),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +281,7 @@ func decodeRow(pr *internal.Row) *Row {
|
|||
|
||||
r := NewRow()
|
||||
r.Attrs = decodeAttrs(pr.Attrs)
|
||||
for _, v := range pr.Bits {
|
||||
for _, v := range pr.Columns {
|
||||
r.SetBit(v)
|
||||
}
|
||||
return r
|
||||
|
|
@ -372,7 +373,7 @@ func (s *RowSegment) Xor(other *RowSegment) *RowSegment {
|
|||
}
|
||||
}
|
||||
|
||||
// SetBit sets the i-th bit of the row.
|
||||
// SetBit sets the i-th column of the row.
|
||||
func (s *RowSegment) SetBit(i uint64) (changed bool) {
|
||||
s.ensureWritable()
|
||||
changed, _ = s.data.Add(i)
|
||||
|
|
@ -382,7 +383,7 @@ func (s *RowSegment) SetBit(i uint64) (changed bool) {
|
|||
return changed
|
||||
}
|
||||
|
||||
// ClearBit clears the i-th bit of the row.
|
||||
// ClearBit clears the i-th column of the row.
|
||||
func (s *RowSegment) ClearBit(i uint64) (changed bool) {
|
||||
s.ensureWritable()
|
||||
|
||||
|
|
@ -398,8 +399,8 @@ func (s *RowSegment) InvalidateCount() {
|
|||
s.n = s.data.Count()
|
||||
}
|
||||
|
||||
// Bits returns a list of all bits set in the segment.
|
||||
func (s *RowSegment) Bits() []uint64 {
|
||||
// Columns returns a list of all columns set in the segment.
|
||||
func (s *RowSegment) Columns() []uint64 {
|
||||
a := make([]uint64, 0, s.Count())
|
||||
itr := s.data.Iterator()
|
||||
for v, eof := itr.Next(); !eof; v, eof = itr.Next() {
|
||||
|
|
@ -408,7 +409,7 @@ func (s *RowSegment) Bits() []uint64 {
|
|||
return a
|
||||
}
|
||||
|
||||
// Count returns the number of set bits in the row.
|
||||
// Count returns the number of set columns in the row.
|
||||
func (s *RowSegment) Count() uint64 { return s.n }
|
||||
|
||||
// ensureWritable clones the segment if it is pointing to non-writable data.
|
||||
|
|
|
|||
22
row_test.go
22
row_test.go
|
|
@ -47,7 +47,7 @@ func TestRow_Merge(t *testing.T) {
|
|||
if cnt := test.r1.Count(); cnt != test.exp {
|
||||
t.Fatalf("merged count %d is not %d", cnt, test.exp)
|
||||
}
|
||||
if length := len(test.r1.Bits()); uint64(length) != test.exp {
|
||||
if length := len(test.r1.Columns()); uint64(length) != test.exp {
|
||||
t.Fatalf("merged length %d is not %d", length, test.exp)
|
||||
}
|
||||
})
|
||||
|
|
@ -65,15 +65,15 @@ func TestRow_Xor(t *testing.T) {
|
|||
t.Fatalf("Test 1 Count after xor %d != 3\n", res.Count())
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(res.Bits(), exp) {
|
||||
t.Fatalf("Test 2 Results %v != expected %v\n", res.Bits(), exp)
|
||||
if !reflect.DeepEqual(res.Columns(), exp) {
|
||||
t.Fatalf("Test 2 Results %v != expected %v\n", res.Columns(), exp)
|
||||
}
|
||||
res = r2.Xor(r1)
|
||||
if res.Count() != 3 {
|
||||
t.Fatalf("Test 3 Count after xor %d != 3\n", res.Count())
|
||||
}
|
||||
if !reflect.DeepEqual(res.Bits(), exp) {
|
||||
t.Fatalf("Test 4 Results %v != expected %v\n", res.Bits(), exp)
|
||||
if !reflect.DeepEqual(res.Columns(), exp) {
|
||||
t.Fatalf("Test 4 Results %v != expected %v\n", res.Columns(), exp)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -86,15 +86,15 @@ func TestRow_Union_Segment(t *testing.T) {
|
|||
if res.Count() != 4 {
|
||||
t.Fatalf("Test 1 Count after Union %d != 5\n", res.Count())
|
||||
}
|
||||
if !reflect.DeepEqual(res.Bits(), exp) {
|
||||
t.Fatalf("Test 2 Union Results %v != expected %v\n", res.Bits(), exp)
|
||||
if !reflect.DeepEqual(res.Columns(), exp) {
|
||||
t.Fatalf("Test 2 Union Results %v != expected %v\n", res.Columns(), exp)
|
||||
}
|
||||
res = r2.Union(r1)
|
||||
if res.Count() != 4 {
|
||||
t.Fatalf("Test 3 Count after xor %d != 5\n", res.Count())
|
||||
}
|
||||
if !reflect.DeepEqual(res.Bits(), exp) {
|
||||
t.Fatalf("Test 2 Union Results %v != expected %v\n", res.Bits(), exp)
|
||||
if !reflect.DeepEqual(res.Columns(), exp) {
|
||||
t.Fatalf("Test 2 Union Results %v != expected %v\n", res.Columns(), exp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ func TestRow_Difference_Segment(t *testing.T) {
|
|||
if res.Count() != 2 {
|
||||
t.Fatalf("Test 1 Count after Difference %d != 5\n", res.Count())
|
||||
}
|
||||
if !reflect.DeepEqual(res.Bits(), exp) {
|
||||
t.Fatalf("Test 2 Difference Results %v != expected %v\n", res.Bits(), exp)
|
||||
if !reflect.DeepEqual(res.Columns(), exp) {
|
||||
t.Fatalf("Test 2 Difference Results %v != expected %v\n", res.Columns(), exp)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -464,12 +464,12 @@ func TestClusterResize_RemoveNode(t *testing.T) {
|
|||
|
||||
// This is an attempt to ensure there is data on both nodes, but is not guaranteed.
|
||||
// TODO: Deterministic node IDs would ensure consistent results
|
||||
setBits := ""
|
||||
setColumns := ""
|
||||
for i := 0; i < 20; i++ {
|
||||
setBits += fmt.Sprintf("SetBit(row=1, frame=\"f\", col=%d) ", i*pilosa.SliceWidth)
|
||||
setColumns += fmt.Sprintf("SetBit(row=1, frame=\"f\", col=%d) ", i*pilosa.SliceWidth)
|
||||
}
|
||||
|
||||
if _, err := m0.Query("i", "", setBits); err != nil {
|
||||
if _, err := m0.Query("i", "", setColumns); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ func TestMain_Set_Quick(t *testing.T) {
|
|||
exp := MustMarshalJSON(map[string]interface{}{
|
||||
"results": []interface{}{
|
||||
map[string]interface{}{
|
||||
"bits": columnIDs,
|
||||
"columns": columnIDs,
|
||||
"attrs": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
|
|
@ -92,7 +92,7 @@ func TestMain_Set_Quick(t *testing.T) {
|
|||
exp := MustMarshalJSON(map[string]interface{}{
|
||||
"results": []interface{}{
|
||||
map[string]interface{}{
|
||||
"bits": columnIDs,
|
||||
"columns": columnIDs,
|
||||
"attrs": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
|
|
@ -132,7 +132,7 @@ func TestMain_SetRowAttrs(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Set bits on different rows in different frames.
|
||||
// Set columns on different rows in different frames.
|
||||
if _, err := m.Query("i", "", `SetBit(row=1, frame="x", col=100)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetBit(row=2, frame="x", col=100)`); err != nil {
|
||||
|
|
@ -157,14 +157,14 @@ func TestMain_SetRowAttrs(t *testing.T) {
|
|||
// Query row x/1.
|
||||
if res, err := m.Query("i", "", `Bitmap(row=1, frame="x")`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{"x":100},"bits":[100]}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{"x":100},"columns":[100]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
}
|
||||
|
||||
// Query row x/2.
|
||||
if res, err := m.Query("i", "", `Bitmap(row=2, frame="x")`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{"x":-200},"bits":[100]}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{"x":-200},"columns":[100]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
}
|
||||
|
||||
|
|
@ -175,19 +175,19 @@ func TestMain_SetRowAttrs(t *testing.T) {
|
|||
// Query rows after reopening.
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, frame="x")`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{"x":100},"bits":[100]}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{"x":100},"columns":[100]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result(reopen): %s", res)
|
||||
}
|
||||
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=3, frame="neg")`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{"x":-0.44},"bits":[100]}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{"x":-0.44},"columns":[100]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result(reopen): %s", res)
|
||||
}
|
||||
// Query row x/2.
|
||||
if res, err := m.Query("i", "", `Bitmap(row=2, frame="x")`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{"x":-200},"bits":[100]}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{"x":-200},"columns":[100]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
}
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ func TestMain_SetColumnAttrs(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Set bits on row.
|
||||
// Set columns on row.
|
||||
if _, err := m.Query("i", "", `SetBit(row=1, frame="x", col=100)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetBit(row=1, frame="x", col=101)`); err != nil {
|
||||
|
|
@ -220,7 +220,7 @@ func TestMain_SetColumnAttrs(t *testing.T) {
|
|||
// Query row.
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, frame="x")`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{},"bits":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{},"columns":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ func TestMain_SetColumnAttrs(t *testing.T) {
|
|||
// Query row after reopening.
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, frame="x")`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{},"bits":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{},"columns":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" {
|
||||
t.Fatalf("unexpected result(reopen): %s", res)
|
||||
}
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ func TestMain_InverseSlices(t *testing.T) {
|
|||
SetBit(col=1, frame="f", row=2000)
|
||||
SetBit(col=1, frame="f", row=%d)
|
||||
`, 1*pilosa.SliceWidth)); err != nil {
|
||||
t.Fatal("setting bits:", err)
|
||||
t.Fatal("setting columns:", err)
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
|
@ -274,12 +274,12 @@ func TestMain_InverseSlices(t *testing.T) {
|
|||
// Query the cluster.
|
||||
if res, err := m.Query("i", "", `Bitmap(col=1, frame="f")`); err != nil {
|
||||
t.Fatal("another bitmap query:", err)
|
||||
} else if res != fmt.Sprintf(`{"results":[{"attrs":{},"bits":[1000,2000,%d]}]}`, 1*pilosa.SliceWidth)+"\n" {
|
||||
} else if res != fmt.Sprintf(`{"results":[{"attrs":{},"columns":[1000,2000,%d]}]}`, 1*pilosa.SliceWidth)+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure program can set bits on one cluster and then restore to a second cluster.
|
||||
// Ensure program can set columns on one cluster and then restore to a second cluster.
|
||||
func TestMain_FrameRestore(t *testing.T) {
|
||||
mains1 := test.MustRunMainWithCluster(t, 2)
|
||||
m10 := mains1[0]
|
||||
|
|
@ -304,13 +304,13 @@ func TestMain_FrameRestore(t *testing.T) {
|
|||
SetBit(row=1, frame="f", col=600000)
|
||||
SetBit(row=1, frame="f", col=800000)
|
||||
`); err != nil {
|
||||
t.Fatal("setting bits:", err)
|
||||
t.Fatal("setting columns:", err)
|
||||
}
|
||||
|
||||
// Query row on first cluster.
|
||||
if res, err := m10.Query("i", "", `Bitmap(row=1, frame="f")`); err != nil {
|
||||
t.Fatal("bitmap query:", err)
|
||||
} else if res != `{"results":[{"attrs":{},"bits":[100,1000,100000,200000,400000,600000,800000]}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{},"columns":[100,1000,100000,200000,400000,600000,800000]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
}
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ func TestMain_FrameRestore(t *testing.T) {
|
|||
// Query row on second cluster.
|
||||
if res, err := m20.Query("i", "", `Bitmap(row=1, frame="f")`); err != nil {
|
||||
t.Fatal("another bitmap query:", err)
|
||||
} else if res != `{"results":[{"attrs":{},"bits":[100,1000,100000,200000,400000,600000,800000]}]}`+"\n" {
|
||||
} else if res != `{"results":[{"attrs":{},"columns":[100,1000,100000,200000,400000,600000,800000]}]}`+"\n" {
|
||||
t.Fatalf("2unexpected result: %s", res)
|
||||
}
|
||||
}
|
||||
|
|
@ -408,7 +408,7 @@ func TestMain_RecalculateHashes(t *testing.T) {
|
|||
t.Fatal("create frame:", err)
|
||||
}
|
||||
|
||||
// Set some bits
|
||||
// Set some columns
|
||||
data := []string{}
|
||||
for rowID := 1; rowID < 10; rowID++ {
|
||||
for columnID := 1; columnID < 100; columnID++ {
|
||||
|
|
@ -416,7 +416,7 @@ func TestMain_RecalculateHashes(t *testing.T) {
|
|||
}
|
||||
}
|
||||
if _, err := cluster[0].Query("i", "", strings.Join(data, "")); err != nil {
|
||||
t.Fatal("setting bits:", err)
|
||||
t.Fatal("setting columns:", err)
|
||||
}
|
||||
|
||||
// Calculate caches on the first node
|
||||
|
|
@ -440,7 +440,7 @@ func TestMain_RecalculateHashes(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// SetCommand represents a command to set a bit.
|
||||
// SetCommand represents a command to set a column.
|
||||
type SetCommand struct {
|
||||
ID uint64
|
||||
Frame string
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ func TestStatsCount_Bitmap(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestStatsCount_SetBitmapAttrs(t *testing.T) {
|
||||
func TestStatsCount_SetColumnAttrs(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
|
|
@ -162,8 +162,8 @@ func TestStatsCount_SetBitmapAttrs(t *testing.T) {
|
|||
|
||||
frame.Stats = &MockStats{
|
||||
mockCount: func(name string, value int64, rate float64) {
|
||||
if name != "SetBitmapAttrs" {
|
||||
t.Errorf("Expected SetBitmapAttrs, Results %s", name)
|
||||
if name != "SetRowAttrs" {
|
||||
t.Errorf("Expected SetRowAttrs, Results %s", name)
|
||||
}
|
||||
called = true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func (f *Fragment) Reopen() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MustSetBits sets bits 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) MustSetBits(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
|
|
@ -95,8 +95,8 @@ func (f *Fragment) MustSetBits(rowID uint64, columnIDs ...uint64) {
|
|||
}
|
||||
}
|
||||
|
||||
// MustClearBits clears bits on a row. Panic on error.
|
||||
func (f *Fragment) MustClearBits(rowID uint64, columnIDs ...uint64) {
|
||||
// MustClearColumns clears columns on a row. Panic on error.
|
||||
func (f *Fragment) MustClearColumns(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
if _, err := f.ClearBit(rowID, columnID); err != nil {
|
||||
panic(err)
|
||||
|
|
@ -126,7 +126,7 @@ func (s *RowAttrStore) SetRowAttrs(id uint64, m map[string]interface{}) {
|
|||
s.attrs[id] = m
|
||||
}
|
||||
|
||||
// GenerateImportFill generates a set of bits pairs that evenly fill a fragment chunk.
|
||||
// GenerateImportFill generates a set of row/col pairs that evenly fill a fragment chunk.
|
||||
func GenerateImportFill(rowN int, pct float64) (rowIDs, columnIDs []uint64) {
|
||||
ipct := int(pct * 100)
|
||||
for i := 0; i < SliceWidth*rowN; i++ {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func (v *View) Reopen() error {
|
|||
return v.Open()
|
||||
}
|
||||
|
||||
// MustSetBits sets bits 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) MustSetBits(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
|
|
@ -82,7 +82,7 @@ func (v *View) MustSetBits(rowID uint64, columnIDs ...uint64) {
|
|||
}
|
||||
}
|
||||
|
||||
// MustClearBits clears bits on a row. Panic on error.
|
||||
// MustClearColumns clears columns on a row. Panic on error.
|
||||
func (v *View) MustClearBits(rowID uint64, columnIDs ...uint64) {
|
||||
for _, columnID := range columnIDs {
|
||||
if _, err := v.ClearBit(rowID, columnID); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue