(tape: &Tape<'_>, pos: &[u32])
| 184 | } |
| 185 | |
| 186 | fn 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)] |
| 206 | mod tests { |
no test coverage detected