Skip to content

Commit 1d1c78d

Browse files
committedNov 25, 2020
groot/rtree: reduce memory usage in tree-write
only keep one basket when writing. this also reduces somewhat the on-disk size of TBranches.
1 parent 8c71fb8 commit 1d1c78d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎groot/rtree/branch.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,10 @@ func (b *tbranch) setStreamerElement(s rbytes.StreamerElement, ctx rbytes.Stream
711711
}
712712

713713
func (b *tbranch) createNewBasket() {
714-
b.writeBasket = len(b.baskets)
715-
cycle := int16(b.writeBasket)
716-
b.baskets = append(b.baskets, newBasketFrom(b.tree, b, cycle, b.basketSize, b.entryOffsetLen))
717-
b.ctx.bk = &b.baskets[b.writeBasket]
718-
if n := len(b.baskets); n > b.maxBaskets {
714+
cycle := int16(b.writeBasket) + 1
715+
bk := newBasketFrom(b.tree, b, cycle, b.basketSize, b.entryOffsetLen)
716+
b.ctx.bk = &bk
717+
if n := b.writeBasket; n > b.maxBaskets {
719718
b.maxBaskets = n
720719
}
721720
}

0 commit comments

Comments
 (0)