mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
Merge pull request #1402 from alanbernstein/pql-updates
Update to new PQL syntax beyond the parser
This commit is contained in:
commit
406f008f80
10 changed files with 330 additions and 250 deletions
|
|
@ -229,7 +229,7 @@ type Cluster struct {
|
|||
// Threshold for logging long-running queries
|
||||
LongQueryTime time.Duration
|
||||
|
||||
// Maximum number of SetBit() or ClearBit() commands per request.
|
||||
// Maximum number of Set() or Clear() commands per request.
|
||||
MaxWritesPerRequest int
|
||||
|
||||
// EventReceiver receives NodeEvents pertaining to node membership.
|
||||
|
|
|
|||
157
executor.go
157
executor.go
|
|
@ -48,7 +48,7 @@ type Executor struct {
|
|||
// Client used for remote requests.
|
||||
client InternalQueryClient
|
||||
|
||||
// Maximum number of SetBit() or ClearBit() commands per request.
|
||||
// Maximum number of Set() or Clear() commands per request.
|
||||
MaxWritesPerRequest int
|
||||
|
||||
// Stores key/id translation data.
|
||||
|
|
@ -178,12 +178,12 @@ func (e *Executor) executeCall(ctx context.Context, index string, c *pql.Call, s
|
|||
case "Max":
|
||||
e.Holder.Stats.CountWithCustomTags(c.Name, 1, 1.0, []string{indexTag})
|
||||
return e.executeMax(ctx, index, c, slices, opt)
|
||||
case "ClearBit":
|
||||
case "Clear":
|
||||
return e.executeClearBit(ctx, index, c, opt)
|
||||
case "Count":
|
||||
e.Holder.Stats.CountWithCustomTags(c.Name, 1, 1.0, []string{indexTag})
|
||||
return e.executeCount(ctx, index, c, slices, opt)
|
||||
case "SetBit":
|
||||
case "Set":
|
||||
return e.executeSetBit(ctx, index, c, opt)
|
||||
case "SetValue":
|
||||
return nil, e.executeSetValue(ctx, index, c, opt)
|
||||
|
|
@ -340,17 +340,17 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Attach attributes for Bitmap() calls.
|
||||
// Attach attributes for Row() calls.
|
||||
// If the column label is used then return column attributes.
|
||||
// If the row label is used then return bitmap attributes.
|
||||
row, _ := other.(*Row)
|
||||
if c.Name == "Bitmap" {
|
||||
if c.Name == "Row" {
|
||||
if opt.ExcludeRowAttrs {
|
||||
row.Attrs = map[string]interface{}{}
|
||||
} else {
|
||||
idx := e.Holder.Index(index)
|
||||
if idx != nil {
|
||||
if columnID, ok, err := c.UintArg(columnLabel); ok && err == nil {
|
||||
if columnID, ok, err := c.UintArg("_" + columnLabel); ok && err == nil {
|
||||
attrs, err := idx.ColumnAttrStore().Attrs(columnID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting column attrs")
|
||||
|
|
@ -359,9 +359,10 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
} else if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
field, _ := c.Args["field"].(string)
|
||||
if fr := idx.Field(field); fr != nil {
|
||||
rowID, _, err := c.UintArg(rowLabel)
|
||||
// field, _ := c.Args["field"].(string)
|
||||
fieldName, _ := c.FieldArg()
|
||||
if fr := idx.Field(fieldName); fr != nil {
|
||||
rowID, _, err := c.UintArg(fieldName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting row")
|
||||
}
|
||||
|
|
@ -386,7 +387,7 @@ func (e *Executor) executeBitmapCall(ctx context.Context, index string, c *pql.C
|
|||
// executeBitmapCallSlice executes a bitmap call for a single slice.
|
||||
func (e *Executor) executeBitmapCallSlice(ctx context.Context, index string, c *pql.Call, slice uint64) (*Row, error) {
|
||||
switch c.Name {
|
||||
case "Bitmap":
|
||||
case "Row":
|
||||
return e.executeBitmapSlice(ctx, index, c, slice)
|
||||
case "Difference":
|
||||
return e.executeDifferenceSlice(ctx, index, c, slice)
|
||||
|
|
@ -585,7 +586,7 @@ func (e *Executor) executeTopNSlices(ctx context.Context, index string, c *pql.C
|
|||
|
||||
// executeTopNSlice executes a TopN call for a single slice.
|
||||
func (e *Executor) executeTopNSlice(ctx context.Context, index string, c *pql.Call, slice uint64) ([]Pair, error) {
|
||||
field, _ := c.Args["field"].(string)
|
||||
field, _ := c.Args["_field"].(string)
|
||||
n, _, err := c.UintArg("n")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("executeTopNSlice: %v", err)
|
||||
|
|
@ -675,24 +676,24 @@ func (e *Executor) executeBitmapSlice(ctx context.Context, index string, c *pql.
|
|||
}
|
||||
|
||||
// Fetch field & row label based on argument.
|
||||
field, _ := c.Args["field"].(string)
|
||||
if field == "" {
|
||||
field = defaultField
|
||||
fieldName, err := c.FieldArg()
|
||||
if err != nil {
|
||||
return nil, errors.New("Row() argument required: field")
|
||||
}
|
||||
f := e.Holder.Field(index, field)
|
||||
f := e.Holder.Field(index, fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
}
|
||||
|
||||
rowID, rowOK, rowErr := c.UintArg(rowLabel)
|
||||
rowID, rowOK, rowErr := c.UintArg(fieldName)
|
||||
if rowErr != nil {
|
||||
return nil, fmt.Errorf("Bitmap() error with arg for row: %v", rowErr)
|
||||
return nil, fmt.Errorf("Row() error with arg for row: %v", rowErr)
|
||||
}
|
||||
if !rowOK {
|
||||
return nil, fmt.Errorf("Bitmap() must specify %v", rowLabel)
|
||||
return nil, fmt.Errorf("Row() must specify %v", rowLabel)
|
||||
}
|
||||
|
||||
frag := e.Holder.Fragment(index, field, ViewStandard, slice)
|
||||
frag := e.Holder.Fragment(index, fieldName, ViewStandard, slice)
|
||||
if frag == nil {
|
||||
return NewRow(), nil
|
||||
}
|
||||
|
|
@ -728,10 +729,10 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C
|
|||
return e.executeBSIGroupRangeSlice(ctx, index, c, slice)
|
||||
}
|
||||
|
||||
// Parse field, use default if unset.
|
||||
field, _ := c.Args["field"].(string)
|
||||
if field == "" {
|
||||
field = defaultField
|
||||
// Parse field.
|
||||
fieldName, err := c.FieldArg()
|
||||
if err != nil {
|
||||
return nil, errors.New("Range() argument required: field")
|
||||
}
|
||||
|
||||
// Retrieve column label.
|
||||
|
|
@ -741,13 +742,13 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C
|
|||
}
|
||||
|
||||
// Retrieve base field.
|
||||
f := idx.Field(field)
|
||||
f := idx.Field(fieldName)
|
||||
if f == nil {
|
||||
return nil, ErrFieldNotFound
|
||||
}
|
||||
|
||||
// Read row & column id.
|
||||
rowID, rowOK, err := c.UintArg(rowLabel)
|
||||
rowID, rowOK, err := c.UintArg(fieldName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("executeRangeSlice - reading row: %v", err)
|
||||
}
|
||||
|
|
@ -756,7 +757,7 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C
|
|||
}
|
||||
|
||||
// Parse start time.
|
||||
startTimeStr, ok := c.Args["start"].(string)
|
||||
startTimeStr, ok := c.Args["_start"].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("Range() start time required")
|
||||
}
|
||||
|
|
@ -766,7 +767,7 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C
|
|||
}
|
||||
|
||||
// Parse end time.
|
||||
endTimeStr, ok := c.Args["end"].(string)
|
||||
endTimeStr, ok := c.Args["_end"].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("Range() end time required")
|
||||
}
|
||||
|
|
@ -784,7 +785,7 @@ func (e *Executor) executeRangeSlice(ctx context.Context, index string, c *pql.C
|
|||
// Union bitmaps across all time-based views.
|
||||
row := &Row{}
|
||||
for _, view := range viewsByTimeRange(ViewStandard, startTime, endTime, q) {
|
||||
f := e.Holder.Fragment(index, field, view, slice)
|
||||
f := e.Holder.Fragment(index, fieldName, view, slice)
|
||||
if f == nil {
|
||||
continue
|
||||
}
|
||||
|
|
@ -994,11 +995,11 @@ func (e *Executor) executeCount(ctx context.Context, index string, c *pql.Call,
|
|||
return n, nil
|
||||
}
|
||||
|
||||
// executeClearBit executes a ClearBit() call.
|
||||
// executeClearBit executes a Clear() call.
|
||||
func (e *Executor) executeClearBit(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) (bool, error) {
|
||||
field, ok := c.Args["field"].(string)
|
||||
if !ok {
|
||||
return false, errors.New("ClearBit() field required")
|
||||
fieldName, err := c.FieldArg()
|
||||
if err != nil {
|
||||
return false, errors.New("Clear() argument required: field")
|
||||
}
|
||||
|
||||
// Retrieve field.
|
||||
|
|
@ -1006,30 +1007,30 @@ func (e *Executor) executeClearBit(ctx context.Context, index string, c *pql.Cal
|
|||
if idx == nil {
|
||||
return false, ErrIndexNotFound
|
||||
}
|
||||
f := idx.Field(field)
|
||||
f := idx.Field(fieldName)
|
||||
if f == nil {
|
||||
return false, ErrFieldNotFound
|
||||
}
|
||||
|
||||
// Read fields using labels.
|
||||
rowID, ok, err := c.UintArg(rowLabel)
|
||||
rowID, ok, err := c.UintArg(fieldName)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading ClearBit() row: %v", err)
|
||||
return false, fmt.Errorf("reading Clear() row: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("ClearBit() row field '%v' required", rowLabel)
|
||||
return false, fmt.Errorf("Clear() row argument '%v' required", rowLabel)
|
||||
}
|
||||
|
||||
colID, ok, err := c.UintArg(columnLabel)
|
||||
colID, ok, err := c.UintArg("_" + columnLabel)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading ClearBit() column: %v", err)
|
||||
return false, fmt.Errorf("reading Clear() column: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("ClearBit col field '%v' required", columnLabel)
|
||||
return false, fmt.Errorf("Clear() col argument '%v' required", columnLabel)
|
||||
}
|
||||
|
||||
return e.executeClearBitField(ctx, index, c, f, colID, rowID, opt)
|
||||
}
|
||||
|
||||
// executeClearBitField executes a ClearBit() call for a single view.
|
||||
// executeClearBitField executes a Clear() call for a single view.
|
||||
func (e *Executor) executeClearBitField(ctx context.Context, index string, c *pql.Call, f *Field, colID, rowID uint64, opt *ExecOptions) (bool, error) {
|
||||
slice := colID / SliceWidth
|
||||
ret := false
|
||||
|
|
@ -1059,11 +1060,11 @@ func (e *Executor) executeClearBitField(ctx context.Context, index string, c *pq
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
// executeSetBit executes a SetBit() call.
|
||||
// executeSetBit executes a Set() call.
|
||||
func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) (bool, error) {
|
||||
field, ok := c.Args["field"].(string)
|
||||
if !ok {
|
||||
return false, errors.New("SetBit() field required: field")
|
||||
fieldName, err := c.FieldArg()
|
||||
if err != nil {
|
||||
return false, errors.New("Set() argument required: field")
|
||||
}
|
||||
|
||||
// Retrieve field.
|
||||
|
|
@ -1071,28 +1072,28 @@ func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call,
|
|||
if idx == nil {
|
||||
return false, ErrIndexNotFound
|
||||
}
|
||||
f := idx.Field(field)
|
||||
f := idx.Field(fieldName)
|
||||
if f == nil {
|
||||
return false, ErrFieldNotFound
|
||||
}
|
||||
|
||||
// Read fields using labels.
|
||||
rowID, ok, err := c.UintArg(rowLabel)
|
||||
rowID, ok, err := c.UintArg(fieldName)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading SetBit() row: %v", err)
|
||||
return false, fmt.Errorf("reading Set() row: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("SetBit() row field '%v' required", rowLabel)
|
||||
return false, fmt.Errorf("Set() row argument '%v' required", rowLabel)
|
||||
}
|
||||
|
||||
colID, ok, err := c.UintArg(columnLabel)
|
||||
colID, ok, err := c.UintArg("_" + columnLabel)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading SetBit() column: %v", err)
|
||||
return false, fmt.Errorf("reading Set() column: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("SetBit() column field '%v' required", columnLabel)
|
||||
return false, fmt.Errorf("Set() column argument '%v' required", columnLabel)
|
||||
}
|
||||
|
||||
var timestamp *time.Time
|
||||
sTimestamp, ok := c.Args["timestamp"].(string)
|
||||
sTimestamp, ok := c.Args["_timestamp"].(string)
|
||||
if ok {
|
||||
t, err := time.Parse(TimeFormat, sTimestamp)
|
||||
if err != nil {
|
||||
|
|
@ -1104,7 +1105,7 @@ func (e *Executor) executeSetBit(ctx context.Context, index string, c *pql.Call,
|
|||
return e.executeSetBitField(ctx, index, c, f, colID, rowID, timestamp, opt)
|
||||
}
|
||||
|
||||
// executeSetBitField executes a SetBit() call for a specific view.
|
||||
// executeSetBitField executes a Set() call for a specific view.
|
||||
func (e *Executor) executeSetBitField(ctx context.Context, index string, c *pql.Call, f *Field, colID, rowID uint64, timestamp *time.Time, opt *ExecOptions) (bool, error) {
|
||||
slice := colID / SliceWidth
|
||||
ret := false
|
||||
|
|
@ -1198,7 +1199,7 @@ func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Cal
|
|||
|
||||
// executeSetRowAttrs executes a SetRowAttrs() call.
|
||||
func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error {
|
||||
fieldName, ok := c.Args["field"].(string)
|
||||
fieldName, ok := c.Args["_field"].(string)
|
||||
if !ok {
|
||||
return errors.New("SetRowAttrs() field required")
|
||||
}
|
||||
|
|
@ -1210,7 +1211,7 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql.
|
|||
}
|
||||
|
||||
// Parse labels.
|
||||
rowID, ok, err := c.UintArg(rowLabel)
|
||||
rowID, ok, err := c.UintArg("_" + rowLabel)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading SetRowAttrs() row: %v", err)
|
||||
} else if !ok {
|
||||
|
|
@ -1219,8 +1220,8 @@ func (e *Executor) executeSetRowAttrs(ctx context.Context, index string, c *pql.
|
|||
|
||||
// Copy args and remove reserved fields.
|
||||
attrs := pql.CopyArgs(c.Args)
|
||||
delete(attrs, "field")
|
||||
delete(attrs, rowLabel)
|
||||
delete(attrs, "_field")
|
||||
delete(attrs, "_"+rowLabel)
|
||||
|
||||
// Set attributes.
|
||||
if err := field.RowAttrStore().SetAttrs(rowID, attrs); err != nil {
|
||||
|
|
@ -1258,7 +1259,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal
|
|||
// Collect attributes by field/id.
|
||||
m := make(map[string]map[uint64]map[string]interface{})
|
||||
for _, c := range calls {
|
||||
field, ok := c.Args["field"].(string)
|
||||
field, ok := c.Args["_field"].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("SetRowAttrs() field required")
|
||||
}
|
||||
|
|
@ -1269,7 +1270,7 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal
|
|||
return nil, ErrFieldNotFound
|
||||
}
|
||||
|
||||
rowID, ok, err := c.UintArg(rowLabel)
|
||||
rowID, ok, err := c.UintArg("_" + rowLabel)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("reading SetRowAttrs() row: %v", rowLabel)
|
||||
} else if !ok {
|
||||
|
|
@ -1278,8 +1279,8 @@ func (e *Executor) executeBulkSetRowAttrs(ctx context.Context, index string, cal
|
|||
|
||||
// Copy args and remove reserved fields.
|
||||
attrs := pql.CopyArgs(c.Args)
|
||||
delete(attrs, "field")
|
||||
delete(attrs, rowLabel)
|
||||
delete(attrs, "_field")
|
||||
delete(attrs, "_"+rowLabel)
|
||||
|
||||
// Create field group, if not exists.
|
||||
fieldMap := m[field]
|
||||
|
|
@ -1348,14 +1349,14 @@ func (e *Executor) executeSetColumnAttrs(ctx context.Context, index string, c *p
|
|||
return ErrIndexNotFound
|
||||
}
|
||||
|
||||
col, okCol, errCol := c.UintArg(columnLabel)
|
||||
col, okCol, errCol := c.UintArg("_" + columnLabel)
|
||||
if errCol != nil || !okCol {
|
||||
return fmt.Errorf("reading SetColumnAttrs() col errs: %v found %v", errCol, okCol)
|
||||
}
|
||||
|
||||
// Copy args and remove reserved fields.
|
||||
attrs := pql.CopyArgs(c.Args)
|
||||
delete(attrs, columnLabel)
|
||||
delete(attrs, "_"+columnLabel)
|
||||
delete(attrs, "field")
|
||||
|
||||
// Set attributes.
|
||||
|
|
@ -1420,9 +1421,9 @@ func (e *Executor) remoteExec(ctx context.Context, node *Node, index string, q *
|
|||
v, err = decodePairs(pb.Results[i].GetPairs()), nil
|
||||
case "Count":
|
||||
v, err = pb.Results[i].N, nil
|
||||
case "SetBit":
|
||||
case "Set":
|
||||
v, err = pb.Results[i].Changed, nil
|
||||
case "ClearBit":
|
||||
case "Clear":
|
||||
v, err = pb.Results[i].Changed, nil
|
||||
case "SetRowAttrs":
|
||||
case "SetColumnAttrs":
|
||||
|
|
@ -1493,6 +1494,7 @@ func (e *Executor) mapReduce(ctx context.Context, index string, slices []uint64,
|
|||
case resp := <-ch:
|
||||
// On error retry against remaining nodes. If an error returns then
|
||||
// the context will cancel and cause all open goroutines to return.
|
||||
|
||||
if resp.err != nil {
|
||||
// Filter out unavailable nodes.
|
||||
nodes = Nodes(nodes).Filter(resp.node)
|
||||
|
|
@ -1591,27 +1593,38 @@ func (e *Executor) mapperLocal(ctx context.Context, slices []uint64, mapFn mapFu
|
|||
}
|
||||
|
||||
func (e *Executor) translateCall(index string, idx *Index, c *pql.Call) error {
|
||||
var colKey, rowKey, fieldName string
|
||||
if c.Name == "Set" || c.Name == "Clear" || c.Name == "Row" {
|
||||
// Positional args in new PQL syntax require special handling here.
|
||||
colKey = "_" + columnLabel
|
||||
fieldName, _ = c.FieldArg()
|
||||
rowKey = fieldName
|
||||
} else {
|
||||
colKey = "col"
|
||||
fieldName = callArgString(c, "field")
|
||||
rowKey = "row"
|
||||
}
|
||||
// Translate column key.
|
||||
if idx.Keys() {
|
||||
if value := callArgString(c, "col"); value != "" {
|
||||
if value := callArgString(c, colKey); value != "" {
|
||||
ids, err := e.TranslateStore.TranslateColumnsToUint64(index, []string{value})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.Args["col"] = ids[0]
|
||||
c.Args[colKey] = ids[0]
|
||||
}
|
||||
}
|
||||
|
||||
// Translate row key, if field is specified & key exists.
|
||||
if fieldName := callArgString(c, "field"); fieldName != "" {
|
||||
if fieldName != "" {
|
||||
field := idx.Field(fieldName)
|
||||
if field.Keys() {
|
||||
if value := callArgString(c, "row"); value != "" {
|
||||
if value := callArgString(c, rowKey); value != "" {
|
||||
ids, err := e.TranslateStore.TranslateRowsToUint64(index, fieldName, []string{value})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.Args["row"] = ids[0]
|
||||
c.Args[rowKey] = ids[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1644,7 +1657,7 @@ func (e *Executor) translateResult(index string, idx *Index, call *pql.Call, res
|
|||
}
|
||||
|
||||
case []Pair:
|
||||
if fieldName := callArgString(call, "field"); fieldName != "" {
|
||||
if fieldName := callArgString(call, "_field"); fieldName != "" {
|
||||
field := idx.Field(fieldName)
|
||||
if field.Keys() {
|
||||
other := make([]Pair, len(result))
|
||||
|
|
@ -1713,7 +1726,7 @@ func needsSlices(calls []*pql.Call) bool {
|
|||
}
|
||||
for _, call := range calls {
|
||||
switch call.Name {
|
||||
case "ClearBit", "SetBit", "SetRowAttrs", "SetColumnAttrs":
|
||||
case "Clear", "Set", "SetRowAttrs", "SetColumnAttrs":
|
||||
continue
|
||||
case "Count", "TopN":
|
||||
return true
|
||||
|
|
|
|||
313
executor_test.go
313
executor_test.go
|
|
@ -44,9 +44,9 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
|
||||
// Set bits.
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(``+
|
||||
fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, 3)+
|
||||
fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, SliceWidth+1)+
|
||||
fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 20, SliceWidth+1),
|
||||
fmt.Sprintf("Set(%d, f=%d)\n", 3, 10)+
|
||||
fmt.Sprintf("Set(%d, f=%d)\n", SliceWidth+1, 10)+
|
||||
fmt.Sprintf("Set(%d, f=%d)\n", SliceWidth+1, 20),
|
||||
), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Row(f=10)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if bits := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(bits, []uint64{3, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected columns: %+v", bits)
|
||||
|
|
@ -63,7 +63,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
}
|
||||
|
||||
// Inhibit column attributes.
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, &pilosa.ExecOptions{ExcludeColumns: true}); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Row(f=10)`), nil, &pilosa.ExecOptions{ExcludeColumns: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
|
|
@ -72,7 +72,7 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
}
|
||||
|
||||
// Inhibit row attributes.
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, &pilosa.ExecOptions{ExcludeRowAttrs: true}); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Row(f=10)`), nil, &pilosa.ExecOptions{ExcludeRowAttrs: true}); 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)
|
||||
|
|
@ -93,9 +93,9 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
|
||||
// Set bits.
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(``+
|
||||
fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, 3)+
|
||||
fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 10, SliceWidth+1)+
|
||||
fmt.Sprintf("SetBit(field=f, row=%d, col=%d)\n", 20, SliceWidth+1),
|
||||
fmt.Sprintf("Set(%d, f=%d)\n", 3, 10)+
|
||||
fmt.Sprintf("Set(%d, f=%d)\n", SliceWidth+1, 10)+
|
||||
fmt.Sprintf("Set(%d, f=%d)\n", SliceWidth+1, 20),
|
||||
), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -116,15 +116,15 @@ func TestExecutor_Execute_Bitmap(t *testing.T) {
|
|||
|
||||
// Set bits.
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(``+
|
||||
`SetBit(field=f, row="bar", col="foo")`+"\n"+
|
||||
`SetBit(field=f, row="baz", col="foo")`+"\n"+
|
||||
`SetBit(field=f, row="bar", col="bat")`+"\n"+
|
||||
`SetBit(field=f, row="bbb", col="aaa")`+"\n",
|
||||
`Set("foo", f="bar")`+"\n"+
|
||||
`Set("foo", f="baz")`+"\n"+
|
||||
`Set("bat", f="bar")`+"\n"+
|
||||
`Set("aaa", f="bbb")`+"\n",
|
||||
), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if results, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row="bar", field=f)`), nil, nil); err != nil {
|
||||
if results, err := e.Execute(context.Background(), "i", test.MustParse(`Row(f="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if diff := cmp.Diff(results, []interface{}{
|
||||
&pilosa.Row{Keys: []string{"foo", "bat"}, Attrs: map[string]interface{}{}},
|
||||
|
|
@ -145,7 +145,7 @@ func TestExecutor_Execute_Difference(t *testing.T) {
|
|||
hldr.SetBit("i", "general", 11, 4)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Difference(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Difference(Row(general=10), Row(general=11))`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, 3}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
|
|
@ -177,7 +177,7 @@ func TestExecutor_Execute_Intersect(t *testing.T) {
|
|||
hldr.SetBit("i", "general", 11, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Intersect(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Intersect(Row(general=10), Row(general=11))`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
|
|
@ -207,7 +207,7 @@ func TestExecutor_Execute_Union(t *testing.T) {
|
|||
hldr.SetBit("i", "general", 11, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Union(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Union(Row(general=10), Row(general=11))`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{0, 2, SliceWidth + 1, SliceWidth + 2}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
|
|
@ -240,7 +240,7 @@ func TestExecutor_Execute_Xor(t *testing.T) {
|
|||
hldr.SetBit("i", "general", 11, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Xor(Bitmap(row=10), Bitmap(row=11))`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Xor(Row(general=10), Row(general=11))`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{0, 2, SliceWidth + 1}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
|
|
@ -256,7 +256,7 @@ func TestExecutor_Execute_Count(t *testing.T) {
|
|||
hldr.SetBit("i", "f", 10, SliceWidth+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, field=f))`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Row(f=10))`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res[0] != uint64(3) {
|
||||
t.Fatalf("unexpected n: %d", res[0])
|
||||
|
|
@ -264,7 +264,7 @@ func TestExecutor_Execute_Count(t *testing.T) {
|
|||
}
|
||||
|
||||
// Ensure a set query can be executed.
|
||||
func TestExecutor_Execute_SetBit(t *testing.T) {
|
||||
func TestExecutor_Execute_Set(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ func TestExecutor_Execute_SetBit(t *testing.T) {
|
|||
t.Fatalf("unexpected bitmap count: %d", n)
|
||||
}
|
||||
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=11, field=f, col=1)`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Set(1, f=11)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if !res[0].(bool) {
|
||||
|
|
@ -287,7 +287,7 @@ func TestExecutor_Execute_SetBit(t *testing.T) {
|
|||
if n := hldr.Row("i", "f", 11).Count(); n != 1 {
|
||||
t.Fatalf("unexpected bitmap count: %d", n)
|
||||
}
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=11, field=f, col=1)`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Set(1, f=11)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if res[0].(bool) {
|
||||
|
|
@ -296,6 +296,21 @@ func TestExecutor_Execute_SetBit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure old PQL syntax doesn't break anything too badly.
|
||||
func TestExecutor_Execute_OldPQL(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
// set a bit so the view gets created.
|
||||
hldr.SetBit("i", "f", 1, 0)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(frame=f, row=11, col=1)`), nil, nil); err == nil || err.Error() != "unknown call: SetBit" {
|
||||
t.Fatal("Expected error: 'unknown call: SetBit'")
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure a SetValue() query can be executed.
|
||||
func TestExecutor_Execute_SetValue(t *testing.T) {
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
|
|
@ -391,16 +406,16 @@ func TestExecutor_Execute_SetRowAttrs(t *testing.T) {
|
|||
// Set two attrs on f/10.
|
||||
// Also set attrs on other bitmaps and fields to test isolation.
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, field=f, foo="bar")`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(f, 10, foo="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=200, field=f, YYY=1)`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(f, 200, YYY=1)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, field=xxx, YYY=1)`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(xxx, 10, YYY=1)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(row=10, field=f, baz=123, bat=true)`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(f, 10, baz=123, bat=true)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -427,15 +442,15 @@ func TestExecutor_Execute_TopN(t *testing.T) {
|
|||
} else if _, err := idx.CreateField("other", pilosa.FieldOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := e.Execute(context.Background(), "i", test.MustParse(`
|
||||
SetBit(field=f, row=0, col=0)
|
||||
SetBit(field=f, row=0, col=1)
|
||||
SetBit(field=f, row=0, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetBit(field=f, row=0, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
SetBit(field=f, row=0, col=`+strconv.Itoa((5*SliceWidth)+100)+`)
|
||||
SetBit(field=f, row=10, col=0)
|
||||
SetBit(field=f, row=10, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetBit(field=f, row=20, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetBit(field=other, row=0, col=0)
|
||||
Set(0, f=0)
|
||||
Set(1, f=0)
|
||||
Set(`+strconv.Itoa(SliceWidth)+`, f=0)
|
||||
Set(`+strconv.Itoa(SliceWidth+2)+`, f=0)
|
||||
Set(`+strconv.Itoa((5*SliceWidth)+100)+`, f=0)
|
||||
Set(0, f=10)
|
||||
Set(`+strconv.Itoa(SliceWidth)+`, f=10)
|
||||
Set(`+strconv.Itoa(SliceWidth)+`, f=20)
|
||||
Set(0, other=0)
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -444,7 +459,7 @@ func TestExecutor_Execute_TopN(t *testing.T) {
|
|||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 1).RecalculateCache()
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 5).RecalculateCache()
|
||||
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=2)`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, n=2)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result[0], []pilosa.Pair{
|
||||
{ID: 0, Count: 5},
|
||||
|
|
@ -467,22 +482,22 @@ func TestExecutor_Execute_TopN(t *testing.T) {
|
|||
} else if _, err := idx.CreateField("other", pilosa.FieldOptions{Keys: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := e.Execute(context.Background(), "i", test.MustParse(`
|
||||
SetBit(field=f, row="foo", col="a")
|
||||
SetBit(field=f, row="foo", col="b")
|
||||
SetBit(field=f, row="foo", col="c")
|
||||
SetBit(field=f, row="foo", col="d")
|
||||
SetBit(field=f, row="foo", col="e")
|
||||
SetBit(field=f, row="bar", col="a")
|
||||
SetBit(field=f, row="bar", col="b")
|
||||
SetBit(field=f, row="baz", col="b")
|
||||
SetBit(field=other, row="foo", col="a")
|
||||
Set("a", f="foo")
|
||||
Set("b", f="foo")
|
||||
Set("c", f="foo")
|
||||
Set("d", f="foo")
|
||||
Set("e", f="foo")
|
||||
Set("a", f="bar")
|
||||
Set("b", f="bar")
|
||||
Set("b", f="baz")
|
||||
Set("a", other="foo")
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
hldr.MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, 0).RecalculateCache()
|
||||
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=2)`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, n=2)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if diff := cmp.Diff(result, []interface{}{
|
||||
[]pilosa.Pair{
|
||||
|
|
@ -509,7 +524,7 @@ func TestExecutor_Execute_TopN_fill(t *testing.T) {
|
|||
|
||||
// Execute query.
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=1)`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, n=1)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{
|
||||
{ID: 0, Count: 4},
|
||||
|
|
@ -543,7 +558,7 @@ func TestExecutor_Execute_TopN_fill_small(t *testing.T) {
|
|||
|
||||
// Execute query.
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=1)`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, n=1)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{
|
||||
{ID: 0, Count: 5},
|
||||
|
|
@ -578,7 +593,7 @@ func TestExecutor_Execute_TopN_Src(t *testing.T) {
|
|||
|
||||
// Execute query.
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=100, field=other), field=f, n=3)`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, Row(other=100), n=3)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{
|
||||
{ID: 20, Count: 3},
|
||||
|
|
@ -602,7 +617,7 @@ func TestExecutor_Execute_TopN_Attr(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{
|
||||
{ID: 10, Count: 1},
|
||||
|
|
@ -625,7 +640,7 @@ func TestExecutor_Execute_TopN_Attr_Src(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(Bitmap(row=10,field=f),field="f", n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, Row(f=10), n=1, attrName="category", attrValues=[123])`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result, []interface{}{[]pilosa.Pair{
|
||||
{ID: 10, Count: 1},
|
||||
|
|
@ -658,20 +673,20 @@ func TestExecutor_Execute_MinMax(t *testing.T) {
|
|||
}
|
||||
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`
|
||||
SetBit(field=x, row=0, col=0)
|
||||
SetBit(field=x, row=0, col=3)
|
||||
SetBit(field=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
SetBit(field=x, row=1, col=1)
|
||||
SetBit(field=x, row=2, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
Set(0, x=0)
|
||||
Set(3, x=0)
|
||||
Set(`+strconv.Itoa(SliceWidth+1)+`, x=0)
|
||||
Set(1, x=1)
|
||||
Set(`+strconv.Itoa(SliceWidth+2)+`, x=2)
|
||||
|
||||
SetValue(f=20, col=0)
|
||||
SetValue(f=-5, col=1)
|
||||
SetValue(f=-5, col=2)
|
||||
SetValue(f=10, col=3)
|
||||
SetValue(f=30, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetValue(f=40, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
SetValue(f=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`)
|
||||
SetValue(f=60, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
SetValue(col=0, f=20)
|
||||
SetValue(col=1, f=-5)
|
||||
SetValue(col=2, f=-5)
|
||||
SetValue(col=3, f=10)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth)+`, f=30)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth+2)+`, f=40)
|
||||
SetValue(col=`+strconv.Itoa((5*SliceWidth)+100)+`, f=50)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth+1)+`, f=60)
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -683,9 +698,9 @@ func TestExecutor_Execute_MinMax(t *testing.T) {
|
|||
cnt int64
|
||||
}{
|
||||
{filter: ``, exp: -5, cnt: 2},
|
||||
{filter: `Bitmap(field=x, row=0)`, exp: 10, cnt: 1},
|
||||
{filter: `Bitmap(field=x, row=1)`, exp: -5, cnt: 1},
|
||||
{filter: `Bitmap(field=x, row=2)`, exp: 40, cnt: 1},
|
||||
{filter: `Row(x=0)`, exp: 10, cnt: 1},
|
||||
{filter: `Row(x=1)`, exp: -5, cnt: 1},
|
||||
{filter: `Row(x=2)`, exp: 40, cnt: 1},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
var pql string
|
||||
|
|
@ -709,9 +724,9 @@ func TestExecutor_Execute_MinMax(t *testing.T) {
|
|||
cnt int64
|
||||
}{
|
||||
{filter: ``, exp: 60, cnt: 1},
|
||||
{filter: `Bitmap(field=x, row=0)`, exp: 60, cnt: 1},
|
||||
{filter: `Bitmap(field=x, row=1)`, exp: -5, cnt: 1},
|
||||
{filter: `Bitmap(field=x, row=2)`, exp: 40, cnt: 1},
|
||||
{filter: `Row(x=0)`, exp: 60, cnt: 1},
|
||||
{filter: `Row(x=1)`, exp: -5, cnt: 1},
|
||||
{filter: `Row(x=2)`, exp: 40, cnt: 1},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
var pql string
|
||||
|
|
@ -769,16 +784,16 @@ func TestExecutor_Execute_Sum(t *testing.T) {
|
|||
}
|
||||
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`
|
||||
SetBit(field=x, row=0, col=0)
|
||||
SetBit(field=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
Set(0, x=0)
|
||||
Set(`+strconv.Itoa(SliceWidth+1)+`, x=0)
|
||||
|
||||
SetValue(foo=20, col=0)
|
||||
SetValue(bar=2000, col=0)
|
||||
SetValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetValue(foo=40, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
SetValue(foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`)
|
||||
SetValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
SetValue(other=1000, col=0)
|
||||
SetValue(col=0, foo=20)
|
||||
SetValue(col=0, bar=2000)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth)+`, foo=30)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth+2)+`, foo=40)
|
||||
SetValue(col=`+strconv.Itoa((5*SliceWidth)+100)+`, foo=50)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth+1)+`, foo=60)
|
||||
SetValue(col=0, other=1000)
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -792,7 +807,7 @@ func TestExecutor_Execute_Sum(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("WithFilter", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Bitmap(field=x, row=0), field=foo)`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Sum(Row(x=0), field=foo)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(result[0], pilosa.ValCount{Val: 80, Count: 2}) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
|
|
@ -801,7 +816,7 @@ func TestExecutor_Execute_Sum(t *testing.T) {
|
|||
}
|
||||
|
||||
// Ensure a range query can be executed.
|
||||
func TestExecutor_Execute_BSIGroupRange(t *testing.T) {
|
||||
func TestExecutor_Execute_Range(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
|
|
@ -818,23 +833,24 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set columns.
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`
|
||||
SetBit(field=f, row=1, col=2, timestamp="1999-12-31T00:00")
|
||||
SetBit(field=f, row=1, col=3, timestamp="2000-01-01T00:00")
|
||||
SetBit(field=f, row=1, col=4, timestamp="2000-01-02T00:00")
|
||||
SetBit(field=f, row=1, col=5, timestamp="2000-02-01T00:00")
|
||||
SetBit(field=f, row=1, col=6, timestamp="2001-01-01T00:00")
|
||||
SetBit(field=f, row=1, col=7, timestamp="2002-01-01T02:00")
|
||||
cc := test.MustParse(`
|
||||
Set(2, f=1, 1999-12-31T00:00)
|
||||
Set(3, f=1, 2000-01-01T00:00)
|
||||
Set(4, f=1, 2000-01-02T00:00)
|
||||
Set(5, f=1, 2000-02-01T00:00)
|
||||
Set(6, f=1, 2001-01-01T00:00)
|
||||
Set(7, f=1, 2002-01-01T02:00)
|
||||
|
||||
SetBit(field=f, row=1, col=2, timestamp="1999-12-30T00:00")
|
||||
SetBit(field=f, row=1, col=2, timestamp="2002-02-01T00:00")
|
||||
SetBit(field=f, row=10, col=2, timestamp="2001-01-01T00:00")
|
||||
`), nil, nil); err != nil {
|
||||
Set(2, f=1, 1999-12-30T00:00)
|
||||
Set(2, f=1, 2002-02-01T00:00)
|
||||
Set(2, f=10, 2001-01-01T00:00)
|
||||
`)
|
||||
if _, err := e.Execute(context.Background(), "i", cc, nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Run("Standard", func(t *testing.T) {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Range(row=1, field=f, start="1999-12-31T00:00", end="2002-01-01T03:00")`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Range(f=1, 1999-12-31T00:00, 2002-01-01T03:00)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{2, 3, 4, 5, 6, 7}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
|
|
@ -843,7 +859,7 @@ func TestExecutor_Execute_BSIGroupRange(t *testing.T) {
|
|||
}
|
||||
|
||||
// Ensure a Range(bsiGroup) query can be executed.
|
||||
func TestExecutor_Execute_Range(t *testing.T) {
|
||||
func TestExecutor_Execute_BSIGroupRange(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
|
|
@ -890,18 +906,18 @@ func TestExecutor_Execute_Range(t *testing.T) {
|
|||
}
|
||||
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`
|
||||
SetBit(field=f, row=0, col=0)
|
||||
SetBit(field=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
Set(0, f=0)
|
||||
Set(`+strconv.Itoa(SliceWidth+1)+`, f=0)
|
||||
|
||||
SetValue(foo=20, col=50)
|
||||
SetValue(bar=2000, col=50)
|
||||
SetValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetValue(foo=10, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
SetValue(foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`)
|
||||
SetValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
SetValue(other=1000, col=0)
|
||||
SetValue(edge=100, col=0)
|
||||
SetValue(edge=-100, col=1)
|
||||
SetValue(col=50, foo=20)
|
||||
SetValue(col=50, bar=2000)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth)+`, foo=30)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth+2)+`, foo=10)
|
||||
SetValue(col=`+strconv.Itoa((5*SliceWidth)+100)+`, foo=20)
|
||||
SetValue(col=`+strconv.Itoa(SliceWidth+1)+`, foo=60)
|
||||
SetValue(col=0, other=1000)
|
||||
SetValue(col=0, edge=100)
|
||||
SetValue(col=1, edge=-100)
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -969,7 +985,7 @@ func TestExecutor_Execute_Range(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("BETWEEN", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(other >< [1, 1000])`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(0 < other < 1000)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
|
|
@ -978,7 +994,7 @@ func TestExecutor_Execute_Range(t *testing.T) {
|
|||
|
||||
// Ensure that the NotNull code path gets run.
|
||||
t.Run("NotNull", func(t *testing.T) {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(other >< [0, 1000])`), nil, nil); err != nil {
|
||||
if result, err := e.Execute(context.Background(), "i", test.MustParse(`Range(-1 < other < 1000)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual([]uint64{0}, result[0].(*pilosa.Row).Columns()) {
|
||||
t.Fatalf("unexpected result: %s", spew.Sdump(result))
|
||||
|
|
@ -1042,7 +1058,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
|
|||
s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
if index != "i" {
|
||||
t.Fatalf("unexpected index: %s", index)
|
||||
} else if query.String() != `Bitmap(field="f", row=10)` {
|
||||
} else if query.String() != `Row(f=10)` {
|
||||
t.Fatalf("unexpected query: %s", query.String())
|
||||
} else if !reflect.DeepEqual(slices, []uint64{1}) {
|
||||
t.Fatalf("unexpected slices: %+v", slices)
|
||||
|
|
@ -1065,7 +1081,7 @@ func TestExecutor_Execute_Remote_Row(t *testing.T) {
|
|||
hldr.SetBit("i", "f", 10, SliceWidth+1)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Bitmap(row=10, field=f)`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Row(f=10)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if columns := res[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{1, 2, 2*SliceWidth + 4}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
|
|
@ -1100,7 +1116,7 @@ func TestExecutor_Execute_Remote_Count(t *testing.T) {
|
|||
hldr.SetBit("i", "f", 10, (2*SliceWidth)+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Bitmap(row=10, field=f))`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`Count(Row(f=10))`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res[0] != uint64(12) {
|
||||
t.Fatalf("unexpected n: %d", res[0])
|
||||
|
|
@ -1128,7 +1144,7 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) {
|
|||
s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
if index != `i` {
|
||||
t.Fatalf("unexpected index: %s", index)
|
||||
} else if query.String() != `SetBit(col=2, field="f", row=10)` {
|
||||
} else if query.String() != `Set(_col=2, f=10)` {
|
||||
t.Fatalf("unexpected query: %s", query.String())
|
||||
}
|
||||
remoteCalled = true
|
||||
|
|
@ -1146,7 +1162,8 @@ func TestExecutor_Execute_Remote_SetBit(t *testing.T) {
|
|||
}
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=10, field=f, col=2)`), nil, nil); err != nil {
|
||||
cc := test.MustParse("Set(2, f=10)")
|
||||
if _, err := e.Execute(context.Background(), "i", cc, nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -1180,7 +1197,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) {
|
|||
s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
if index != `i` {
|
||||
t.Fatalf("unexpected index: %s", index)
|
||||
} else if query.String() != `SetBit(col=2, field="f", row=10, timestamp="2016-12-11T10:09")` {
|
||||
} else if query.String() != `Set(_col=2, _timestamp="2016-12-11T10:09", f=10)` {
|
||||
t.Fatalf("unexpected query: %s", query.String())
|
||||
}
|
||||
remoteCalled = true
|
||||
|
|
@ -1200,7 +1217,8 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) {
|
|||
}
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit(row=10, field=f, col=2, timestamp="2016-12-11T10:09")`), nil, nil); err != nil {
|
||||
cc := test.MustParse(`Set(2, f=10, 2016-12-11T10:09)`)
|
||||
if _, err := e.Execute(context.Background(), "i", cc, nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -1241,11 +1259,11 @@ func TestExecutor_Execute_Remote_TopN(t *testing.T) {
|
|||
// slices and a second time to get the counts for a set of bitmaps.
|
||||
switch remoteExecN {
|
||||
case 0:
|
||||
if query.String() != `TopN(field="f", n=3)` {
|
||||
if query.String() != `TopN(_field="f", n=3)` {
|
||||
t.Fatalf("unexpected query(0): %s", query.String())
|
||||
}
|
||||
case 1:
|
||||
if query.String() != `TopN(field="f", ids=[0,10,30], n=3)` {
|
||||
if query.String() != `TopN(_field="f", ids=[0,10,30], n=3)` {
|
||||
t.Fatalf("unexpected query(1): %s", query.String())
|
||||
}
|
||||
default:
|
||||
|
|
@ -1269,7 +1287,7 @@ func TestExecutor_Execute_Remote_TopN(t *testing.T) {
|
|||
hldr.SetBit("i", "f", 30, (4*SliceWidth)+2)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(field=f, n=3)`), nil, nil); err != nil {
|
||||
if res, err := e.Execute(context.Background(), "i", test.MustParse(`TopN(f, n=3)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(res, []interface{}{[]pilosa.Pair{
|
||||
{ID: 0, Count: 5},
|
||||
|
|
@ -1280,6 +1298,55 @@ func TestExecutor_Execute_Remote_TopN(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure a remote query can set RowAttrs
|
||||
func TestExecutor_Execute_Remote_SetRowAttrs(t *testing.T) {
|
||||
c := pilosa.NewTestCluster(2)
|
||||
|
||||
// Create secondary server and update second cluster node.
|
||||
s := test.NewServer()
|
||||
defer s.Close()
|
||||
|
||||
uri, err := pilosa.NewURIFromAddress(s.Host())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c.Nodes[1].URI = *uri
|
||||
|
||||
// Mock secondary server's executor to verify arguments and return a bitmap.
|
||||
s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
if index != "i" {
|
||||
t.Fatalf("unexpected index: %s", index)
|
||||
} else if query.String() != `SetRowAttrs(_field="f", _row=10, bat=true, baz=123)` {
|
||||
t.Fatalf("unexpected query: %s", query.String())
|
||||
}
|
||||
|
||||
return []interface{}{}, nil
|
||||
}
|
||||
|
||||
// Create local executor data.
|
||||
// The local node owns slice 1.
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
||||
index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
if _, err := index.CreateFieldIfNotExists("f", pilosa.FieldOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f := hldr.Field("i", "f")
|
||||
s.Handler.API.Holder = hldr.Holder
|
||||
hldr.SetBit("i", "f", 10, SliceWidth+1)
|
||||
|
||||
e := test.NewExecutor(hldr.Holder, c)
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetRowAttrs(f, 10, baz=123, bat=true)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if m, err := f.RowAttrStore().Attrs(10); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(m, map[string]interface{}{"bat": true, "baz": int64(123)}) {
|
||||
t.Fatalf("unexpected bitmap attr: %#v", m)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure executor returns an error if too many writes are in a single request.
|
||||
func TestExecutor_Execute_ErrMaxWritesPerRequest(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
|
|
@ -1287,13 +1354,13 @@ func TestExecutor_Execute_ErrMaxWritesPerRequest(t *testing.T) {
|
|||
hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
e.MaxWritesPerRequest = 3
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetBit() ClearBit() SetBit() SetBit()`), nil, nil); err != pilosa.ErrTooManyWrites {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`Set() Clear() Set() Set()`), nil, nil); err != pilosa.ErrTooManyWrites {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure SetColumnAttrs doesn't save `field` as an attribute
|
||||
func TestExectutor_SetColumnAttrs_ExcludeField(t *testing.T) {
|
||||
func TestExecutor_SetColumnAttrs_ExcludeField(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
index := hldr.MustCreateIndexIfNotExists("i", pilosa.IndexOptions{})
|
||||
|
|
@ -1304,11 +1371,11 @@ func TestExectutor_SetColumnAttrs_ExcludeField(t *testing.T) {
|
|||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
|
||||
// SetColumnAttrs call should exclude the field attribute
|
||||
_, err := e.Execute(context.Background(), "i", test.MustParse("SetBit(field='f', row=1, col=10)"), nil, nil)
|
||||
_, err := e.Execute(context.Background(), "i", test.MustParse("Set(10, f=1)"), nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = e.Execute(context.Background(), "i", test.MustParse("SetColumnAttrs(field='f', col=10, foo='bar')"), nil, nil)
|
||||
_, err = e.Execute(context.Background(), "i", test.MustParse("SetColumnAttrs(10, foo='bar')"), nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -1321,11 +1388,11 @@ func TestExectutor_SetColumnAttrs_ExcludeField(t *testing.T) {
|
|||
}
|
||||
|
||||
// SetColumnAttrs call should not break if field is not specified
|
||||
_, err = e.Execute(context.Background(), "i", test.MustParse("SetBit(field='f', row=1, col=20)"), nil, nil)
|
||||
_, err = e.Execute(context.Background(), "i", test.MustParse("Set(20, f=10)"), nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = e.Execute(context.Background(), "i", test.MustParse("SetColumnAttrs(col=20, foo='bar')"), nil, nil)
|
||||
_, err = e.Execute(context.Background(), "i", test.MustParse("SetColumnAttrs(20, foo='bar')"), nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1873,11 +1873,11 @@ func (s *FragmentSyncer) syncBlock(id int) error {
|
|||
|
||||
// Only sync the standard block.
|
||||
for j := 0; j < len(set.columnIDs); j++ {
|
||||
fmt.Fprintf(&(buffers[count/maxWrites]), "SetBit(field=%q, row=%d, col=%d)\n", f.field, set.rowIDs[j], (f.slice*SliceWidth)+set.columnIDs[j])
|
||||
fmt.Fprintf(&(buffers[count/maxWrites]), "Set(%d, %s=%d)\n", (f.slice*SliceWidth)+set.columnIDs[j], f.field, set.rowIDs[j])
|
||||
count++
|
||||
}
|
||||
for j := 0; j < len(clear.columnIDs); j++ {
|
||||
fmt.Fprintf(&(buffers[count/maxWrites]), "ClearBit(field=%q, row=%d, col=%d)\n", f.field, clear.rowIDs[j], (f.slice*SliceWidth)+clear.columnIDs[j])
|
||||
fmt.Fprintf(&(buffers[count/maxWrites]), "Clear(%d, %s=%d)\n", (f.slice*SliceWidth)+clear.columnIDs[j], f.field, clear.rowIDs[j])
|
||||
count++
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ func TestClient_MultiNode(t *testing.T) {
|
|||
|
||||
topN := 4
|
||||
queryRequest := &internal.QueryRequest{
|
||||
Query: fmt.Sprintf(`TopN(field="%s", n=%d)`, "f", topN),
|
||||
Query: fmt.Sprintf(`TopN(f, n=%d)`, topN),
|
||||
Remote: false,
|
||||
}
|
||||
result, err := client[0].Query(context.Background(), "i", queryRequest)
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ func TestHandler_Query_Args_URL(t *testing.T) {
|
|||
h.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
if index != "idx0" {
|
||||
t.Fatalf("unexpected index: %s", index)
|
||||
} else if query.String() != `Count(Bitmap(id=100))` {
|
||||
} else if query.String() != `Count(Row(id=100))` {
|
||||
t.Fatalf("unexpected query: %s", query.String())
|
||||
} else if !reflect.DeepEqual(slices, []uint64{0, 1}) {
|
||||
t.Fatalf("unexpected slices: %+v", slices)
|
||||
|
|
@ -229,7 +229,7 @@ func TestHandler_Query_Args_URL(t *testing.T) {
|
|||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1", strings.NewReader("Count( Bitmap( id=100))")))
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1", strings.NewReader("Count( Row( id=100))")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d %s", w.Code, w.Body.String())
|
||||
} else if body := w.Body.String(); body != `{"results":[100]}`+"\n" {
|
||||
|
|
@ -248,7 +248,7 @@ func TestHandler_Query_Args_Protobuf(t *testing.T) {
|
|||
h.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
if index != "idx0" {
|
||||
t.Fatalf("unexpected index: %s", index)
|
||||
} else if query.String() != `Count(Bitmap(id=100))` {
|
||||
} else if query.String() != `Count(Row(id=100))` {
|
||||
t.Fatalf("unexpected query: %s", query.String())
|
||||
} else if !reflect.DeepEqual(slices, []uint64{0, 1}) {
|
||||
t.Fatalf("unexpected slices: %+v", slices)
|
||||
|
|
@ -258,7 +258,7 @@ func TestHandler_Query_Args_Protobuf(t *testing.T) {
|
|||
|
||||
// Generate request body.
|
||||
reqBody, err := proto.Marshal(&internal.QueryRequest{
|
||||
Query: "Count(Bitmap(id=100))",
|
||||
Query: "Count(Row(id=100))",
|
||||
Slices: []uint64{0, 1},
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -286,7 +286,7 @@ func TestHandler_Query_Args_Err(t *testing.T) {
|
|||
h.API.Cluster = test.NewCluster(1)
|
||||
h.API.Holder = hldr.Holder
|
||||
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=a,b", strings.NewReader("Bitmap(id=100)")))
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=a,b", strings.NewReader("Row(id=100)")))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"invalid slice argument"}`+"\n" {
|
||||
|
|
@ -295,7 +295,7 @@ func TestHandler_Query_Args_Err(t *testing.T) {
|
|||
}
|
||||
func TestHandler_Query_Params_Err(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
test.MustNewHandler().ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1&db=sample", strings.NewReader("Bitmap(id=100)")))
|
||||
test.MustNewHandler().ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1&db=sample", strings.NewReader("Row(id=100)")))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"db is not a valid argument"}`+"\n" {
|
||||
|
|
@ -317,7 +317,7 @@ func TestHandler_Query_Uint64_JSON(t *testing.T) {
|
|||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1", strings.NewReader("Count( Bitmap( id=100))")))
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1", strings.NewReader("Count( Row( id=100))")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"results":[100]}`+"\n" {
|
||||
|
|
@ -338,7 +338,7 @@ func TestHandler_Query_Uint64_Protobuf(t *testing.T) {
|
|||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader("Count(Bitmap(id=100))"))
|
||||
r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader("Count(Row(id=100))"))
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
|
|
@ -370,7 +370,7 @@ func TestHandler_Query_Bitmap_JSON(t *testing.T) {
|
|||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader("Bitmap(id=100)")))
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader("Row(id=100)")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"results":[{"attrs":{"a":"b","c":1,"d":true},"columns":[1,3,66,1048577]}]}`+"\n" {
|
||||
|
|
@ -403,7 +403,7 @@ func TestHandler_Query_Row_ColumnAttrs_JSON(t *testing.T) {
|
|||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query?columnAttrs=true", strings.NewReader("Bitmap(id=100)")))
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query?columnAttrs=true", strings.NewReader("Row(id=100)")))
|
||||
if w.Code != gohttp.StatusOK {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} 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" {
|
||||
|
|
@ -426,7 +426,7 @@ func TestHandler_Query_Row_Protobuf(t *testing.T) {
|
|||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader("Bitmap(id=100)"))
|
||||
r := test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader("Row(id=100)"))
|
||||
r.Header.Set("Accept", "application/x-protobuf")
|
||||
h.ServeHTTP(w, r)
|
||||
if w.Code != gohttp.StatusOK {
|
||||
|
|
@ -475,7 +475,7 @@ func TestHandler_Query_Row_ColumnAttrs_Protobuf(t *testing.T) {
|
|||
|
||||
// Encode request body.
|
||||
buf, err := proto.Marshal(&internal.QueryRequest{
|
||||
Query: "Bitmap(id=100)",
|
||||
Query: "Row(id=100)",
|
||||
ColumnAttrs: true,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -590,7 +590,7 @@ func TestHandler_Query_Err_JSON(t *testing.T) {
|
|||
}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`Bitmap(id=100)`)))
|
||||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/i/query", strings.NewReader(`Row(id=100)`)))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"executing: marker"}`+"\n" {
|
||||
|
|
@ -653,7 +653,7 @@ func TestHandler_Query_ErrParse(t *testing.T) {
|
|||
h.ServeHTTP(w, test.MustNewHTTPRequest("POST", "/index/idx0/query?slices=0,1", strings.NewReader("bad_fn(")))
|
||||
if w.Code != gohttp.StatusBadRequest {
|
||||
t.Fatalf("unexpected status code: %d", w.Code)
|
||||
} else if body := w.Body.String(); body != `{"error":"parsing: parsing: \nparse error near open (line 1 symbol 7 - line 1 symbol 8):\n\"(\"\n"}`+"\n" {
|
||||
} else if body := w.Body.String(); body != `{"error":"parsing: parsing: \nparse error near IDENT (line 1 symbol 1 - line 1 symbol 4):\n\"bad\"\n"}`+"\n" { // TODO not confident
|
||||
t.Fatalf("unexpected body: \n%s", body)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ func TestMain_SendReceiveMessage(t *testing.T) {
|
|||
|
||||
// Write data on first node.
|
||||
if _, err := m0.Query("i", "", `
|
||||
SetBit(row=1, field="f", col=1)
|
||||
SetBit(row=1, field="f", col=2400000)
|
||||
Set(1, f=1)
|
||||
Set(2400000, f=1)
|
||||
`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -259,8 +259,8 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
|
||||
// Write data on first node.
|
||||
if _, err := m0.Query("i", "", `
|
||||
SetBit(row=1, field="f", col=1)
|
||||
SetBit(row=1, field="f", col=1300000)
|
||||
Set(1, f=1)
|
||||
Set(1300000, f=1)
|
||||
`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -311,8 +311,8 @@ func TestClusterResize_AddNode(t *testing.T) {
|
|||
|
||||
// Write data on first node. Note that no data is placed on slice 1.
|
||||
if _, err := m0.Query("i", "", `
|
||||
SetBit(row=1, field="f", col=1)
|
||||
SetBit(row=1, field="f", col=2400000)
|
||||
Set(1, f=1)
|
||||
Set(2400000, f=1)
|
||||
`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -466,7 +466,7 @@ func TestClusterResize_RemoveNode(t *testing.T) {
|
|||
// TODO: Deterministic node IDs would ensure consistent results
|
||||
setColumns := ""
|
||||
for i := 0; i < 20; i++ {
|
||||
setColumns += fmt.Sprintf("SetBit(row=1, field=\"f\", col=%d) ", i*pilosa.SliceWidth)
|
||||
setColumns += fmt.Sprintf("Set(%d, f=1) ", i*pilosa.SliceWidth)
|
||||
}
|
||||
|
||||
if _, err := m0.Query("i", "", setColumns); err != nil {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ type Config struct {
|
|||
Bind string `toml:"bind"`
|
||||
|
||||
// MaxWritesPerRequest limits the number of mutating commands that can be in
|
||||
// a single request to the server. This includes SetBit, ClearBit,
|
||||
// a single request to the server. This includes Set, Clear,
|
||||
// SetRowAttrs & SetColumnAttrs.
|
||||
MaxWritesPerRequest int `toml:"max-writes-per-request"`
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ func TestMain_Set_Quick(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Execute SetBit() commands.
|
||||
// Execute Set() commands.
|
||||
for _, cmd := range cmds {
|
||||
if err := client.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists {
|
||||
t.Fatal(err)
|
||||
|
|
@ -57,7 +57,7 @@ func TestMain_Set_Quick(t *testing.T) {
|
|||
if err := client.CreateField(context.Background(), "i", cmd.Field, pilosa.FieldOptions{}); err != nil && err != pilosa.ErrFieldExists {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := m.Query("i", "", fmt.Sprintf(`SetBit(row=%d, field=%q, col=%d)`, cmd.ID, cmd.Field, cmd.ColumnID)); err != nil {
|
||||
if _, err := m.Query("i", "", fmt.Sprintf(`Set(%d, %s=%d)`, cmd.ColumnID, cmd.Field, cmd.ID)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ func TestMain_Set_Quick(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}) + "\n"
|
||||
if res, err := m.Query("i", "", fmt.Sprintf(`Bitmap(row=%d, field=%q)`, id, field)); err != nil {
|
||||
if res, err := m.Query("i", "", fmt.Sprintf(`Row(%s=%d)`, field, id)); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != exp {
|
||||
t.Fatalf("unexpected result:\n\ngot=%s\n\nexp=%s\n\n", res, exp)
|
||||
|
|
@ -96,7 +96,7 @@ func TestMain_Set_Quick(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}) + "\n"
|
||||
if res, err := m.Query("i", "", fmt.Sprintf(`Bitmap(row=%d, field=%q)`, id, field)); err != nil {
|
||||
if res, err := m.Query("i", "", fmt.Sprintf(`Row(%s=%d)`, field, id)); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != exp {
|
||||
t.Fatalf("unexpected result (reopen):\n\ngot=%s\n\nexp=%s\n\n", res, exp)
|
||||
|
|
@ -132,36 +132,36 @@ func TestMain_SetRowAttrs(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set columns on different rows in different fields.
|
||||
if _, err := m.Query("i", "", `SetBit(row=1, field="x", col=100)`); err != nil {
|
||||
if _, err := m.Query("i", "", `Set(100, x=1)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetBit(row=2, field="x", col=100)`); err != nil {
|
||||
} else if _, err := m.Query("i", "", `Set(100, x=2)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetBit(row=2, field="z", col=100)`); err != nil {
|
||||
} else if _, err := m.Query("i", "", `Set(100, x=2)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetBit(row=3, field="neg", col=100)`); err != nil {
|
||||
} else if _, err := m.Query("i", "", `Set(100, neg=3)`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Set row attributes.
|
||||
if _, err := m.Query("i", "", `SetRowAttrs(row=1, field="x", x=100)`); err != nil {
|
||||
if _, err := m.Query("i", "", `SetRowAttrs(x, 1, x=100)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetRowAttrs(row=2, field="x", x=-200)`); err != nil {
|
||||
} else if _, err := m.Query("i", "", `SetRowAttrs(x, 2, x=-200)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetRowAttrs(row=2, field="z", x=300)`); err != nil {
|
||||
} else if _, err := m.Query("i", "", `SetRowAttrs(z, 2, x=300)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetRowAttrs(row=3, field="neg", x=-0.44)`); err != nil {
|
||||
} else if _, err := m.Query("i", "", `SetRowAttrs(neg, 3, x=-0.44)`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Query row x/1.
|
||||
if res, err := m.Query("i", "", `Bitmap(row=1, field="x")`); err != nil {
|
||||
if res, err := m.Query("i", "", `Row(x=1)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} 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, field="x")`); err != nil {
|
||||
if res, err := m.Query("i", "", `Row(x=2)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{"x":-200},"columns":[100]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
|
|
@ -172,19 +172,19 @@ func TestMain_SetRowAttrs(t *testing.T) {
|
|||
}
|
||||
|
||||
// Query rows after reopening.
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, field="x")`); err != nil {
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Row(x=1)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} 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, field="neg")`); err != nil {
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Row(neg=3)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} 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, field="x")`); err != nil {
|
||||
if res, err := m.Query("i", "", `Row(x=2)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{"x":-200},"columns":[100]}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
|
|
@ -205,19 +205,19 @@ func TestMain_SetColumnAttrs(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set columns on row.
|
||||
if _, err := m.Query("i", "", `SetBit(row=1, field="x", col=100)`); err != nil {
|
||||
if _, err := m.Query("i", "", `Set(100, x=1)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := m.Query("i", "", `SetBit(row=1, field="x", col=101)`); err != nil {
|
||||
} else if _, err := m.Query("i", "", `Set(101, x=1)`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Set column attributes.
|
||||
if _, err := m.Query("i", "", `SetColumnAttrs(col=100, foo="bar")`); err != nil {
|
||||
if _, err := m.Query("i", "", `SetColumnAttrs(100, foo="bar")`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Query row.
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, field="x")`); err != nil {
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Row(x=1)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{},"columns":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" {
|
||||
t.Fatalf("unexpected result: %s", res)
|
||||
|
|
@ -228,7 +228,7 @@ func TestMain_SetColumnAttrs(t *testing.T) {
|
|||
}
|
||||
|
||||
// Query row after reopening.
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Bitmap(row=1, field="x")`); err != nil {
|
||||
if res, err := m.Query("i", "columnAttrs=true", `Row(x=1)`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if res != `{"results":[{"attrs":{},"columns":[100,101]}],"columnAttrs":[{"id":100,"attrs":{"foo":"bar"}}]}`+"\n" {
|
||||
t.Fatalf("unexpected result(reopen): %s", res)
|
||||
|
|
@ -279,7 +279,7 @@ func TestMain_RecalculateHashes(t *testing.T) {
|
|||
data := []string{}
|
||||
for rowID := 1; rowID < 10; rowID++ {
|
||||
for columnID := 1; columnID < 100; columnID++ {
|
||||
data = append(data, fmt.Sprintf(`SetBit(row=%d, field="f", col=%d)`, rowID, columnID))
|
||||
data = append(data, fmt.Sprintf(`Set(%d, f=%d)`, columnID, rowID))
|
||||
}
|
||||
}
|
||||
if _, err := cluster[0].Query("i", "", strings.Join(data, "")); err != nil {
|
||||
|
|
@ -296,7 +296,7 @@ func TestMain_RecalculateHashes(t *testing.T) {
|
|||
|
||||
// Run a TopN query on all nodes. The result should be the same as the target.
|
||||
for _, m := range cluster {
|
||||
res, err := m.Query("i", "", `TopN(field="f")`)
|
||||
res, err := m.Query("i", "", `TopN(f)`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ func TestStatsCount_Bitmap(t *testing.T) {
|
|||
e := test.NewExecutor(hldr.Holder, pilosa.NewTestCluster(1))
|
||||
e.Holder.Stats = &MockStats{
|
||||
mockCountWithTags: func(name string, value int64, rate float64, tags []string) {
|
||||
if name != "Bitmap" {
|
||||
t.Errorf("Expected Bitmap, Results %s", name)
|
||||
if name != "Row" {
|
||||
t.Errorf("Expected Row, Results %s", name)
|
||||
}
|
||||
|
||||
if tags[0] != "index:d" {
|
||||
|
|
@ -138,7 +138,7 @@ func TestStatsCount_Bitmap(t *testing.T) {
|
|||
called = true
|
||||
},
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "d", test.MustParse(`Bitmap(field=f, row=0)`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "d", test.MustParse(`Row(f=0)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !called {
|
||||
|
|
@ -168,7 +168,7 @@ func TestStatsCount_SetColumnAttrs(t *testing.T) {
|
|||
called = true
|
||||
},
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetRowAttrs(row=10, field=f, foo="bar")`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetRowAttrs(f, 10, foo="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !called {
|
||||
|
|
@ -199,7 +199,7 @@ func TestStatsCount_SetProfileAttrs(t *testing.T) {
|
|||
called = true
|
||||
},
|
||||
}
|
||||
if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetColumnAttrs(col=10, field=f, foo="bar")`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "d", test.MustParse(`SetColumnAttrs(10, foo="bar")`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !called {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue