refactor: address PR feedback
parent
e40fecb1ff
commit
cc39bf3cb4
|
@ -198,9 +198,8 @@ where
|
|||
match col_writer {
|
||||
BoolColumnWriter(ref mut w) => {
|
||||
let p = packer.bool_packer();
|
||||
let rep_levels = vec![0; p.num_rows()];
|
||||
let n = w
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), Some(&rep_levels))
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), None)
|
||||
.context(ParquetLibraryError {
|
||||
message: String::from("Can't write_batch with bool values"),
|
||||
})?;
|
||||
|
@ -209,9 +208,8 @@ where
|
|||
Int32ColumnWriter(_) => unreachable!("ParquetWriter does not support INT32 data"),
|
||||
Int64ColumnWriter(ref mut w) => {
|
||||
let p = packer.i64_packer();
|
||||
let rep_levels = vec![0; p.num_rows()];
|
||||
let n = w
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), Some(&rep_levels))
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), None)
|
||||
.context(ParquetLibraryError {
|
||||
message: String::from("Can't write_batch with int64 values"),
|
||||
})?;
|
||||
|
@ -223,9 +221,8 @@ where
|
|||
}
|
||||
DoubleColumnWriter(ref mut w) => {
|
||||
let p = packer.f64_packer();
|
||||
let rep_levels = vec![0; p.num_rows()];
|
||||
let n = w
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), Some(&rep_levels))
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), None)
|
||||
.context(ParquetLibraryError {
|
||||
message: String::from("Can't write_batch with f64 values"),
|
||||
})?;
|
||||
|
@ -233,9 +230,8 @@ where
|
|||
}
|
||||
ByteArrayColumnWriter(ref mut w) => {
|
||||
let p = packer.str_packer();
|
||||
let rep_levels = vec![0; p.num_rows()];
|
||||
let n = w
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), Some(&rep_levels))
|
||||
.write_batch(&p.some_values(), Some(&p.def_levels()), None)
|
||||
.context(ParquetLibraryError {
|
||||
message: String::from("Can't write_batch with byte array values"),
|
||||
})?;
|
||||
|
|
|
@ -232,9 +232,7 @@ where
|
|||
self.values.len()
|
||||
}
|
||||
|
||||
/// Get the value of logical row at `index`. This may be different
|
||||
/// than the index in self.values.len() when NULLs are present
|
||||
/// because there are no values in self.values stored for NULL
|
||||
/// Get the value of logical row at `index`.
|
||||
pub fn get(&self, index: usize) -> Option<&T> {
|
||||
self.values[index].as_ref()
|
||||
}
|
||||
|
@ -253,13 +251,10 @@ where
|
|||
|
||||
/// returns a binary vector indicating which indexes have null values.
|
||||
pub fn def_levels(&self) -> Vec<i16> {
|
||||
let mut levels = vec![1; self.values.len()];
|
||||
for (i, v) in self.values.iter().enumerate() {
|
||||
if v.is_none() {
|
||||
levels[i] = 0;
|
||||
}
|
||||
}
|
||||
levels
|
||||
self.values
|
||||
.iter()
|
||||
.map(|v| if v.is_some() { 1 } else { 0 })
|
||||
.collect::<Vec<i16>>()
|
||||
}
|
||||
|
||||
/// returns all of the non-null values in the Packer
|
||||
|
|
Loading…
Reference in New Issue