paleolimbot commented on code in PR #998:
URL: https://github.com/apache/arrow-nanoarrow/pull/998#discussion_r4406231008


##########
python/src/nanoarrow/iterator.py:
##########
@@ -281,6 +281,26 @@ def _list_iter(self, offset, length):
             for start, end in zip(starts, ends):
                 yield list(islice(child_iter, end - start))
 
+    def _map_iter(self, offset: int, length: int):
+        # A map is a list of (key, value) structs, converted to a list of 
tuples
+        view = self._array_view
+        offset += view.offset
+
+        offsets = memoryview(view.buffer(1))[offset : (offset + length + 1)]
+        starts = offsets[:-1]
+        ends = offsets[1:]
+        entries = self._children[0]
+        entries_iter = entries._struct_tuple_iter(starts[0], ends[-1] - 
starts[0])

Review Comment:
   I believe here we have to handle the zero length case first (before indexing 
into the entries)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to