Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ViewContext and page byte ranges in array reader #339

Merged
merged 6 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ zigzag = "0.1.0"
warnings = "deny"

[workspace.lints.clippy]
all = "deny"
all = { level = "deny", priority = -1 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of us using nightly, seems like they now complain if two rules have same "priority" so you make this priority lower so it can be overriden by individual rules

or_fun_call = "deny"
2 changes: 1 addition & 1 deletion vortex-fastlanes/src/bitpacking/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub fn unpack_single(array: &BitPackedArray, index: usize) -> VortexResult<Scala
/// The caller must ensure the following invariants hold:
/// * `packed.len() == (length + 1023) / 1024 * 128 * bit_width`
/// * `index_to_decode < length`
/// Where `length` is the length of the array/slice backed by `packed` (but is not provided to this function).
/// Where `length` is the length of the array/slice backed by `packed` (but is not provided to this function).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also us using nightly

pub unsafe fn unpack_single_primitive<T: NativePType + TryBitPack>(
packed: &[u8],
bit_width: usize,
Expand Down
5 changes: 5 additions & 0 deletions vortex-ipc/src/stream_reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ impl<R: VortexRead> StreamArrayReader<R> {
Ok(self)
}

/// Retrieve the loaded view_context
pub fn view_context(&self) -> Option<Arc<ViewContext>> {
self.view_context.clone()
}

pub fn with_dtype(self, dtype: DType) -> Self {
assert!(self.dtype.is_none(), "DType already set");
Self {
Expand Down
15 changes: 15 additions & 0 deletions vortex-ipc/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use futures_util::{Stream, TryStreamExt};
use vortex::array::chunked::ChunkedArray;
use vortex::stream::ArrayStream;
use vortex::{Array, IntoArrayData, ViewContext};
use vortex_buffer::Buffer;
use vortex_dtype::DType;
use vortex_error::{vortex_bail, VortexResult};

Expand All @@ -14,6 +15,7 @@ pub struct ArrayWriter<W: VortexWrite> {

view_ctx_range: Option<ByteRange>,
array_layouts: Vec<ArrayLayout>,
page_ranges: Vec<ByteRange>,
}

impl<W: VortexWrite> ArrayWriter<W> {
Expand All @@ -23,6 +25,7 @@ impl<W: VortexWrite> ArrayWriter<W> {
view_ctx,
view_ctx_range: None,
array_layouts: vec![],
page_ranges: vec![],
}
}

Expand All @@ -34,6 +37,10 @@ impl<W: VortexWrite> ArrayWriter<W> {
&self.array_layouts
}

pub fn page_ranges(&self) -> &[ByteRange] {
&self.page_ranges
}

pub fn into_inner(self) -> W {
self.msgs.into_inner()
}
Expand Down Expand Up @@ -102,6 +109,14 @@ impl<W: VortexWrite> ArrayWriter<W> {
self.write_array_stream(array.into_array_stream()).await
}
}

pub async fn write_page(mut self, buffer: Buffer) -> VortexResult<Self> {
let begin = self.msgs.tell();
self.msgs.write_page(buffer).await?;
let end = self.msgs.tell();
self.page_ranges.push(ByteRange { begin, end });
Ok(self)
}
}

#[derive(Copy, Clone, Debug)]
Expand Down