pitrou commented on a change in pull request #12315:
URL: https://github.com/apache/arrow/pull/12315#discussion_r802522459



##########
File path: cpp/gdb_arrow.py
##########
@@ -1230,15 +1532,245 @@ def type(self):
         return cast_to_concrete(deref(self.val['type']), concrete_type)
 
     def _format_contents(self):
-        return (f"length {self.val['length']}, "
+        return (f"length {self.length}, "
+                f"offset {self.offset}, "
                 f"{format_null_count(self.val['null_count'])}")
 
+    def _buffer(self, index, type_id=None):
+        buffers = StdVector(self.val['buffers'])
+        bufptr = SharedPtr(buffers[index]).get()
+        if int(bufptr) == 0:
+            return None
+        if type_id is not None:
+            return TypedBuffer.from_type_id(bufptr.dereference(), type_id)
+        else:
+            return Buffer(bufptr.dereference())
+
+    def _buffer_values(self, index, type_id, length=None):
+        """
+        Return a typed view of values in the buffer with the given index.
+
+        Values are returned as tuples since some types may decode to
+        multiple values (for example day_time_interval).
+        """
+        buf = self._buffer(index, type_id)
+        if buf is None:
+            return None
+        if length is None:
+            length = self.length
+        return buf.view(self.offset, length)
+
+    def _unpacked_buffer_values(self, index, type_id, length=None):
+        """
+        Like _buffer_values(), but assumes values are 1-tuples
+        and returns them unpacked.
+        """
+        return StarMappedView(identity,
+                              self._buffer_values(index, type_id, length))
+
+    def _null_bitmap(self):
+        buf = self._buffer(0) if has_null_bitmap(self.type_id) else None
+        return NullBitmap.from_buffer(buf, self.offset, self.length)
+
+    def display_hint(self):
+        return None
+
+    def children(self):
+        return ()
+
     def to_string(self):
         ty = self.type
         return (f"{self.name} of type {ty}, "
                 f"{self._format_contents()}")
 
 
+class NumericArrayDataPrinter(ArrayDataPrinter):
+    """
+    ArrayDataPrinter specialization for numeric data types.
+    """
+    _format_value = staticmethod(identity)
+
+    def _values_view(self):
+        return StarMappedView(self._format_value,
+                              self._buffer_values(1, self.type_id))
+
+    def display_hint(self):
+        return "array"
+
+    def children(self):

Review comment:
       See my answer to the other comment. We shouldn't have to worry about 
cutting off, gdb will do that for us following the user's printing 
configuration.




-- 
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