MCPcopy Create free account
hub / github.com/apache/arrow / _get_offsets_buffer

Method _get_offsets_buffer

python/pyarrow/interchange/column.py:508–529  ·  view source on GitHub ↗

Return the buffer containing the offset values for variable-size binary data (e.g., variable-length strings) and the buffer's associated dtype. Raises NoBufferPresent if the data buffer does not have an associated offsets buffer.

(self)

Source from the content-addressed store, hash-verified

506 "does not have a separate mask")
507
508 def _get_offsets_buffer(self) -> Tuple[_PyArrowBuffer, Any]:
509 """
510 Return the buffer containing the offset values for variable-size binary
511 data (e.g., variable-length strings) and the buffer's associated dtype.
512 Raises NoBufferPresent if the data buffer does not have an associated
513 offsets buffer.
514 """
515 array = self._col
516 n = len(array.buffers())
517 if n == 2:
518 raise NoBufferPresent(
519 "This column has a fixed-length dtype so "
520 "it does not have an offsets buffer"
521 )
522 elif n == 3:
523 # Define the dtype of the returned buffer
524 dtype = self._col.type
525 if pa.types.is_large_string(dtype):
526 dtype = (DtypeKind.INT, 64, "l", Endianness.NATIVE)
527 else:
528 dtype = (DtypeKind.INT, 32, "i", Endianness.NATIVE)
529 return _PyArrowBuffer(array.buffers()[1]), dtype

Callers 1

get_buffersMethod · 0.95

Calls 4

_PyArrowBufferClass · 0.90
lenFunction · 0.85
NoBufferPresentClass · 0.85
buffersMethod · 0.80

Tested by

no test coverage detected