pub struct ReaderBuilder<R> {
reader: R,
file_size: u64,
batch_size: usize,
range: Option<Range<u64>>,
reader_schema: Option<AvroSchema>,
projection: Option<Vec<usize>>,
header_size_hint: Option<u64>,
utf8_view: bool,
strict_mode: bool,
tz: Tz,
}Expand description
Builder for an asynchronous Avro file reader.
Fields§
§reader: R§file_size: u64§batch_size: usize§range: Option<Range<u64>>§reader_schema: Option<AvroSchema>§projection: Option<Vec<usize>>§header_size_hint: Option<u64>§utf8_view: bool§strict_mode: bool§tz: TzImplementations§
Source§impl<R> ReaderBuilder<R>
impl<R> ReaderBuilder<R>
pub(super) fn new(reader: R, file_size: u64, batch_size: usize) -> Self
Sourcepub fn with_range(self, range: Range<u64>) -> Self
pub fn with_range(self, range: Range<u64>) -> Self
Specify a byte range to read from the Avro file. If this is provided, the reader will read all the blocks within the specified range, if the range ends mid-block, it will attempt to fetch the remaining bytes to complete the block, but no further blocks will be read. If this is omitted, the full file will be read.
Sourcepub fn with_reader_schema(self, reader_schema: AvroSchema) -> Self
pub fn with_reader_schema(self, reader_schema: AvroSchema) -> Self
Specify a reader schema to use when reading the Avro file. This can be useful to project specific columns or handle schema evolution. If this is not provided, the schema will be derived from the Arrow schema provided.
Sourcepub fn with_projection(self, projection: Vec<usize>) -> Self
pub fn with_projection(self, projection: Vec<usize>) -> Self
Specify a projection of column indices to read from the Avro file. This can help optimize reading by only fetching the necessary columns.
Sourcepub fn with_header_size_hint(self, hint: u64) -> Self
pub fn with_header_size_hint(self, hint: u64) -> Self
Provide a hint for the expected size of the Avro header in bytes. This can help optimize the initial read operation when fetching the header.
Sourcepub fn with_utf8_view(self, utf8_view: bool) -> Self
pub fn with_utf8_view(self, utf8_view: bool) -> Self
Enable usage of Utf8View types when reading string data.
Sourcepub fn with_strict_mode(self, strict_mode: bool) -> Self
pub fn with_strict_mode(self, strict_mode: bool) -> Self
Enable strict mode for schema validation and data reading.
Source§impl<R: AsyncFileReader> ReaderBuilder<R>
impl<R: AsyncFileReader> ReaderBuilder<R>
Sourcepub async fn try_build(self) -> Result<AsyncAvroFileReader<R>, AvroError>
pub async fn try_build(self) -> Result<AsyncAvroFileReader<R>, AvroError>
Build the asynchronous Avro reader with the provided parameters. This reads the header first to initialize the reader state.
Sourcepub fn build_with_header(
self,
header_info: HeaderInfo,
) -> Result<AsyncAvroFileReader<R>, AvroError>
pub fn build_with_header( self, header_info: HeaderInfo, ) -> Result<AsyncAvroFileReader<R>, AvroError>
Build the asynchronous Avro reader with the provided header.
This allows initializing the reader with pre-parsed header information. Note that this method is not async because it does not need to perform any I/O operations.
Note: Any header_size_hint set via Self::with_header_size_hint is not used
when building with a pre-parsed header, since no header fetching occurs.