阅读器

结构体 Reader 

源代码
pub struct Reader<R: BufRead> {
    reader: R,
    header: Header,
    decoder: Decoder,
    block_decoder: BlockDecoder,
    block_data: Vec<u8>,
    block_count: usize,
    block_cursor: usize,
    finished: bool,
}
展开描述

一个高层级的 Avro 对象容器文件阅读器。

ReaderBufRead 源中拉取块,处理可选的块压缩,并使用内部的 Decoder 将它们逐行解码为 Arrow RecordBatch 值。它实现了

字段§

§reader: R§header: Header§decoder: Decoder§block_decoder: BlockDecoder§block_data: Vec<u8>§block_count: usize§block_cursor: usize§finished: bool

实现§

源文件§

impl<R: BufRead> Reader<R>

源代码

pub fn schema(&self) -> SchemaRef

返回从 Avro 文件头(或通过可选的读取器模式派生)发现的 Arrow 模式。

源代码

pub fn avro_header(&self) -> &Header

返回解析后的 Avro 容器文件头(魔数、元数据、编解码器、同步信息)的引用。

源代码

fn read(&mut self) -> Result<Option<RecordBatch>, ArrowError>

从 Avro 文件读取下一个 RecordBatch,如果到达文件末尾则返回 Ok(None)

批次受 batch_size 限制;单个 OCF 块可能产生多个批次,一个批次也可能跨越多个块。

Trait 实现§

源文件§

impl<R: Debug + BufRead> Debug for Reader<R>

源文件§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

使用给定的格式化程序格式化值。 阅读更多
源文件§

impl<R: BufRead> Iterator for Reader<R>

源文件§

type Item = Result<RecordBatch, ArrowError>

正在迭代的元素的类型。
源文件§

fn next(&mut self) -> Option<Self::Item>

推进迭代器并返回下一个值。阅读更多
源文件§

