diff --git a/fragment.go b/fragment.go index 829b4e03b..8d68d08a1 100644 --- a/fragment.go +++ b/fragment.go @@ -312,7 +312,8 @@ func (f *Fragment) close() error { func (f *Fragment) closeStorage() error { // Clear the storage bitmap so it doesn't access the closed mmap. - f.storage = roaring.NewBitmap() + + //f.storage = roaring.NewBitmap() // Unmap the file. if f.storageData != nil { diff --git a/roaring/roaring.go b/roaring/roaring.go index 456c9fccc..54e417744 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -617,9 +617,10 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error { // Read key count in bytes sizeof(cookie):(sizeof(cookie)+sizeof(uint32)). keyN := binary.LittleEndian.Uint32(data[4:8]) - b.keys = make([]uint64, keyN) - b.containers = make([]*container, keyN) - + if int(keyN) != len(b.keys) { + b.keys = make([]uint64, keyN) + b.containers = make([]*container, keyN) + } headerSize := headerBaseSize // Descriptive header section: Read container keys and cardinalities.