Skip to content

Commit

Permalink
asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
robert3005 committed Oct 22, 2024
1 parent 18e07c0 commit 9b06b6f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions vortex-serde/src/layouts/write/layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ pub struct Layout {
}

impl Layout {
pub fn flat(begin: u64, end: u64) -> Self {
pub fn flat(buffer: ByteRange) -> Self {
Self {
id: FLAT_LAYOUT_ID,
buffers: Some(vec![ByteRange::new(begin, end)]),
buffers: Some(vec![buffer]),
children: None,
metadata: None,
}
Expand Down
4 changes: 2 additions & 2 deletions vortex-serde/src/layouts/write/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<W: VortexWrite> LayoutWriter<W> {
byte_offsets
.iter()
.zip(byte_offsets.iter().skip(1))
.map(|(begin, end)| Layout::flat(*begin, *end))
.map(|(begin, end)| Layout::flat(ByteRange::new(*begin, *end)))
})
.collect();
let len = chunk.row_offsets.len() - 1;
Expand All @@ -147,7 +147,7 @@ impl<W: VortexWrite> LayoutWriter<W> {
let dtype_end = self.msgs.tell();
self.msgs.write_batch(metadata_array.into_array()).await?;
chunks.push_front(Layout::inlined_schema(
vec![Layout::flat(dtype_end, self.msgs.tell())],
vec![Layout::flat(ByteRange::new(dtype_end, self.msgs.tell()))],
ByteRange::new(dtype_begin, dtype_end),
));
column_layouts.push(Layout::chunked(chunks.into(), true));
Expand Down
1 change: 1 addition & 0 deletions vortex-serde/src/stream_writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl Display for ByteRange {

impl ByteRange {
pub fn new(begin: u64, end: u64) -> Self {
assert!(end > begin, "Buffer end must be after its beginning");
Self { begin, end }
}

Expand Down

0 comments on commit 9b06b6f

Please sign in to comment.