fn next_chunk<const N: usize>( &mut self, ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>
where Self: Sized,

🔬这是一个仅限夜间构建的实验性 API。(iter_next_chunk)
推进迭代器并返回一个包含接下来的 N 个值的数组。阅读更多
1.0.0 · 源文件§

fn size_hint(&self) -> (usize, Option<usize>)

返回迭代器剩余长度的边界。阅读更多
1.0.0 · 源文件§

fn count(self) -> usize
where Self: Sized,

消耗迭代器,计算迭代次数并返回它。阅读更多
1.0.0 · 源文件§

fn last(self) -> Option<Self::Item>
where Self: Sized,

消耗迭代器,返回最后一个元素。阅读更多
源文件§

fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>

🔬这是一个仅限夜间构建的实验性 API。(iter_advance_by)
将迭代器推进 n 个元素。阅读更多
1.0.0 · 源文件§

fn nth(&mut self, n: usize) -> Option<Self::Item>

返回迭代器的第 n 个元素。阅读更多
1.28.0 · 源文件§

fn step_by(self, step: usize) -> StepBy<Self>
where Self: Sized,

创建一个从同一点开始的迭代器,但每次迭代都按给定步长前进。阅读更多
1.0.0 · 源文件§

fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
where Self: Sized, U: IntoIterator<Item = Self::Item>,

接受两个迭代器并创建一个按顺序迭代两者的迭代器。阅读更多
1.0.0 · 源文件§

fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>
where Self: Sized, U: IntoIterator,

将两个迭代器“打包”成一个对偶迭代器。阅读更多
源文件§

fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
where Self: Sized, Self::Item: Clone,

🔬这是一个仅限夜间构建的实验性 API。(iter_intersperse)
创建一个新的迭代器,它在原始迭代器的相邻项之间放置一个 separator 的副本。阅读更多
源文件§

fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
where Self: Sized, G: FnMut() -> Self::Item,

🔬这是一个仅限夜间构建的实验性 API。(iter_intersperse)
创建一个新的迭代器,它在原始迭代器的相邻项之间放置一个由 separator 生成的项。阅读更多
1.0.0 · 源文件§

fn map<B, F>(self, f: F) -> Map<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> B,

接受一个闭包并创建一个迭代器,该迭代器在每个元素上调用该闭包。阅读更多
1.21.0 · 源文件§

fn for_each<F>(self, f: F)
where Self: Sized, F: FnMut(Self::Item),

对迭代器的每个元素调用一个闭包。阅读更多
1.0.0 · 源文件§

fn filter<P>(self, predicate: P) -> Filter<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

创建一个迭代器,它使用一个闭包来确定是否应产生一个元素。阅读更多
1.0.0 · 源文件§

fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

创建一个既过滤又映射的迭代器。阅读更多
1.0.0 · 源文件§

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

创建一个迭代器,它提供当前迭代计数和下一个值。阅读更多
1.0.0 · 源文件§

fn peekable(self) -> Peekable<Self>
where Self: Sized,

创建一个迭代器,它可以使用 peekpeek_mut 方法查看迭代器的下一个元素而无需消耗它。有关更多信息,请参阅它们的文档。阅读更多
1.0.0 · 源文件§

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

创建一个基于谓词 skip 元素的迭代器。阅读更多
1.0.0 · 源文件§

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

创建一个基于谓词生成元素的迭代器。阅读更多
1.57.0 · 源文件§

fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
where Self: Sized, P: FnMut(Self::Item) -> Option<B>,

创建一个迭代器,它既根据谓词产生元素又进行映射。阅读更多
1.0.0 · 源文件§

fn skip(self, n: usize) -> Skip<Self>
where Self: Sized,

创建一个跳过前 n 个元素的迭代器。阅读更多
1.0.0 · 源文件§

fn take(self, n: usize) -> Take<Self>
where Self: Sized,

创建一个迭代器,它产生前 n 个元素,如果底层迭代器提前结束则更少。阅读更多
1.0.0 · 源文件§

fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option<B>,

一个迭代器适配器,它像 fold 一样维护内部状态,但与 fold 不同,它会生成一个新的迭代器。阅读更多
1.0.0 · 源文件§

fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
where Self: Sized, U: IntoIterator, F: FnMut(Self::Item) -> U,

创建一个迭代器,它像 map 一样工作,但会展平嵌套结构。阅读更多
1.29.0 · 源文件§

fn flatten(self) -> Flatten<Self>
where Self: Sized, Self::Item: IntoIterator,

创建一个迭代器,它会展平嵌套结构。阅读更多
源文件§

fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
where Self: Sized, F: FnMut(&[Self::Item; N]) -> R,

🔬这是一个仅限夜间构建的实验性 API。(iter_map_windows)
self 上每个大小为 N 的连续窗口调用给定函数 f,并返回一个迭代器,该迭代器遍历 f 的输出。与 slice::windows() 类似,映射期间的窗口也会重叠。阅读更多
1.0.0 · 源文件§

fn fuse(self) -> Fuse<Self>
where Self: Sized,

创建一个迭代器,它在第一个 None 之后结束。阅读更多
1.0.0 · 源文件§

fn inspect<F>(self, f: F) -> Inspect<Self, F>
where Self: Sized, F: FnMut(&Self::Item),

对迭代器的每个元素执行操作,并传递该值。阅读更多
1.0.0 · 源文件§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

为此 Iterator 实例创建一个“按引用”适配器。阅读更多
1.0.0 · 源文件§

fn collect<B>(self) -> B
where B: FromIterator<Self::Item>, Self: Sized,

将迭代器转换为集合。阅读更多
源文件§

fn try_collect<B>( &mut self, ) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
where Self: Sized, Self::Item: Try, <Self::Item as Try>::Residual: Residual<B>, B: FromIterator<<Self::Item as Try>::Output>,

🔬这是一个仅限夜间构建的实验性 API。(iterator_try_collect)
将迭代器转换为集合(可能失败),如果遇到失败则短路。阅读更多
源文件§

fn collect_into<E>(self, collection: &mut E) -> &mut E
where E: Extend<Self::Item>, Self: Sized,

🔬这是一个仅限夜间构建的实验性 API。(iter_collect_into)
将迭代器中的所有项收集到一个集合中。阅读更多
1.0.0 · 源文件§

fn partition<B, F>(self, f: F) -> (B, B)
where Self: Sized, B: Default + Extend<Self::Item>, F: FnMut(&Self::Item) -> bool,

消耗一个迭代器,并从中创建两个集合。阅读更多
源文件§

fn is_partitioned<P>(self, predicate: P) -> bool
where Self: Sized, P: FnMut(Self::Item) -> bool,

🔬这是一个仅限夜间构建的实验性 API。(iter_is_partitioned)
检查此迭代器的元素是否根据给定谓词进行分区,使得所有返回 true 的元素都在所有返回 false 的元素之前。阅读更多
1.27.0 · 源文件§

fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
where Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Output = B>,

一个迭代器方法,只要函数成功返回就应用它,产生一个单一的最终值。阅读更多
1.27.0 · 源文件§

fn try_for_each<F, R>(&mut self, f: F) -> R
where Self: Sized, F: FnMut(Self::Item) -> R, R: Try<Output = ()>,

一个迭代器方法,它对迭代器中的每个项应用一个可能失败的函数,在第一个错误处停止并返回该错误。阅读更多
1.0.0 · 源文件§

fn fold<B, F>(self, init: B, f: F) -> B
where Self: Sized, F: FnMut(B, Self::Item) -> B,

通过应用操作将每个元素折叠到累加器中,返回最终结果。阅读更多
1.51.0 · 源文件§

fn reduce<F>(self, f: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item,

通过重复应用归约操作,将元素归约成单个元素。阅读更多
源文件§

fn try_reduce<R>( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
where Self: Sized, R: Try<Output = Self::Item>, <R as Try>::Residual: Residual<Option<Self::Item>>,

🔬这是一个仅限夜间构建的实验性 API。(iterator_try_reduce)
通过重复应用归约操作,将元素归约成单个元素。如果闭包返回失败,则立即将失败传播回调用方。阅读更多
1.0.0 · 源文件§

fn all<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool,

测试迭代器的每个元素是否都匹配一个谓词。阅读更多
1.0.0 · 源文件§

fn any<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool,

测试迭代器的任何元素是否匹配一个谓词。阅读更多
1.0.0 · 源文件§

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

搜索迭代器中满足谓词的元素。阅读更多
1.30.0 · 源文件§

fn find_map<B, F>(&mut self, f: F) -> Option<B>
where Self: Sized, F: FnMut(Self::Item) -> Option<B>,

将函数应用于迭代器的元素,并返回第一个非 None 结果。阅读更多
源文件§

fn try_find<R>( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
where Self: Sized, R: Try<Output = bool>, <R as Try>::Residual: Residual<Option<Self::Item>>,

🔬这是一个仅限夜间构建的实验性 API。(try_find)
将函数应用于迭代器的元素,并返回第一个真结果或第一个错误。阅读更多
1.0.0 · 源文件§

fn position<P>(&mut self, predicate: P) -> Option<usize>
where Self: Sized, P: FnMut(Self::Item) -> bool,

在迭代器中搜索元素,返回其索引。阅读更多
1.0.0 · 源文件§

fn max(self) -> Option<Self::Item>
where Self: Sized, Self::Item: Ord,

返回迭代器的最大元素。阅读更多
1.0.0 · 源文件§

fn min(self) -> Option<Self::Item>
where Self: Sized, Self::Item: Ord,

返回迭代器的最小元素。阅读更多
1.6.0 · 源文件§

fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B,

返回从指定函数中给出最大值的元素。阅读更多
1.15.0 · 源文件§

fn max_by<F>(self, compare: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,

返回相对于指定比较函数给出最大值的元素。阅读更多
1.6.0 · 源文件§

fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
where B: Ord, Self: Sized, F: FnMut(&Self::Item) -> B,

返回从指定函数中给出最小值的元素。阅读更多
1.15.0 · 源文件§

fn min_by<F>(self, compare: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> Ordering,

返回相对于指定比较函数给出最小值的元素。阅读更多
1.0.0 · 源文件§

fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
where FromA: Default + Extend<A>, FromB: Default + Extend<B>, Self: Sized + Iterator<Item = (A, B)>,

将一对迭代器转换为一对容器。阅读更多
1.36.0 · 源文件§

fn copied<'a, T>(self) -> Copied<Self>
where T: Copy + 'a, Self: Sized + Iterator<Item = &'a T>,

创建一个复制所有元素的迭代器。阅读更多
1.0.0 · 源文件§

fn cloned<'a, T>(self) -> Cloned<Self>
where T: Clone + 'a, Self: Sized + Iterator<Item = &'a T>,

创建一个 clone 所有元素的迭代器。阅读更多
源文件§

fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
where Self: Sized,

🔬这是一个仅限夜间构建的实验性 API。(iter_array_chunks)
返回一个迭代器,它一次迭代 N 个元素。阅读更多
1.11.0 · 源文件§

fn sum<S>(self) -> S
where Self: Sized, S: Sum<Self::Item>,

对迭代器的元素求和。阅读更多
1.11.0 · 源文件§

fn product<P>(self) -> P
where Self: Sized, P: Product<Self::Item>,

遍历整个迭代器,将所有元素相乘。阅读更多
1.5.0 · 源文件§

fn cmp<I>(self, other: I) -> Ordering
where I: IntoIterator<Item = Self::Item>, Self::Item: Ord, Self: Sized,

字典式比较此 Iterator 的元素与另一个迭代器的元素。阅读更多
源文件§

fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,

🔬这是一个仅限 nightly 的实验性 API。(iter_order_by)
按字典顺序根据指定的比较函数比较此 Iterator 的元素与另一个迭代器的元素。阅读更多
1.5.0 · 来源§

fn partial_cmp<I>(self, other: I) -> Option<Ordering>
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

按字典顺序比较此 IteratorPartialOrd 元素与另一个迭代器的元素。比较过程类似于短路求值,无需比较剩余元素即可返回结果。一旦可以确定顺序,求值就会停止并返回结果。阅读更多
来源§

fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,

🔬这是一个仅限 nightly 的实验性 API。(iter_order_by)
按字典顺序根据指定的比较函数比较此 Iterator 的元素与另一个迭代器的元素。阅读更多
1.5.0 · 来源§

fn eq<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否与另一个迭代器的元素相等。阅读更多
来源§

fn eq_by<I, F>(self, other: I, eq: F) -> bool
where Self: Sized, I: IntoIterator, F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,

🔬这是一个仅限 nightly 的实验性 API。(iter_order_by)
根据指定的相等函数,确定此 Iterator 的元素是否与另一个迭代器的元素相等。阅读更多
1.5.0 · 来源§

fn ne<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialEq<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否与另一个迭代器的元素不相等。阅读更多
1.5.0 · 来源§

fn lt<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否按字典顺序小于另一个迭代器的元素。阅读更多
1.5.0 · 来源§

fn le<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否按字典顺序小于或等于另一个迭代器的元素。阅读更多
1.5.0 · 来源§

fn gt<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否按字典顺序大于另一个迭代器的元素。阅读更多
1.5.0 · 来源§

fn ge<I>(self, other: I) -> bool
where I: IntoIterator, Self::Item: PartialOrd<<I as IntoIterator>::Item>, Self: Sized,

确定此 Iterator 的元素是否按字典顺序大于或等于另一个迭代器的元素。阅读更多
1.82.0 · 来源§

fn is_sorted(self) -> bool
where Self: Sized, Self::Item: PartialOrd,

检查此迭代器的元素是否已排序。阅读更多
1.82.0 · 来源§

fn is_sorted_by<F>(self, compare: F) -> bool
where Self: Sized, F: FnMut(&Self::Item, &Self::Item) -> bool,

使用给定的比较函数检查此迭代器的元素是否已排序。阅读更多
1.82.0 · 来源§

fn is_sorted_by_key<F, K>(self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> K, K: PartialOrd,

使用给定的键提取函数检查此迭代器的元素是否已排序。阅读更多
来源§

impl<R: BufRead> RecordBatchReader for Reader<R>

来源§

fn schema(&self) -> SchemaRef

返回此 RecordBatchReader 的模式。阅读更多

自动 Trait 实现§

§

impl<R> Freeze for Reader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Reader<R>
where R: RefUnwindSafe,

§

impl<R> Send for Reader<R>
where R: Send,

§

impl<R> Sync for Reader<R>
where R: Sync,

§

impl<R> Unpin for Reader<R>
where R: Unpin,

§

impl<R> UnwindSafe for Reader<R>
where R: UnwindSafe,

通用实现§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

获取 selfTypeId阅读更多
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

从拥有的值进行不可变借用。 阅读更多
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

从拥有的值进行可变借用。 阅读更多
§

impl<T> From<T> for T

§

fn from(t: T) -> T

返回未更改的参数。

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换是 From<T> for U 的实现选择执行的任何操作。

来源§

impl<I> IntoIterator for I
where I: Iterator,

来源§

type Item = <I as Iterator>::Item

正在迭代的元素的类型。
来源§

type IntoIter = I

我们要将它转换成哪种迭代器?
来源§

fn into_iter(self) -> I

从一个值创建迭代器。阅读更多
来源§

impl<I> IteratorRandom for I
where I: Iterator,

来源§

fn choose<R>(self, rng: &mut R) -> Option<Self::Item>
where R: Rng + ?Sized,

均匀地抽取一个元素。阅读更多
来源§

fn choose_stable<R>(self, rng: &mut R) -> Option<Self::Item>
where R: Rng + ?Sized,

均匀地抽取一个元素(稳定)。阅读更多
来源§

fn choose_multiple_fill<R>(self, rng: &mut R, buf: &mut [Self::Item]) -> usize
where R: Rng + ?Sized,

均匀地抽取 amount 个不同的元素到缓冲区中。阅读更多
来源§

fn choose_multiple<R>(self, rng: &mut R, amount: usize) -> Vec<Self::Item>
where R: Rng + ?Sized,

均匀地抽取 amount 个不同的元素到 Vec 中。阅读更多
§

impl<T> Same for T

§

type Output = T

应该总是 Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

转换错误时返回的类型。
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

转换错误时返回的类型。
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,