yordan-pavlov commented on a change in pull request #1041:
URL: https://github.com/apache/arrow-rs/pull/1041#discussion_r774811594
##########
File path: parquet/src/column/reader/decoder.rs
##########
@@ -0,0 +1,215 @@
+use std::collections::HashMap;
+use std::ops::Range;
+
+use crate::basic::Encoding;
+use crate::data_type::DataType;
+use crate::decoding::{get_decoder, Decoder, DictDecoder, PlainDecoder};
+use crate::encodings::rle::RleDecoder;
+use crate::errors::{ParquetError, Result};
+use crate::memory::ByteBufferPtr;
+use crate::schema::types::ColumnDescPtr;
+use crate::util::bit_util::BitReader;
+
+/// A type that can have level data written to it by a [`ColumnLevelDecoder`]
+pub trait LevelsWriter {
+ fn capacity(&self) -> usize;
+
+ fn get(&self, idx: usize) -> i16;
+
+ fn count_nulls(&self, range: Range<usize>, max_level: i16) -> usize;
+}
+
+impl LevelsWriter for [i16] {
+ fn capacity(&self) -> usize {
+ self.len()
+ }
+
+ fn get(&self, idx: usize) -> i16 {
+ self[idx]
+ }
+
+ fn count_nulls(&self, range: Range<usize>, max_level: i16) -> usize {
+ self[range].iter().filter(|i| **i != max_level).count()
+ }
+}
+
+/// A type that can have value data written to it by a [`ColumnValueDecoder`]
+pub trait ValuesWriter {
+ fn capacity(&self) -> usize;
+}
+
+impl<T> ValuesWriter for [T] {
+ fn capacity(&self) -> usize {
+ self.len()
+ }
+}
+
+/// Decodes level data to a [`LevelsWriter`]
+pub trait ColumnLevelDecoder {
+ type Writer: LevelsWriter + ?Sized;
+
+ fn create(max_level: i16, encoding: Encoding, data: ByteBufferPtr) -> Self;
Review comment:
wouldn't a `new` method be more idiomatic (instead of `create` )?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]