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

Function estimate_data_capacity

arrow-json/src/reader/binary_array.rs:186–203  ·  view source on GitHub ↗
(tape: &Tape<'_>, pos: &[u32])

Source from the content-addressed store, hash-verified

184}
185
186fn estimate_data_capacity(tape: &Tape<'_>, pos: &[u32]) -> Result<usize, ArrowError> {
187 let mut data_capacity = 0;
188 for p in pos {
189 match tape.get(*p) {
190 TapeElement::String(idx) => {
191 let string_len = tape.get_string(idx).len();
192 // two hex characters represent one byte
193 let decoded_len = string_len.div_ceil(2);
194 data_capacity += decoded_len;
195 }
196 TapeElement::Null => {}
197 _ => {
198 return Err(tape.error(*p, "binary data encoded as string"));
199 }
200 }
201 }
202 Ok(data_capacity)
203}
204
205#[cfg(test)]
206mod tests {

Callers 1

decodeMethod · 0.85

Calls 4

get_stringMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected