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

Function encode_one

arrow-row/src/variable.rs:163–187  ·  view source on GitHub ↗
(out: &mut [u8], val: Option<&[u8]>, opts: SortOptions)

Source from the content-addressed store, hash-verified

161
162#[inline]
163pub fn encode_one(out: &mut [u8], val: Option<&[u8]>, opts: SortOptions) -> usize {
164 match val {
165 None => encode_null(out, opts),
166 Some([]) => encode_empty(out, opts),
167 Some(val) => {
168 // Write `2_u8` to demarcate as non-empty, non-null string
169 out[0] = NON_EMPTY_SENTINEL;
170
171 let len = if val.len() <= BLOCK_SIZE {
172 1 + encode_blocks::<MINI_BLOCK_SIZE>(&mut out[1..], val)
173 } else {
174 let (initial, rem) = val.split_at(BLOCK_SIZE);
175 let offset = encode_blocks::<MINI_BLOCK_SIZE>(&mut out[1..], initial);
176 out[offset] = BLOCK_CONTINUATION;
177 1 + offset + encode_blocks::<BLOCK_SIZE>(&mut out[1 + offset..], rem)
178 };
179
180 if opts.descending {
181 // Invert bits
182 out[..len].iter_mut().for_each(|v| *v = !*v)
183 }
184 len
185 }
186 }
187}
188
189/// Writes `val` in `SIZE` blocks with the appropriate continuation tokens
190#[inline]

Callers 2

encodeFunction · 0.70
encodeFunction · 0.70

Calls 3

encode_nullFunction · 0.85
encode_emptyFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected