mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
make view and fragment not found errors constant
based on code review feedback
This commit is contained in:
parent
a3b07ff519
commit
790bea147f
2 changed files with 6 additions and 4 deletions
|
|
@ -1537,7 +1537,8 @@ func executeDistinctShardBSI(ctx context.Context, qcx *Qcx, idx *Index, fieldNam
|
|||
|
||||
existsBitmap, err := tx.OffsetRange(index, fieldName, view, shard, ShardWidth*shard, ShardWidth*0, ShardWidth*1)
|
||||
if err != nil {
|
||||
if _, ok := errors.Cause(err).(ViewOrFragmentNotFound); ok {
|
||||
switch errors.Cause(err) {
|
||||
case ViewNotFound, FragmentNotFound:
|
||||
return result, nil
|
||||
}
|
||||
return result, errors.Wrap(err, "getting exists bitmap")
|
||||
|
|
|
|||
7
rrtx.go
7
rrtx.go
|
|
@ -373,13 +373,13 @@ func (tx *RoaringTx) getFragment(index, field, view string, shard uint64) (*frag
|
|||
|
||||
v := f.view(view)
|
||||
if v == nil {
|
||||
return nil, ViewOrFragmentNotFound(errors.Errorf("view not found: %q", view))
|
||||
return nil, errors.Wrapf(ViewNotFound, "getting %s", view)
|
||||
}
|
||||
|
||||
frag := v.Fragment(shard)
|
||||
|
||||
if frag == nil {
|
||||
return nil, ViewOrFragmentNotFound(errors.Errorf("fragment not found: %q / %q / %d", field, view, shard))
|
||||
return nil, errors.Wrapf(FragmentNotFound, "field:%q, view:%q, shard:%d", field, view, shard)
|
||||
}
|
||||
|
||||
// Note: we cannot cache frag into tx.fragment.
|
||||
|
|
@ -389,7 +389,8 @@ func (tx *RoaringTx) getFragment(index, field, view string, shard uint64) (*frag
|
|||
return frag, nil
|
||||
}
|
||||
|
||||
type ViewOrFragmentNotFound error
|
||||
const ViewNotFound = Error("view not found")
|
||||
const FragmentNotFound = Error("fragment not found")
|
||||
|
||||
func (tx *RoaringTx) bitmap(index, field, view string, shard uint64) (*roaring.Bitmap, error) {
|
||||
frag, err := tx.getFragment(index, field, view, shard)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue