MCPcopy
hub / github.com/ray-project/ray / _align_bit_offset

Function _align_bit_offset

python/ray/_private/arrow_serialization.py:750–764  ·  view source on GitHub ↗

Align the bit offset into the buffer with the front of the buffer by shifting the buffer and eliminating the offset.

(
    buf: "pyarrow.Buffer",
    bit_offset: int,
    byte_length: int,
)

Source from the content-addressed store, hash-verified

748
749
750def _align_bit_offset(
751 buf: "pyarrow.Buffer",
752 bit_offset: int,
753 byte_length: int,
754) -> "pyarrow.Buffer":
755 """Align the bit offset into the buffer with the front of the buffer by shifting
756 the buffer and eliminating the offset.
757 """
758 import pyarrow as pa
759
760 bytes_ = buf.to_pybytes()
761 bytes_as_int = int.from_bytes(bytes_, sys.byteorder)
762 bytes_as_int >>= bit_offset
763 bytes_ = bytes_as_int.to_bytes(byte_length, sys.byteorder)
764 return pa.py_buffer(bytes_)
765
766
767def _arrow_table_ipc_reduce(table: "pyarrow.Table"):

Callers 2

Calls 2

to_bytesMethod · 0.80
from_bytesMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…