pub fn next_batch<I>(&self, value_iter: &mut I) -> Result<Option<RecordBatch>>
    where
        I: Iterator<Item = Result<Value>>,
    {
        let rows = value_iter
            .take(self.batch_size)
            .map(|value| {
                let v = value?;
                match v {
                    Value::Object(_) => Ok(v),
                    _ => Err(ArrowError::Other(format!(
                        "Row needs to be of type object, got: {:?}",
                        v
                    ))),
                }
            })
            .collect::<Result<Vec<_>>>()?;
        let rows = rows.iter().collect::<Vec<_>>();

        if rows.is_empty() {
            // reached end of file
            return Ok(None);
        }

        let projection = self.projection.clone().unwrap_or_else(Vec::new);

        let projected_fields = if projection.is_empty() {
            self.schema.fields().to_vec()
        } else {
            projection
                .iter()
                .map(|name| self.schema.column_with_name(name).map(|x| x.1.clone()))
                .flatten()
                .collect()
        };

        let data_type = DataType::Struct(projected_fields.clone());
        let array = read(&rows, data_type);
        let array = array.as_any().downcast_ref::<StructArray>().unwrap();
        let arrays = array.values().to_vec();

        let projected_schema = Arc::new(Schema::new(projected_fields));

        RecordBatch::try_new(projected_schema, arrays).map(Some)
    }
/// Read the next batch of records
Read the next batch of records
Read the next batch of records
pub fn next_batch<I>(&self, value_iter: &mut I) -> Result<Option<RecordBatch>>
    where
        I: Iterator<Item = Result<Value>>,
    {
        let rows = value_iter
            .take(self.batch_size)
            .map(|value| {
                let v = value?;
                match v {
                    Value::Object(_) => Ok(v),
                    _ => Err(ArrowError::Other(format!(
                        "Row needs to be of type object, got: {:?}",
                        v
                    ))),
                }
            })
            .collect::<Result<Vec<_>>>()?;
        let rows = rows.iter().collect::<Vec<_>>();
        if rows.is_empty() {
            // reached end of file
            return Ok(None);
        }
        let projection = self.projection.clone().unwrap_or_else(Vec::new);
        let projected_fields = if projection.is_empty() {
            self.schema.fields().to_vec()
        } else {
            projection
                .iter()
                .map(|name| self.schema.column_with_name(name).map(|x| x.1.clone()))
                .flatten()
                .collect()
        };
        let data_type = DataType::Struct(projected_fields.clone());
        let array = read(&rows, data_type);
        let array = array.as_any().downcast_ref::<StructArray>().unwrap();
        let arrays = array.values().to_vec();
        let projected_schema = Arc::new(Schema::new(projected_fields));
        RecordBatch::try_new(projected_schema, arrays).map(Some)
    }
pub fn next_batch < I > ( & self , value_iter : & mut I ) -> Result < Option < RecordBatch > > where I : Iterator < Item = Result < Value > > , { let rows = value_iter . take ( self . batch_size ) . map ( | value | { let v = value ? ; match v { Value :: Object ( _ ) => Ok ( v ) , _ => Err ( ArrowError :: Other ( format ! ( " " v ) ) ) , } } ) . collect :: < Result < Vec < _ > > > ( ) ? ; let rows = rows . iter ( ) . collect :: < Vec < _ > > ( ) ; if rows . is_empty ( ) { // reached end of file return Ok ( None ) ; } let projection = self . projection . clone ( ) . unwrap_or_else ( Vec :: new ) ; let projected_fields = if projection . is_empty ( ) { self . schema . fields ( ) . to_vec ( ) } else { projection . iter ( ) . map ( | name | self . schema . column_with_name ( name ) . map ( | x | x . 1 . clone ( ) ) ) . flatten ( ) . collect ( ) } ; let data_type = DataType :: Struct ( projected_fields . clone ( ) ) ; let array = read ( & rows , data_type ) ; let array = array . as_any ( ) . downcast_ref :: < StructArray > ( ) . unwrap ( ) ; let arrays = array . values ( ) . to_vec ( ) ; let projected_schema = Arc :: new ( Schema :: new ( projected_fields ) ) ; RecordBatch :: try_new ( projected_schema , arrays ) . map ( Some ) }
Read the next batch of records
Read the next batch of records
&self
value_iter
&mut I