MCPcopy Create free account
hub / github.com/apache/arrow-rs / make_raw_inline

Function make_raw_inline

arrow-array/src/array/byte_view_array.rs:1609–1620  ·  view source on GitHub ↗

Helper to create a raw u128 value representing an inline ByteView: - `length`: number of meaningful bytes (must be ≤ 12) - `data`: the actual inline data bytes The first 4 bytes encode length in little-endian, the following 12 bytes contain the inline string data (unpadded).

(length: u32, data: &[u8])

Source from the content-addressed store, hash-verified

1607 /// The first 4 bytes encode length in little-endian,
1608 /// the following 12 bytes contain the inline string data (unpadded).
1609 fn make_raw_inline(length: u32, data: &[u8]) -> u128 {
1610 assert!(length as usize <= 12, "Inline length must be ≤ 12");
1611 assert!(
1612 data.len() == length as usize,
1613 "Data length must match `length`"
1614 );
1615
1616 let mut raw_bytes = [0u8; 16];
1617 raw_bytes[0..4].copy_from_slice(&length.to_le_bytes()); // length stored little-endian
1618 raw_bytes[4..(4 + data.len())].copy_from_slice(data); // inline data
1619 u128::from_le_bytes(raw_bytes)
1620 }
1621
1622 // Test inputs: various lengths and lexical orders,
1623 // plus special cases for byte order and length tie-breaking

Calls 2

to_le_bytesMethod · 0.45
lenMethod · 0.45