Skip to content

Commit

Permalink
chore: random refactoring/renaming (#1669)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamGS authored Dec 12, 2024
1 parent c03faad commit b8d3ff2
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 120 deletions.
10 changes: 5 additions & 5 deletions vortex-file/src/read/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ impl<R: VortexReadAt + Unpin> VortexReadBuilder<R> {
let message_cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let layout_reader = self.layout_serde.read_layout(
initial_read.fb_layout(),
Scan::new(match self.projection {
Projection::All => None,
Projection::Flat(p) => Some(Arc::new(Select::include(p))),
}),
match self.projection {
Projection::All => Scan::empty(),
Projection::Flat(p) => Scan::new(Arc::new(Select::include(p))),
},
RelativeLayoutCache::new(message_cache.clone(), lazy_dtype.clone()),
)?;

Expand All @@ -154,7 +154,7 @@ impl<R: VortexReadAt + Unpin> VortexReadBuilder<R> {
.map(|row_filter| {
self.layout_serde.read_layout(
initial_read.fb_layout(),
Scan::new(Some(Arc::new(row_filter))),
Scan::new(Arc::new(row_filter)),
RelativeLayoutCache::new(message_cache.clone(), lazy_dtype),
)
})
Expand Down
18 changes: 9 additions & 9 deletions vortex-file/src/read/layouts/chunked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ impl ChunkedLayoutBuilder<'_> {
};
Some(self.layout_builder.read_layout(
metadata_fb,
Scan::new(Some(Arc::new(Select::include(
Scan::new(Arc::new(Select::include(
s.names().iter().map(|s| Field::Name(s.clone())).collect(),
)))),
))),
self.message_cache.relative(
METADATA_LAYOUT_PART_ID,
Arc::new(LazyDType::from_dtype(stats_dtype)),
Expand Down Expand Up @@ -289,7 +289,7 @@ impl ChunkedLayoutReader {
impl LayoutReader for ChunkedLayoutReader {
fn add_splits(&self, row_offset: usize, splits: &mut BTreeSet<usize>) -> VortexResult<()> {
for RangedLayoutReader((begin, _), child) in &self.layouts {
child.add_splits(row_offset + begin, splits)?
child.add_splits(row_offset + begin, splits)?;
}
Ok(())
}
Expand Down Expand Up @@ -474,7 +474,7 @@ mod tests {
.unwrap(),
ChunkedLayoutBuilder {
layout,
scan: Scan::new(None),
scan: Scan::empty(),
layout_builder,
message_cache: RelativeLayoutCache::new(cache, dtype),
}
Expand All @@ -491,11 +491,11 @@ mod tests {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (mut filter_layout, mut projection_layout, buf, length) = layout_and_bytes(
cache.clone(),
Scan::new(Some(RowFilter::new_expr(BinaryExpr::new_expr(
Scan::new(RowFilter::new_expr(BinaryExpr::new_expr(
Arc::new(Identity),
Operator::Gt,
Literal::new_expr(10.into()),
)))),
))),
)
.await;

Expand Down Expand Up @@ -527,7 +527,7 @@ mod tests {
async fn read_range_no_filter() {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (_, mut projection_layout, buf, length) =
layout_and_bytes(cache.clone(), Scan::new(None)).await;
layout_and_bytes(cache.clone(), Scan::empty()).await;
let arr = read_layout(&mut projection_layout, cache, &buf, length).pop_front();

assert!(arr.is_some());
Expand All @@ -543,7 +543,7 @@ mod tests {
async fn read_no_range() {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (_, mut projection_layout, buf, _) =
layout_and_bytes(cache.clone(), Scan::new(None)).await;
layout_and_bytes(cache.clone(), Scan::empty()).await;
let arr = read_layout_data(
&mut projection_layout,
cache,
Expand All @@ -564,7 +564,7 @@ mod tests {
async fn read_multiple_selectors() {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (_, mut projection_layout, buf, _) =
layout_and_bytes(cache.clone(), Scan::new(None)).await;
layout_and_bytes(cache.clone(), Scan::empty()).await;

let mut first_range = BooleanBufferBuilder::new(200);
first_range.append_n(150, true);
Expand Down
16 changes: 8 additions & 8 deletions vortex-file/src/read/layouts/columnar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl ColumnarLayoutBuilder<'_> {

let child = self.layout_serde.read_layout(
child_layout,
Scan::new(projected_expr),
Scan::from(projected_expr),
self.message_cache
.relative(resolved_child as u16, child_field),
)?;
Expand Down Expand Up @@ -223,7 +223,7 @@ impl ColumnarLayoutReader {
impl LayoutReader for ColumnarLayoutReader {
fn add_splits(&self, row_offset: usize, splits: &mut BTreeSet<usize>) -> VortexResult<()> {
for child in &self.children {
child.add_splits(row_offset, splits)?
child.add_splits(row_offset, splits)?;
}
Ok(())
}
Expand Down Expand Up @@ -470,7 +470,7 @@ mod tests {
layout_serde
.read_layout(
initial_read.fb_layout(),
Scan::new(None),
Scan::empty(),
RelativeLayoutCache::new(cache.clone(), dtype),
)
.unwrap(),
Expand All @@ -485,11 +485,11 @@ mod tests {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (mut filter_layout, mut project_layout, buf, length) = layout_and_bytes(
cache.clone(),
Scan::new(Some(RowFilter::new_expr(BinaryExpr::new_expr(
Scan::new(RowFilter::new_expr(BinaryExpr::new_expr(
Column::new_expr(Field::from("ints")),
Operator::Gt,
Literal::new_expr(10.into()),
)))),
))),
)
.await;
let arr = filter_read_layout(
Expand Down Expand Up @@ -540,7 +540,7 @@ mod tests {
async fn read_range_no_filter() {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (_, mut project_layout, buf, length) =
layout_and_bytes(cache.clone(), Scan::new(None)).await;
layout_and_bytes(cache.clone(), Scan::empty()).await;
let arr = read_layout(project_layout.as_mut(), cache, &buf, length).pop_front();

assert!(arr.is_some());
Expand Down Expand Up @@ -583,7 +583,7 @@ mod tests {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (mut filter_layout, mut project_layout, buf, length) = layout_and_bytes(
cache.clone(),
Scan::new(Some(RowFilter::new_expr(BinaryExpr::new_expr(
Scan::new(RowFilter::new_expr(BinaryExpr::new_expr(
BinaryExpr::new_expr(
Column::new_expr(Field::from("strs")),
Operator::Eq,
Expand All @@ -595,7 +595,7 @@ mod tests {
Operator::Lt,
Literal::new_expr(150.into()),
),
)))),
))),
)
.await;
let arr = filter_read_layout(
Expand Down
10 changes: 5 additions & 5 deletions vortex-file/src/read/layouts/flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ mod tests {
writer.write_batch(array).await.unwrap();
let written = writer.into_inner();

let projection_scan = Scan::new(None);
let projection_scan = Scan::empty();
let dtype = Arc::new(LazyDType::from_dtype(PType::I32.into()));

(
Expand Down Expand Up @@ -180,11 +180,11 @@ mod tests {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (mut filter_layout, mut projection_layout, buf, length) = layout_and_bytes(
cache.clone(),
Scan::new(Some(RowFilter::new_expr(BinaryExpr::new_expr(
Scan::new(RowFilter::new_expr(BinaryExpr::new_expr(
Arc::new(Identity),
Operator::Gt,
Literal::new_expr(10.into()),
)))),
))),
)
.await;
let arr = filter_read_layout(
Expand Down Expand Up @@ -225,11 +225,11 @@ mod tests {
let cache = Arc::new(RwLock::new(LayoutMessageCache::default()));
let (mut filter_layout, mut projection_layout, buf, length) = layout_and_bytes(
cache.clone(),
Scan::new(Some(RowFilter::new_expr(BinaryExpr::new_expr(
Scan::new(RowFilter::new_expr(BinaryExpr::new_expr(
Arc::new(Identity),
Operator::Gt,
Literal::new_expr(101.into()),
)))),
))),
)
.await;
let arr = filter_read_layout(
Expand Down
8 changes: 4 additions & 4 deletions vortex-file/src/read/layouts/test_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use vortex_array::ArrayData;
use vortex_error::VortexUnwrap;

use crate::read::mask::RowMask;
use crate::read::splits::FixedSplitIterator;
use crate::read::splits::SplitsAccumulator;
use crate::{LayoutMessageCache, LayoutReader, MessageLocator, PollRead};

fn layout_splits(
layouts: &[&mut dyn LayoutReader],
length: usize,
) -> impl Iterator<Item = RowMask> {
let mut iter = FixedSplitIterator::new(length as u64, None);
let mut iter = SplitsAccumulator::new(length as u64, None);
let mut splits = BTreeSet::new();
for layout in layouts {
layout.add_splits(0, &mut splits).vortex_unwrap();
}
iter.additional_splits(&mut splits).vortex_unwrap();
iter.map(|m| m.unwrap())
iter.append_splits(&mut splits);
iter.into_iter().map(|m| m.unwrap())
}

pub fn read_layout_data(
Expand Down
8 changes: 7 additions & 1 deletion vortex-file/src/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ impl Scan {
Self { expr: None }
}

pub fn new(expr: Option<ExprRef>) -> Self {
pub fn new(expr: ExprRef) -> Self {
Self { expr: Some(expr) }
}
}

impl From<Option<ExprRef>> for Scan {
fn from(expr: Option<ExprRef>) -> Self {
Self { expr }
}
}
Expand Down
Loading

0 comments on commit b8d3ff2

Please sign in to comment.