pub struct ReaderBuilder {
    batch_size: usize,
    coerce_primitive: bool,
    strict_mode: bool,
    is_field: bool,
    struct_mode: StructMode,
    schema: SchemaRef,
}Fields§
§batch_size: usize§coerce_primitive: bool§strict_mode: bool§is_field: bool§struct_mode: StructMode§schema: SchemaRefImplementations§
Source§impl ReaderBuilder
 
impl ReaderBuilder
Sourcepub fn new(schema: SchemaRef) -> Self
 
pub fn new(schema: SchemaRef) -> Self
Create a new ReaderBuilder with the provided [SchemaRef]
This could be obtained using infer_json_schema if not known
Any columns not present in schema will be ignored, unless strict_mode is set to true.
In this case, an error is returned when a column is missing from schema.
Sourcepub fn new_with_field(field: impl Into<FieldRef>) -> Self
 
pub fn new_with_field(field: impl Into<FieldRef>) -> Self
Create a new ReaderBuilder that will parse JSON values of field.data_type()
Unlike ReaderBuilder::new this does not require the root of the JSON data
to be an object, i.e. {..}, allowing for parsing of any valid JSON value(s)
// Root of JSON schema is a numeric type
let data = "1\n2\n3\n";
let field = Arc::new(Field::new("int", DataType::Int32, true));
let mut reader = ReaderBuilder::new_with_field(field.clone()).build(data.as_bytes()).unwrap();
let b = reader.next().unwrap().unwrap();
let values = b.column(0).as_primitive::<Int32Type>().values();
assert_eq!(values, &[1, 2, 3]);
// Root of JSON schema is a list type
let data = "[1, 2, 3, 4, 5, 6, 7]\n[1, 2, 3]";
let field = Field::new_list("int", field.clone(), true);
let mut reader = ReaderBuilder::new_with_field(field).build(data.as_bytes()).unwrap();
let b = reader.next().unwrap().unwrap();
let list = b.column(0).as_list::<i32>();
assert_eq!(list.offsets().as_ref(), &[0, 7, 10]);
let list_values = list.values().as_primitive::<Int32Type>();
assert_eq!(list_values.values(), &[1, 2, 3, 4, 5, 6, 7, 1, 2, 3]);Sourcepub fn with_batch_size(self, batch_size: usize) -> Self
 
pub fn with_batch_size(self, batch_size: usize) -> Self
Sets the batch size in rows to read
Sourcepub fn with_coerce_primitive(self, coerce_primitive: bool) -> Self
 
pub fn with_coerce_primitive(self, coerce_primitive: bool) -> Self
Sets if the decoder should coerce primitive values (bool and number) into string when the Schema’s column is Utf8 or LargeUtf8.
Sourcepub fn with_strict_mode(self, strict_mode: bool) -> Self
 
pub fn with_strict_mode(self, strict_mode: bool) -> Self
Sets if the decoder should return an error if it encounters a column not
present in schema. If struct_mode is ListOnly the value of
strict_mode is effectively true. It is required for all fields of
the struct to be in the list: without field names, there is no way to
determine which field is missing.
Sourcepub fn with_struct_mode(self, struct_mode: StructMode) -> Self
 
pub fn with_struct_mode(self, struct_mode: StructMode) -> Self
Set the StructMode for the reader, which determines whether structs
can be decoded from JSON as objects or lists. For more details refer to
the enum documentation. Default is to use ObjectOnly.
Sourcepub fn build_decoder(self) -> Result<Decoder, ArrowError>
 
pub fn build_decoder(self) -> Result<Decoder, ArrowError>
Create a Decoder