mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-09 14:41:02 +00:00
rename executor.SetFieldValue() to executor.SetValue()
This commit is contained in:
parent
90a4d957bd
commit
c49fdb7b9b
3 changed files with 39 additions and 39 deletions
14
executor.go
14
executor.go
|
|
@ -138,8 +138,8 @@ func (e *Executor) executeCall(ctx context.Context, index string, c *pql.Call, s
|
|||
return e.executeCount(ctx, index, c, slices, opt)
|
||||
case "SetBit":
|
||||
return e.executeSetBit(ctx, index, c, opt)
|
||||
case "SetFieldValue":
|
||||
return nil, e.executeSetFieldValue(ctx, index, c, opt)
|
||||
case "SetValue":
|
||||
return nil, e.executeSetValue(ctx, index, c, opt)
|
||||
case "SetRowAttrs":
|
||||
return nil, e.executeSetRowAttrs(ctx, index, c, opt)
|
||||
case "SetColumnAttrs":
|
||||
|
|
@ -1107,14 +1107,14 @@ func (e *Executor) executeSetBitView(ctx context.Context, index string, c *pql.C
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
// executeSetFieldValue executes a SetFieldValue() call.
|
||||
func (e *Executor) executeSetFieldValue(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error {
|
||||
// executeSetValue executes a SetValue() call.
|
||||
func (e *Executor) executeSetValue(ctx context.Context, index string, c *pql.Call, opt *ExecOptions) error {
|
||||
// Parse labels.
|
||||
columnID, ok, err := c.UintArg(columnLabel)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reading SetFieldValue() column: %v", err)
|
||||
return fmt.Errorf("reading SetValue() column: %v", err)
|
||||
} else if !ok {
|
||||
return fmt.Errorf("SetFieldValue() column field '%v' required", columnLabel)
|
||||
return fmt.Errorf("SetValue() column field '%v' required", columnLabel)
|
||||
}
|
||||
|
||||
// Copy args and remove reserved fields.
|
||||
|
|
@ -1139,7 +1139,7 @@ func (e *Executor) executeSetFieldValue(ctx context.Context, index string, c *pq
|
|||
default:
|
||||
return ErrInvalidFieldValueType
|
||||
}
|
||||
frame.Stats.Count("SetFieldValue", 1, 1.0)
|
||||
frame.Stats.Count("SetValue", 1, 1.0)
|
||||
}
|
||||
|
||||
// Do not forward call if this is already being forwarded.
|
||||
|
|
|
|||
|
|
@ -263,8 +263,8 @@ func TestExecutor_Execute_SetBit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure a SetFieldValue() query can be executed.
|
||||
func TestExecutor_Execute_SetFieldValue(t *testing.T) {
|
||||
// Ensure a SetValue() query can be executed.
|
||||
func TestExecutor_Execute_SetValue(t *testing.T) {
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
hldr := test.MustOpenHolder()
|
||||
defer hldr.Close()
|
||||
|
|
@ -283,9 +283,9 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) {
|
|||
|
||||
// Set field values.
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f=25)`), nil, nil); err != nil {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f=25)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=100, f=10)`), nil, nil); err != nil {
|
||||
} else if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=100, f=10)`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
@ -321,21 +321,21 @@ func TestExecutor_Execute_SetFieldValue(t *testing.T) {
|
|||
|
||||
t.Run("ErrColumnFieldRequired", func(t *testing.T) {
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name=10, f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(invalid_column_name=10, f=100)`), nil, nil); err == nil || err.Error() != `SetValue() column field 'col' required` {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("ErrColumnFieldValue", func(t *testing.T) {
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(invalid_column_name="bad_column", f=100)`), nil, nil); err == nil || err.Error() != `SetFieldValue() column field 'col' required` {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(invalid_column_name="bad_column", f=100)`), nil, nil); err == nil || err.Error() != `SetValue() column field 'col' required` {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("ErrInvalidFieldValueType", func(t *testing.T) {
|
||||
e := test.NewExecutor(hldr.Holder, test.NewCluster(1))
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetFieldValue(col=10, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` {
|
||||
if _, err := e.Execute(context.Background(), "i", test.MustParse(`SetValue(col=10, f="hello")`), nil, nil); err == nil || err.Error() != `invalid field value type` {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
})
|
||||
|
|
@ -591,14 +591,14 @@ func TestExecutor_Execute_MinMax(t *testing.T) {
|
|||
SetBit(frame=x, row=1, col=1)
|
||||
SetBit(frame=x, row=2, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
|
||||
SetFieldValue(f=20, col=0)
|
||||
SetFieldValue(f=-5, col=1)
|
||||
SetFieldValue(f=-5, col=2)
|
||||
SetFieldValue(f=10, col=3)
|
||||
SetFieldValue(f=30, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetFieldValue(f=40, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
SetFieldValue(f=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`)
|
||||
SetFieldValue(f=60, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
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)+`)
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -699,13 +699,13 @@ func TestExecutor_Execute_Sum(t *testing.T) {
|
|||
SetBit(frame=x, row=0, col=0)
|
||||
SetBit(frame=x, row=0, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
|
||||
SetFieldValue(foo=20, col=0)
|
||||
SetFieldValue(bar=2000, col=0)
|
||||
SetFieldValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetFieldValue(foo=40, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
SetFieldValue(foo=50, col=`+strconv.Itoa((5*SliceWidth)+100)+`)
|
||||
SetFieldValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
SetFieldValue(other=1000, col=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)
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -820,15 +820,15 @@ func TestExecutor_Execute_FieldRange(t *testing.T) {
|
|||
SetBit(frame=f, row=0, col=0)
|
||||
SetBit(frame=f, row=0, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
|
||||
SetFieldValue(foo=20, col=50)
|
||||
SetFieldValue(bar=2000, col=50)
|
||||
SetFieldValue(foo=30, col=`+strconv.Itoa(SliceWidth)+`)
|
||||
SetFieldValue(foo=10, col=`+strconv.Itoa(SliceWidth+2)+`)
|
||||
SetFieldValue(foo=20, col=`+strconv.Itoa((5*SliceWidth)+100)+`)
|
||||
SetFieldValue(foo=60, col=`+strconv.Itoa(SliceWidth+1)+`)
|
||||
SetFieldValue(other=1000, col=0)
|
||||
SetFieldValue(edge=100, col=0)
|
||||
SetFieldValue(edge=-100, col=1)
|
||||
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)
|
||||
`), nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ func TestFrame_SetTimeQuantum(t *testing.T) {
|
|||
}
|
||||
|
||||
// Ensure a frame can set & read a field value.
|
||||
func TestFrame_SetFieldValue(t *testing.T) {
|
||||
func TestFrame_SetValue(t *testing.T) {
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
idx := test.MustOpenIndex()
|
||||
defer idx.Close()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue