Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
danking committed Oct 29, 2024
1 parent 6dd5985 commit 9f8df14
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
3 changes: 2 additions & 1 deletion vortex-serde/src/layouts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ pub const COLUMN_LAYOUT_ID: LayoutId = LayoutId(3);
pub const INLINE_SCHEMA_LAYOUT_ID: LayoutId = LayoutId(4);

pub const PRUNING_STATS: [Stat; 4] = [Stat::Min, Stat::Max, Stat::NullCount, Stat::TrueCount];
pub const METADATA_FIELD_NAMES: [&str; 5] = ["row_offset", "min", "max", "null_count", "true_count"];
pub const METADATA_FIELD_NAMES: [&str; 5] =
["row_offset", "min", "max", "null_count", "true_count"];

pub use read::*;
pub use write::*;
3 changes: 2 additions & 1 deletion vortex-serde/src/layouts/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use vortex_expr::{BinaryExpr, Column, Literal, Operator};

use crate::layouts::write::LayoutWriter;
use crate::layouts::{
LayoutDeserializer, LayoutReaderBuilder, Projection, RowFilter, EOF_SIZE, FOOTER_POSTSCRIPT_SIZE, MAGIC_BYTES, METADATA_FIELD_NAMES, PRUNING_STATS, VERSION
LayoutDeserializer, LayoutReaderBuilder, Projection, RowFilter, EOF_SIZE,
FOOTER_POSTSCRIPT_SIZE, MAGIC_BYTES, METADATA_FIELD_NAMES, PRUNING_STATS, VERSION,
};

#[test]
Expand Down
42 changes: 34 additions & 8 deletions vortex-serde/src/layouts/write/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<W: VortexWrite> LayoutWriter<W> {
Ok(())
}

async fn write_metadata_arrays(&mut self) -> VortexResult<Layout> {
async fn write_metadata_arrays(&mut self) -> VortexResult<Layout> {
let mut column_layouts = Vec::with_capacity(self.column_chunks.len());
for column_accumulator in mem::take(&mut self.column_chunks) {
let (mut chunks, metadata_array) = column_accumulator.into_chunks_and_metadata()?;
Expand Down Expand Up @@ -195,7 +195,7 @@ async fn write_fb_raw<W: VortexWrite, F: WriteFlatBuffer>(mut writer: W, fb: F)
Ok(writer)
}

struct ColumnChunkAccumulator<> {
struct ColumnChunkAccumulator {
pub dtype: DType,
pub row_offsets: Vec<u64>,
pub batch_byte_offsets: Vec<Vec<u64>>,
Expand Down Expand Up @@ -232,14 +232,26 @@ impl ColumnChunkAccumulator {
if matches!(stat, Stat::Min | Stat::Max) {
if let Some(ref value) = value {
if !value.value().is_instance_of(&self.dtype) {
vortex_bail!("Expected all min/max values to have dtype {}, got {}", self.dtype, value.dtype());
vortex_bail!(
"Expected all min/max values to have dtype {}, got {}",
self.dtype,
value.dtype()
);
}
}
}

match stat {
Stat::Min => self.minima.push(value.map(|v| v.into_value()).unwrap_or_else(|| ScalarValue::Null)),
Stat::Max => self.maxima.push(value.map(|v| v.into_value()).unwrap_or_else(|| ScalarValue::Null)),
Stat::Min => self.minima.push(
value
.map(|v| v.into_value())
.unwrap_or_else(|| ScalarValue::Null),
),
Stat::Max => self.maxima.push(
value
.map(|v| v.into_value())
.unwrap_or_else(|| ScalarValue::Null),
),
Stat::NullCount => self.null_counts.push(value.and_then(|v| {
v.into_value()
.as_pvalue()
Expand Down Expand Up @@ -288,8 +300,18 @@ impl ColumnChunkAccumulator {
let values = match stat {
Stat::Min => mem::take(&mut self.minima),
Stat::Max => mem::take(&mut self.maxima),
Stat::NullCount => self.null_counts.iter().cloned().map(ScalarValue::from).collect(),
Stat::TrueCount => self.true_counts.iter().cloned().map(ScalarValue::from).collect(),
Stat::NullCount => self
.null_counts
.iter()
.cloned()
.map(ScalarValue::from)
.collect(),
Stat::TrueCount => self
.true_counts
.iter()
.cloned()
.map(ScalarValue::from)
.collect(),
_ => vortex_bail!("Unsupported pruning stat: {}", stat),
};
if values.len() != length {
Expand All @@ -316,7 +338,11 @@ impl ColumnChunkAccumulator {
}
for name in &names {
if !METADATA_FIELD_NAMES.contains(&name.as_ref()) {
vortex_panic!("Found unexpected metadata field name {}, expected one of {:?}", name, METADATA_FIELD_NAMES);
vortex_panic!(
"Found unexpected metadata field name {}, expected one of {:?}",
name,
METADATA_FIELD_NAMES
);
}
}

Expand Down

0 comments on commit 9f8df14

Please sign in to comment.