From bb6ccf970ba669bd738264a8c81074334d87af91 Mon Sep 17 00:00:00 2001 From: Jefffrey Date: Wed, 25 Sep 2024 07:03:42 +1000 Subject: [PATCH] Rename FloatIter to FloatDecoder --- src/array_decoder/mod.rs | 6 +++--- src/encoding/float.rs | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/array_decoder/mod.rs b/src/array_decoder/mod.rs index 2de39c1a..612f8733 100644 --- a/src/array_decoder/mod.rs +++ b/src/array_decoder/mod.rs @@ -31,7 +31,7 @@ use snafu::{ensure, ResultExt}; use crate::column::{get_present_vec, Column}; use crate::encoding::boolean::BooleanIter; use crate::encoding::byte::ByteRleReader; -use crate::encoding::float::FloatIter; +use crate::encoding::float::FloatDecoder; use crate::encoding::{get_rle_reader, PrimitiveValueDecoder}; use crate::error::{ self, ArrowSnafu, MismatchedSchemaSnafu, Result, UnexpectedSnafu, UnsupportedTypeVariantSnafu, @@ -404,7 +404,7 @@ pub fn array_decoder_factory( } ); let iter = stripe.stream_map().get(column, Kind::Data); - let iter = Box::new(FloatIter::new(iter)); + let iter = Box::new(FloatDecoder::new(iter)); let present = get_present_vec(column, stripe)? .map(|iter| Box::new(iter.into_iter()) as Box + Send>); Box::new(Float32ArrayDecoder::new(iter, present)) @@ -418,7 +418,7 @@ pub fn array_decoder_factory( } ); let iter = stripe.stream_map().get(column, Kind::Data); - let iter = Box::new(FloatIter::new(iter)); + let iter = Box::new(FloatDecoder::new(iter)); let present = get_present_vec(column, stripe)? .map(|iter| Box::new(iter.into_iter()) as Box + Send>); Box::new(Float64ArrayDecoder::new(iter, present)) diff --git a/src/encoding/float.rs b/src/encoding/float.rs index 394d42b2..06f05433 100644 --- a/src/encoding/float.rs +++ b/src/encoding/float.rs @@ -58,13 +58,12 @@ impl Float for f64 { } } -// TODO: rename to FloatDecoder -pub struct FloatIter { +pub struct FloatDecoder { reader: R, phantom: std::marker::PhantomData, } -impl FloatIter { +impl FloatDecoder { pub fn new(reader: R) -> Self { Self { reader, @@ -73,7 +72,7 @@ impl FloatIter { } } -impl PrimitiveValueDecoder for FloatIter { +impl PrimitiveValueDecoder for FloatDecoder { fn decode(&mut self, out: &mut [T]) -> Result<()> { let mut buf = vec![0; out.len() * T::BYTE_SIZE]; self.reader.read_exact(&mut buf).context(IoSnafu)?; @@ -99,7 +98,7 @@ impl PrimitiveValueDecoder for FloatIter { } // TODO: remove this, currently only needed as we move from iterator to PrimitiveValueDecoder -impl Iterator for FloatIter { +impl Iterator for FloatDecoder { type Item = Result; fn next(&mut self) -> Option { @@ -172,7 +171,7 @@ mod tests { let bytes = float_to_bytes(&input); let bytes = Cursor::new(bytes); - let mut iter = FloatIter::::new(bytes); + let mut iter = FloatDecoder::::new(bytes); let mut actual = vec![F::zero(); input.len()]; iter.decode(&mut actual).unwrap(); @@ -204,7 +203,7 @@ mod tests { let bytes = float_to_bytes(&[f32::NAN]); let bytes = Cursor::new(bytes); - let mut iter = FloatIter::::new(bytes); + let mut iter = FloatDecoder::::new(bytes); let mut actual = vec![0.0; 1]; iter.decode(&mut actual).unwrap(); assert!(actual[0].is_nan()); @@ -215,7 +214,7 @@ mod tests { let bytes = float_to_bytes(&[f64::NAN]); let bytes = Cursor::new(bytes); - let mut iter = FloatIter::::new(bytes); + let mut iter = FloatDecoder::::new(bytes); let mut actual = vec![0.0; 1]; iter.decode(&mut actual).unwrap(); assert!(actual[0].is_nan());