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

Method build_decoder

arrow-json/src/reader/mod.rs:326–353  ·  view source on GitHub ↗

Create a [`Decoder`]

(self)

Source from the content-addressed store, hash-verified

324
325 /// Create a [`Decoder`]
326 pub fn build_decoder(self) -> Result<Decoder, ArrowError> {
327 let (data_type, nullable) = if self.is_field {
328 let field = &self.schema.fields[0];
329 let data_type = Cow::Borrowed(field.data_type());
330 (data_type, field.is_nullable())
331 } else {
332 let data_type = Cow::Owned(DataType::Struct(self.schema.fields.clone()));
333 (data_type, false)
334 };
335
336 let ctx = DecoderContext {
337 coerce_primitive: self.coerce_primitive,
338 strict_mode: self.strict_mode,
339 struct_mode: self.struct_mode,
340 ignore_type_conflicts: self.ignore_type_conflicts,
341 };
342 let decoder = ctx.make_decoder(data_type.as_ref(), nullable)?;
343
344 let num_fields = self.schema.flattened_fields().len();
345
346 Ok(Decoder {
347 decoder,
348 is_field: self.is_field,
349 tape_decoder: TapeDecoder::new(self.batch_size, num_fields),
350 batch_size: self.batch_size,
351 schema: self.schema,
352 })
353 }
354}
355
356/// Reads JSON data with a known schema directly into arrow [`RecordBatch`]

Callers 15

do_benchFunction · 0.45
bench_decode_schemaFunction · 0.45
bench_serialize_valuesFunction · 0.45
bench_decode_binaryFunction · 0.45
buildMethod · 0.45
test_basicFunction · 0.45
test_decoder_errorFunction · 0.45
test_serialize_timestampFunction · 0.45
test_serialize_decimalFunction · 0.45
test_serde_fieldFunction · 0.45

Calls 7

flattened_fieldsMethod · 0.80
data_typeMethod · 0.45
is_nullableMethod · 0.45
cloneMethod · 0.45
make_decoderMethod · 0.45
as_refMethod · 0.45
lenMethod · 0.45