ipld / go-ipld-adl-hamt

Other
4 stars 4 forks source link

Implement map iterator over element links #41

Closed masih closed 2 years ago

masih commented 2 years ago

The map iterator implementation was only handling buckets in the Element unions. This meant that if the length of HAMT is sufficiently large, such that Elements could contain a link to a node, the map iterator would panic.

To avoid this, load the Element link when it is encountered and populate the iterator steps appropriately so that the entire map is traversed.

Add tests that assert the map iterator functions as expected: traverses the entire map, and returns each key exactly once.

Avoid panicing by letting Done proceed and retrospectively return errors via Next as stated in MapIterator.Done interface documentation.

masih commented 2 years ago

Thank you both for the reviews 🙇