Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Feb 9, 2022
1 parent a026b66 commit 40ca3df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/io/avro/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod schema;
mod util;

pub(super) use header::deserialize_header;
pub(super) use schema::convert_schema;
pub(super) use schema::infer_schema;

use crate::array::Array;
use crate::chunk::Chunk;
Expand All @@ -32,7 +32,7 @@ pub fn read_metadata<R: std::io::Read>(
reader: &mut R,
) -> Result<(Vec<AvroSchema>, Schema, Option<Compression>, [u8; 16])> {
let (avro_schema, codec, marker) = util::read_schema(reader)?;
let schema = convert_schema(&avro_schema)?;
let schema = infer_schema(&avro_schema)?;

let avro_schema = if let AvroSchema::Record(Record { fields, .. }) = avro_schema {
fields.into_iter().map(|x| x.schema).collect()
Expand Down
7 changes: 4 additions & 3 deletions src/io/avro/read/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ fn external_props(schema: &AvroSchema) -> Metadata {
props
}

/// Maps an [`AvroSchema`] into a [`Schema`].
pub fn convert_schema(schema: &AvroSchema) -> Result<Schema> {
/// Infers an [`Schema`] from the root [`AvroSchema`].
/// This
pub fn infer_schema(schema: &AvroSchema) -> Result<Schema> {
if let AvroSchema::Record(Record { fields, .. }) = schema {
Ok(fields
.iter()
Expand All @@ -35,7 +36,7 @@ pub fn convert_schema(schema: &AvroSchema) -> Result<Schema> {
.into())
} else {
Err(ArrowError::OutOfSpec(
"An avro Schema must be of type Record".to_string(),
"The root AvroSchema must be of type Record".to_string(),
))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/io/avro/read_async/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use futures::AsyncReadExt;
use crate::datatypes::Schema;
use crate::error::{ArrowError, Result};

use super::super::read::convert_schema;
use super::super::read::deserialize_header;
use super::super::read::infer_schema;
use super::super::Compression;
use super::super::{read_header, read_metadata};
use super::utils::zigzag_i64;
Expand All @@ -28,7 +28,7 @@ pub async fn read_metadata<R: AsyncRead + Unpin + Send>(
reader: &mut R,
) -> Result<(Vec<AvroSchema>, Schema, Option<Compression>, [u8; 16])> {
let (avro_schema, codec, marker) = read_metadata_async(reader).await?;
let schema = convert_schema(&avro_schema)?;
let schema = infer_schema(&avro_schema)?;

let avro_schema = if let AvroSchema::Record(Record { fields, .. }) = avro_schema {
fields.into_iter().map(|x| x.schema).collect()
Expand Down

0 comments on commit 40ca3df

Please sign in to comment.