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)
| 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 |
no test coverage detected