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

Method decode

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

Source from the content-addressed store, hash-verified

89
90impl<O: OffsetSizeTrait> ArrayDecoder for BinaryArrayDecoder<O> {
91 fn decode(&mut self, tape: &Tape<'_>, pos: &[u32]) -> Result<ArrayRef, ArrowError> {
92 let data_capacity = estimate_data_capacity(tape, pos)?;
93
94 if O::from_usize(data_capacity).is_none() {
95 return Err(ArrowError::JsonError(format!(
96 "offset overflow decoding {}",
97 GenericStringArray::<O>::DATA_TYPE
98 )));
99 }
100
101 let mut builder = GenericBinaryBuilder::<O>::with_capacity(pos.len(), data_capacity);
102
103 for p in pos {
104 match tape.get(*p) {
105 TapeElement::String(idx) => {
106 let string = tape.get_string(idx);
107 // Decode directly into the builder for performance. If decoding fails,
108 // the error is terminal and the builder is discarded by the caller.
109 decode_hex_to_writer(string, &mut builder)?;
110 builder.append_value(b"");
111 }
112 TapeElement::Null => builder.append_null(),
113 _ => unreachable!(),
114 }
115 }
116
117 Ok(Arc::new(builder.finish()))
118 }
119}
120
121#[derive(Default)]

Callers

nothing calls this directly

Calls 10

estimate_data_capacityFunction · 0.85
decode_hex_to_writerFunction · 0.85
get_stringMethod · 0.80
lenMethod · 0.45
getMethod · 0.45
append_valueMethod · 0.45
append_nullMethod · 0.45
finishMethod · 0.45
clearMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected