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

Function PackedMaxSpreadBytes

cpp/src/arrow/util/bpacking_dispatch_internal.h:63–74  ·  view source on GitHub ↗

Compute the maximum spread in bytes that a packed integer can cover. This is assuming contiguous packed integer starting with the given bit offset away from a byte boundary. This function is non-monotonic, for instance with zero offset, three bit integers will be split on the first byte boundary (hence having a spread of two bytes) while four bit integer will be well behaved and never spread over

Source from the content-addressed store, hash-verified

61/// four bit integer will be well behaved and never spread over byte boundary (hence
62/// having a spread of one).
63ARROW_FORCE_INLINE constexpr int PackedMaxSpreadBytes(int width, int bit_offset) {
64 int max = static_cast<int>(bit_util::BytesForBits(width));
65 int start = bit_offset;
66 do {
67 const int byte_start = start / 8;
68 const int byte_end = (start + width - 1) / 8; // inclusive end bit
69 const int spread = byte_end - byte_start + 1;
70 max = spread > max ? spread : max;
71 start += width;
72 } while (start % 8 != bit_offset);
73 return max;
74}
75
76/// Compute the maximum spread in bytes that a packed integer can cover across all bit
77/// offsets.

Callers 2

unpack_exactFunction · 0.85
KernelShapeClass · 0.85

Calls 1

BytesForBitsFunction · 0.85

Tested by

no test coverage detected