dolthub / swiss

Golang port of Abseil's SwissTable
Apache License 2.0
772 stars 39 forks source link

fix: deep remove kvs by clear #15

Closed rfyiamcool closed 1 year ago

rfyiamcool commented 1 year ago

change

the groups structure needs to be reset when clear swiss map ? if reset medata to empty, the memory not be cleaned.

reltuk commented 1 year ago

I'm not certain that this change is correct as currently written, since it doesn't track sz and I think len(m.ctrl) and len(m.groups) will diverge here.

But, that being said, I'm not certain if Clear() should be clearing groups in general. We don't clear entries in groups for (*Map).Delete().

I can see how it would be compelling in general to clear the groups entry if there are retained pointers or slices in particular, since those will effectively leak otherwise.

Let me consult internally and see if this is something we want to change in general. I'll follow up on this PR shortly.

Thank you for the contribution!

reltuk commented 1 year ago

I've just opened #16 as an alternative implementation and would appreciate your thoughts.

reltuk commented 1 year ago

I merged #16 instead. Thanks again for your contribution and please do not hesitate to reach out if you have any follow up here.