diff --git a/api.go b/api.go index 5bf8d0c21..71fc039a7 100644 --- a/api.go +++ b/api.go @@ -314,8 +314,7 @@ func (api *API) Field(_ context.Context, indexName, fieldName string) (*Field, e // in one long bitmap. func (api *API) ImportRoaringBytes(ctx context.Context, roaringBytes []byte, indexName, fieldName string, shard uint64) (err error) { if err = api.validate(apiField); err != nil { - err = errors.Wrap(err, "validating api method") - return + return errors.Wrap(err, "validating api method") } nodes := api.cluster.shardNodes(indexName, shard) var wg sync.WaitGroup @@ -324,8 +323,7 @@ func (api *API) ImportRoaringBytes(ctx context.Context, roaringBytes []byte, ind if node.ID == api.server.nodeID { field := api.holder.Field(indexName, fieldName) if field == nil { - err = newNotFoundError(ErrFieldNotFound) - return + return newNotFoundError(ErrFieldNotFound) } wg.Add(1) go func(node *Node) { @@ -344,7 +342,7 @@ func (api *API) ImportRoaringBytes(ctx context.Context, roaringBytes []byte, ind } wg.Wait() - return + return err } // DeleteField removes the named field from the named index. If the index is not diff --git a/roaring/roaring.go b/roaring/roaring.go index 9e62f399a..6f6103318 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -3434,10 +3434,7 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error { // Read container offsets and attach data. if haveRuns { - err := readWithRuns(b, data, pos, keyN) - if err != nil { - return errors.Wrap(err, "reading runs from standard roaring format") - } + readWithRuns(b, data, pos, keyN) } else { err := readOffsets(b, data, pos, keyN) if err != nil { @@ -3447,7 +3444,7 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error { return nil } -func readOffsets(b *Bitmap, data []byte, pos int, keyN uint32) (err error) { +func readOffsets(b *Bitmap, data []byte, pos int, keyN uint32) error { citer, _ := b.Containers.Iterator(0) for i, buf := 0, data[pos:]; i < int(keyN); i, buf = i+1, buf[4:] { @@ -3473,11 +3470,10 @@ func readOffsets(b *Bitmap, data []byte, pos int, keyN uint32) (err error) { return fmt.Errorf("unsupported container type %d", c.containerType) } } - return + return nil } -func readWithRuns(b *Bitmap, data []byte, pos int, keyN uint32) (err error) { - +func readWithRuns(b *Bitmap, data []byte, pos int, keyN uint32) { citer, _ := b.Containers.Iterator(0) for i := 0; i < int(keyN); i++ { citer.Next() @@ -3505,6 +3501,4 @@ func readWithRuns(b *Bitmap, data []byte, pos int, keyN uint32) (err error) { pos += bitmapN * 8 } } - return - }