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

Function decode_blocks

arrow-row/src/variable.rs:221–258  ·  view source on GitHub ↗

Decodes a single block of data The `f` function accepts a slice of the decoded data, it may be called multiple times

(row: &[u8], options: SortOptions, mut f: impl FnMut(&[u8]))

Source from the content-addressed store, hash-verified

219/// Decodes a single block of data
220/// The `f` function accepts a slice of the decoded data, it may be called multiple times
221pub fn decode_blocks(row: &[u8], options: SortOptions, mut f: impl FnMut(&[u8])) -> usize {
222 let (non_empty_sentinel, continuation) = match options.descending {
223 true => (!NON_EMPTY_SENTINEL, !BLOCK_CONTINUATION),
224 false => (NON_EMPTY_SENTINEL, BLOCK_CONTINUATION),
225 };
226
227 if row[0] != non_empty_sentinel {
228 // Empty or null string
229 return 1;
230 }
231
232 // Extracts the block length from the sentinel
233 let block_len = |sentinel: u8| match options.descending {
234 true => !sentinel as usize,
235 false => sentinel as usize,
236 };
237
238 let mut idx = 1;
239 for _ in 0..MINI_BLOCK_COUNT {
240 let sentinel = row[idx + MINI_BLOCK_SIZE];
241 if sentinel != continuation {
242 f(&row[idx..idx + block_len(sentinel)]);
243 return idx + MINI_BLOCK_SIZE + 1;
244 }
245 f(&row[idx..idx + MINI_BLOCK_SIZE]);
246 idx += MINI_BLOCK_SIZE + 1;
247 }
248
249 loop {
250 let sentinel = row[idx + BLOCK_SIZE];
251 if sentinel != continuation {
252 f(&row[idx..idx + block_len(sentinel)]);
253 return idx + BLOCK_SIZE + 1;
254 }
255 f(&row[idx..idx + BLOCK_SIZE]);
256 idx += BLOCK_SIZE + 1;
257 }
258}
259
260/// Returns the number of bytes of encoded data
261fn decoded_len(row: &[u8], options: SortOptions) -> usize {

Callers 6

decoded_lenFunction · 0.85
decode_binaryFunction · 0.85
decode_binary_view_innerFunction · 0.85
decodeFunction · 0.85
decode_list_viewFunction · 0.85
decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected