diff --git a/src/encoding/integer/mod.rs b/src/encoding/integer/mod.rs index 02bca71f..f652d4e9 100644 --- a/src/encoding/integer/mod.rs +++ b/src/encoding/integer/mod.rs @@ -24,8 +24,8 @@ use std::{ }; use num::{traits::CheckedShl, PrimInt, Signed}; -use rle_v1::RleReaderV1; -use rle_v2::RleReaderV2; +use rle_v1::RleV1Decoder; +use rle_v2::RleV2Decoder; use snafu::ResultExt; use util::{ get_closest_aligned_bit_width, signed_msb_decode, signed_zigzag_decode, signed_zigzag_encode, @@ -52,10 +52,10 @@ pub fn get_unsigned_rle_reader( ) -> Box + Send> { match column.encoding().kind() { ProtoColumnKind::Direct | ProtoColumnKind::Dictionary => { - Box::new(RleReaderV1::::new(reader)) + Box::new(RleV1Decoder::::new(reader)) } ProtoColumnKind::DirectV2 | ProtoColumnKind::DictionaryV2 => { - Box::new(RleReaderV2::::new(reader)) + Box::new(RleV2Decoder::::new(reader)) } } } @@ -65,8 +65,10 @@ pub fn get_rle_reader( reader: R, ) -> Result + Send>> { match column.encoding().kind() { - ProtoColumnKind::Direct => Ok(Box::new(RleReaderV1::::new(reader))), - ProtoColumnKind::DirectV2 => Ok(Box::new(RleReaderV2::::new(reader))), + ProtoColumnKind::Direct => Ok(Box::new(RleV1Decoder::::new(reader))), + ProtoColumnKind::DirectV2 => { + Ok(Box::new(RleV2Decoder::::new(reader))) + } k => InvalidColumnEncodingSnafu { name: column.name(), encoding: k, diff --git a/src/encoding/integer/rle_v1.rs b/src/encoding/integer/rle_v1.rs index 36545d04..ab9c7766 100644 --- a/src/encoding/integer/rle_v1.rs +++ b/src/encoding/integer/rle_v1.rs @@ -60,14 +60,14 @@ impl EncodingType { } /// Decodes a stream of Integer Run Length Encoded version 1 bytes. -pub struct RleReaderV1 { +pub struct RleV1Decoder { reader: R, decoded_ints: Vec, current_head: usize, sign: PhantomData, } -impl RleReaderV1 { +impl RleV1Decoder { pub fn new(reader: R) -> Self { Self { reader, @@ -137,7 +137,7 @@ fn read_run( Ok(()) } -impl PrimitiveValueDecoder for RleReaderV1 { +impl PrimitiveValueDecoder for RleV1Decoder { // TODO: this is exact duplicate from RLEv2 version; deduplicate it fn decode(&mut self, out: &mut [N]) -> Result<()> { let available = &self.decoded_ints[self.current_head..]; @@ -190,7 +190,7 @@ mod tests { use super::*; fn test_helper(data: &[u8], expected: &[i64]) { - let mut reader = RleReaderV1::::new(Cursor::new(data)); + let mut reader = RleV1Decoder::::new(Cursor::new(data)); let mut actual = vec![0; expected.len()]; reader.decode(&mut actual).unwrap(); assert_eq!(actual, expected); diff --git a/src/encoding/integer/rle_v2/mod.rs b/src/encoding/integer/rle_v2/mod.rs index f176450f..9f654cd3 100644 --- a/src/encoding/integer/rle_v2/mod.rs +++ b/src/encoding/integer/rle_v2/mod.rs @@ -79,7 +79,7 @@ impl EncodingType { } } -pub struct RleReaderV2 { +pub struct RleV2Decoder { reader: R, decoded_ints: Vec, /// Indexes into decoded_ints to make it act like a queue @@ -88,7 +88,7 @@ pub struct RleReaderV2 { sign: PhantomData, } -impl RleReaderV2 { +impl RleV2Decoder { pub fn new(reader: R) -> Self { Self { reader, @@ -131,7 +131,7 @@ impl RleReaderV2 { } } -impl PrimitiveValueDecoder for RleReaderV2 { +impl PrimitiveValueDecoder for RleV2Decoder { fn decode(&mut self, out: &mut [N]) -> Result<()> { let available = &self.decoded_ints[self.current_head..]; // If we have enough in buffer to copy over @@ -256,7 +256,7 @@ impl Default for RleV2EncodingState { } } -pub struct RleWriterV2 { +pub struct RleV2Encoder { /// Stores the run length encoded sequences. data: BytesMut, /// Used in state machine for determining which sub-encoding @@ -265,7 +265,7 @@ pub struct RleWriterV2 { phantom: PhantomData, } -impl RleWriterV2 { +impl RleV2Encoder { // Algorithm adapted from: // https://github.com/apache/orc/blob/main/java/core/src/java/org/apache/orc/impl/RunLengthIntegerWriterV2.java @@ -398,13 +398,13 @@ impl RleWriterV2 { } } -impl EstimateMemory for RleWriterV2 { +impl EstimateMemory for RleV2Encoder { fn estimate_memory_size(&self) -> usize { self.data.len() } } -impl PrimitiveValueEncoder for RleWriterV2 { +impl PrimitiveValueEncoder for RleV2Encoder { fn new() -> Self { Self { data: BytesMut::new(), @@ -549,7 +549,7 @@ mod tests { // multiple times fn test_helper(data: &[u8], expected: &[i64]) { - let mut reader = RleReaderV2::::new(Cursor::new(data)); + let mut reader = RleV2Decoder::::new(Cursor::new(data)); let mut actual = vec![0; expected.len()]; reader.decode(&mut actual).unwrap(); assert_eq!(actual, expected); @@ -668,11 +668,11 @@ mod tests { // currently 99% of the time here the subencoding will be Direct due to random generation fn roundtrip_helper(values: &[N]) -> Result> { - let mut writer = RleWriterV2::::new(); + let mut writer = RleV2Encoder::::new(); writer.write_slice(values); let data = writer.take_inner(); - let mut reader = RleReaderV2::::new(Cursor::new(data)); + let mut reader = RleV2Decoder::::new(Cursor::new(data)); let mut actual = vec![N::zero(); values.len()]; reader.decode(&mut actual).unwrap(); diff --git a/src/writer/column.rs b/src/writer/column.rs index 808c46d6..1174c17f 100644 --- a/src/writer/column.rs +++ b/src/writer/column.rs @@ -31,7 +31,7 @@ use crate::{ boolean::BooleanEncoder, byte::ByteRleEncoder, float::FloatValueEncoder, - integer::{rle_v2::RleWriterV2, NInt, SignedEncoding, UnsignedEncoding}, + integer::{rle_v2::RleV2Encoder, NInt, SignedEncoding, UnsignedEncoding}, PrimitiveValueEncoder, }, error::Result, @@ -263,7 +263,7 @@ where T::Offset: NInt, { string_bytes: BytesMut, - length_encoder: RleWriterV2, + length_encoder: RleV2Encoder, present: Option, encoded_count: usize, } @@ -275,7 +275,7 @@ where pub fn new() -> Self { Self { string_bytes: BytesMut::new(), - length_encoder: RleWriterV2::new(), + length_encoder: RleV2Encoder::new(), present: None, encoded_count: 0, } @@ -393,9 +393,9 @@ where pub type FloatColumnEncoder = PrimitiveColumnEncoder>; pub type DoubleColumnEncoder = PrimitiveColumnEncoder>; pub type ByteColumnEncoder = PrimitiveColumnEncoder; -pub type Int16ColumnEncoder = PrimitiveColumnEncoder>; -pub type Int32ColumnEncoder = PrimitiveColumnEncoder>; -pub type Int64ColumnEncoder = PrimitiveColumnEncoder>; +pub type Int16ColumnEncoder = PrimitiveColumnEncoder>; +pub type Int32ColumnEncoder = PrimitiveColumnEncoder>; +pub type Int64ColumnEncoder = PrimitiveColumnEncoder>; pub type StringColumnEncoder = GenericBinaryColumnEncoder>; pub type LargeStringColumnEncoder = GenericBinaryColumnEncoder>; pub type BinaryColumnEncoder = GenericBinaryColumnEncoder>;