(&mut self, tape: &Tape<'_>, pos: &[u32])
| 48 | |
| 49 | impl<O: OffsetSizeTrait> ArrayDecoder for StringArrayDecoder<O> { |
| 50 | fn decode(&mut self, tape: &Tape<'_>, pos: &[u32]) -> Result<ArrayRef, ArrowError> { |
| 51 | let coerce_primitive = self.coerce_primitive; |
| 52 | |
| 53 | let mut data_capacity = 0; |
| 54 | for p in pos { |
| 55 | match tape.get(*p) { |
| 56 | TapeElement::String(idx) => { |
| 57 | data_capacity += tape.get_string(idx).len(); |
| 58 | } |
| 59 | TapeElement::Null => {} |
| 60 | TapeElement::True if coerce_primitive => { |
| 61 | data_capacity += TRUE.len(); |
| 62 | } |
| 63 | TapeElement::False if coerce_primitive => { |
| 64 | data_capacity += FALSE.len(); |
| 65 | } |
| 66 | TapeElement::Number(idx) if coerce_primitive => { |
| 67 | data_capacity += tape.get_string(idx).len(); |
| 68 | } |
| 69 | TapeElement::I64(_) |
| 70 | | TapeElement::I32(_) |
| 71 | | TapeElement::F64(_) |
| 72 | | TapeElement::F32(_) |
| 73 | if coerce_primitive => |
| 74 | { |
| 75 | // An arbitrary estimate |
| 76 | data_capacity += 10; |
| 77 | } |
| 78 | _ if self.ignore_type_conflicts => {} |
| 79 | _ => { |
| 80 | return Err(tape.error(*p, "string")); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | if O::from_usize(data_capacity).is_none() { |
| 86 | return Err(ArrowError::JsonError(format!( |
| 87 | "offset overflow decoding {}", |
| 88 | GenericStringArray::<O>::DATA_TYPE |
| 89 | ))); |
| 90 | } |
| 91 | |
| 92 | let mut builder = GenericStringBuilder::<O>::with_capacity(pos.len(), data_capacity); |
| 93 | |
| 94 | let mut float_formatter = ryu::Buffer::new(); |
| 95 | let mut int_formatter = itoa::Buffer::new(); |
| 96 | |
| 97 | for p in pos { |
| 98 | match tape.get(*p) { |
| 99 | TapeElement::String(idx) => { |
| 100 | builder.append_value(tape.get_string(idx)); |
| 101 | } |
| 102 | TapeElement::Null => builder.append_null(), |
| 103 | TapeElement::True if coerce_primitive => { |
| 104 | builder.append_value(TRUE); |
| 105 | } |
| 106 | TapeElement::False if coerce_primitive => { |
| 107 | builder.append_value(FALSE); |
nothing calls this directly
no test coverage detected