Skip to content

Commit

Permalink
Merge pull request #412 from wjohnson-aurora/master
Browse files Browse the repository at this point in the history
Use io.ReadFull in roaring64.Bitmap.ReadFrom
  • Loading branch information
lemire authored Jan 29, 2024
2 parents 0d5af75 + 8c5bae9 commit aec9bd4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions roaring64/roaring64.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ func (rb *Bitmap) FromUnsafeBytes(data []byte) (p int64, err error) {
func (rb *Bitmap) ReadFrom(stream io.Reader) (p int64, err error) {
sizeBuf := make([]byte, 8)
var n int
n, err = stream.Read(sizeBuf)
if n == 0 || err != nil {
n, err = io.ReadFull(stream, sizeBuf)
if err != nil {
return int64(n), err
}
p += int64(n)
Expand All @@ -159,8 +159,8 @@ func (rb *Bitmap) ReadFrom(stream io.Reader) (p int64, err error) {
}
keyBuf := sizeBuf[:4]
for i := uint64(0); i < size; i++ {
n, err = stream.Read(keyBuf)
if n == 0 || err != nil {
n, err = io.ReadFull(stream, keyBuf)
if err != nil {
return int64(n), fmt.Errorf("error in bitmap.readFrom: could not read key #%d: %s", i, err)
}
p += int64(n)
Expand Down

0 comments on commit aec9bd4

Please sign in to comment.