mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
refactored clear to fix q2;removed unused comment
This commit is contained in:
parent
26e3460413
commit
643884aeb3
2 changed files with 20 additions and 14 deletions
32
executor.go
32
executor.go
|
|
@ -2650,6 +2650,14 @@ func (e *executor) executeClearBit(ctx context.Context, index string, c *pql.Cal
|
|||
span, ctx := tracing.StartSpanFromContext(ctx, "Executor.executeClearBit")
|
||||
defer span.Finish()
|
||||
|
||||
// Read colID
|
||||
colID, ok, err := c.UintArg("_" + columnLabel)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading Clear() column: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("column argument to Clear(<COLUMN>, <FIELD>=<ROW>) required")
|
||||
}
|
||||
// Read field name.
|
||||
fieldName, err := c.FieldArg()
|
||||
if err != nil {
|
||||
return false, errors.New("Clear() argument required: field")
|
||||
|
|
@ -2664,19 +2672,12 @@ func (e *executor) executeClearBit(ctx context.Context, index string, c *pql.Cal
|
|||
if f == nil {
|
||||
return false, ErrFieldNotFound
|
||||
}
|
||||
// Read fields using labels.
|
||||
rowID, ok, err := c.UintArg(fieldName)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading Clear() row: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("row=<row> argument required to Clear() call")
|
||||
}
|
||||
|
||||
colID, ok, err := c.UintArg("_" + columnLabel)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading Clear() column: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("column argument to Clear(<COLUMN>, <FIELD>=<ROW>) required")
|
||||
// Clear column on existence field
|
||||
if ef := idx.existenceField(); ef != nil {
|
||||
if _, err := ef.ClearBit(0, colID); err != nil {
|
||||
return false, errors.Wrap(err, "clearing existence column")
|
||||
}
|
||||
}
|
||||
|
||||
// Int field.
|
||||
|
|
@ -2684,6 +2685,13 @@ func (e *executor) executeClearBit(ctx context.Context, index string, c *pql.Cal
|
|||
return e.executeClearValueField(ctx, index, c, f, colID, opt)
|
||||
}
|
||||
|
||||
rowID, ok, err := c.UintArg(fieldName)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("reading Clear() row: %v", err)
|
||||
} else if !ok {
|
||||
return false, fmt.Errorf("row=<row> argument required to Clear() call")
|
||||
}
|
||||
|
||||
return e.executeClearBitField(ctx, index, c, f, colID, rowID, opt)
|
||||
}
|
||||
|
||||
|
|
|
|||
2
field.go
2
field.go
|
|
@ -1188,12 +1188,10 @@ func (f *Field) SetValue(columnID uint64, value int64) (changed bool, err error)
|
|||
|
||||
// ClearValue removes a field value for a column.
|
||||
func (f *Field) ClearValue(columnID uint64) (changed bool, err error) {
|
||||
// Fetch bsiGroup & validate min/max.
|
||||
bsig := f.bsiGroup(f.name)
|
||||
if bsig == nil {
|
||||
return false, ErrBSIGroupNotFound
|
||||
}
|
||||
|
||||
// Fetch target view.
|
||||
view := f.view(viewBSIGroupPrefix + f.name)
|
||||
if view == nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue