From a8b070716d7391aa10bf2ecfc88cfd86212e225b Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 6 Sep 2017 14:41:14 -0500 Subject: [PATCH] reuse fragment memory --- fragment.go | 3 ++- roaring/roaring.go | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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.