Skip to content
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
10 changes: 8 additions & 2 deletions encodings/fastlanes/src/rle/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ mod tests {
use vortex_array::validity::Validity;
use vortex_buffer::Buffer;
use vortex_buffer::ByteBufferMut;
use vortex_session::registry::ReadContext;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to a better name


use crate::RLEArray;
use crate::test::SESSION;
Expand Down Expand Up @@ -458,7 +459,7 @@ mod tests {
.decode(
&DType::Primitive(PType::U32, Nullability::NonNullable),
2048,
&ctx,
&ReadContext::new(ctx.to_ids()),
&SESSION,
)
.unwrap();
Expand Down Expand Up @@ -498,7 +499,12 @@ mod tests {

let parts = ArrayParts::try_from(concat).unwrap();
let decoded = parts
.decode(sliced.dtype(), sliced.len(), &ctx, &SESSION)
.decode(
sliced.dtype(),
sliced.len(),
&ReadContext::new(ctx.to_ids()),
&SESSION,
)
.unwrap();

let original_data = sliced.to_primitive();
Expand Down
3 changes: 2 additions & 1 deletion encodings/pco/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use vortex_buffer::BufferMut;
use vortex_error::VortexResult;
use vortex_mask::Mask;
use vortex_session::VortexSession;
use vortex_session::registry::ReadContext;

static SESSION: LazyLock<VortexSession> = LazyLock::new(|| {
let session = VortexSession::empty().with::<ArraySession>();
Expand Down Expand Up @@ -166,7 +167,7 @@ fn test_serde() -> VortexResult<()> {
let decoded = parts.decode(
&DType::Primitive(PType::I32, Nullability::NonNullable),
1_000_000,
&context,
&ReadContext::new(context.to_ids()),
&SESSION,
)?;
let mut ctx = SESSION.create_execution_ctx();
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15982,7 +15982,7 @@ pub fn vortex_array::serde::ArrayParts::buffer_lengths(&self) -> alloc::vec::Vec

pub fn vortex_array::serde::ArrayParts::child(&self, idx: usize) -> vortex_array::serde::ArrayParts

pub fn vortex_array::serde::ArrayParts::decode(&self, dtype: &vortex_array::dtype::DType, len: usize, ctx: &vortex_array::ArrayContext, session: &vortex_session::VortexSession) -> vortex_error::VortexResult<vortex_array::ArrayRef>
pub fn vortex_array::serde::ArrayParts::decode(&self, dtype: &vortex_array::dtype::DType, len: usize, ctx: &vortex_session::registry::ReadContext, session: &vortex_session::VortexSession) -> vortex_error::VortexResult<vortex_array::ArrayRef>

pub fn vortex_array::serde::ArrayParts::encoding_id(&self) -> u16

Expand Down
5 changes: 4 additions & 1 deletion vortex-array/src/arrays/decimal/vtable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl DecimalVTable {
mod tests {
use vortex_buffer::ByteBufferMut;
use vortex_buffer::buffer;
use vortex_session::registry::ReadContext;

use crate::ArrayContext;
use crate::IntoArray;
Expand Down Expand Up @@ -273,7 +274,9 @@ mod tests {
let concat = concat.freeze();

let parts = ArrayParts::try_from(concat).unwrap();
let decoded = parts.decode(&dtype, 5, &ctx, &LEGACY_SESSION).unwrap();
let decoded = parts
.decode(&dtype, 5, &ReadContext::new(ctx.to_ids()), &LEGACY_SESSION)
.unwrap();
assert!(decoded.is::<DecimalVTable>());
}
}
10 changes: 9 additions & 1 deletion vortex-array/src/arrays/masked/vtable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ mod tests {
use rstest::rstest;
use vortex_buffer::ByteBufferMut;
use vortex_error::VortexError;
use vortex_session::registry::ReadContext;

use crate::ArrayContext;
use crate::Canonical;
Expand Down Expand Up @@ -269,7 +270,14 @@ mod tests {
let concat = concat.freeze();

let parts = ArrayParts::try_from(concat).unwrap();
let decoded = parts.decode(&dtype, len, &ctx, &LEGACY_SESSION).unwrap();
let decoded = parts
.decode(
&dtype,
len,
&ReadContext::new(ctx.to_ids()),
&LEGACY_SESSION,
)
.unwrap();

assert!(decoded.is::<MaskedVTable>());
assert_eq!(
Expand Down
8 changes: 0 additions & 8 deletions vortex-array/src/context.rs

This file was deleted.

6 changes: 4 additions & 2 deletions vortex-array/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ use std::sync::LazyLock;
pub use array::*;
pub use canonical::*;
pub use columnar::*;
pub use context::*;
pub use executor::*;
pub use hash::*;
pub use mask_future::*;
pub use metadata::*;
use vortex_session::VortexSession;
use vortex_session::registry::Context;

use crate::session::ArraySession;
use crate::vtable::DynVTable;

pub mod accessor;
#[doc(hidden)]
Expand All @@ -39,7 +40,6 @@ pub mod builtins;
mod canonical;
mod columnar;
pub mod compute;
mod context;
pub mod display;
pub mod dtype;
mod executor;
Expand Down Expand Up @@ -80,3 +80,5 @@ pub mod flatbuffers {
// here...
pub static LEGACY_SESSION: LazyLock<VortexSession> =
LazyLock::new(|| VortexSession::empty().with::<ArraySession>());

pub type ArrayContext = Context<&'static dyn DynVTable>;
5 changes: 3 additions & 2 deletions vortex-array/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use vortex_flatbuffers::WriteFlatBuffer;
use vortex_flatbuffers::array as fba;
use vortex_flatbuffers::array::Compression;
use vortex_session::VortexSession;
use vortex_session::registry::ReadContext;
use vortex_utils::aliases::hash_map::HashMap;

use crate::ArrayContext;
Expand Down Expand Up @@ -318,7 +319,7 @@ impl ArrayParts {
&self,
dtype: &DType,
len: usize,
ctx: &ArrayContext,
ctx: &ReadContext,
session: &VortexSession,
) -> VortexResult<ArrayRef> {
let encoding_idx = self.flatbuffer().encoding();
Expand Down Expand Up @@ -623,7 +624,7 @@ impl ArrayParts {

struct ArrayPartsChildren<'a> {
parts: &'a ArrayParts,
ctx: &'a ArrayContext,
ctx: &'a ReadContext,
session: &'a VortexSession,
}

Expand Down
9 changes: 5 additions & 4 deletions vortex-cuda/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ use vortex::scalar::ScalarTruncation;
use vortex::scalar::lower_bound;
use vortex::scalar::upper_bound;
use vortex::session::VortexSession;
use vortex::session::registry::ReadContext;
use vortex::utils::aliases::hash_map::HashMap;

/// A buffer inlined into layout metadata for host-side access.
Expand Down Expand Up @@ -94,7 +95,7 @@ pub struct CudaFlatLayout {
row_count: u64,
dtype: DType,
segment_id: SegmentId,
ctx: ArrayContext,
ctx: ReadContext,
array_tree: ByteBuffer,
/// Small buffers kept on host, keyed by global buffer index.
host_buffers: Arc<HashMap<u32, ByteBuffer>>,
Expand All @@ -107,7 +108,7 @@ impl CudaFlatLayout {
}

#[inline]
pub fn array_ctx(&self) -> &ArrayContext {
pub fn array_ctx(&self) -> &ReadContext {
&self.ctx
}

Expand Down Expand Up @@ -195,7 +196,7 @@ impl VTable for CudaFlatVTable {
metadata: &<Self::Metadata as DeserializeMetadata>::Output,
segment_ids: Vec<SegmentId>,
_children: &dyn LayoutChildren,
ctx: &ArrayContext,
ctx: &ReadContext,
) -> VortexResult<Self::Layout> {
if segment_ids.len() != 1 {
vortex_bail!("CudaFlatLayout must have exactly one segment ID");
Expand Down Expand Up @@ -535,7 +536,7 @@ impl LayoutStrategy for CudaFlatLayoutStrategy {
row_count,
dtype: stream.dtype().clone(),
segment_id,
ctx: ctx.clone(),
ctx: ReadContext::new(ctx.to_ids()),
array_tree,
host_buffers: Arc::new(host_buffer_map),
}
Expand Down
11 changes: 5 additions & 6 deletions vortex-file/src/footer/file_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ use std::sync::Arc;

use flatbuffers::FlatBufferBuilder;
use flatbuffers::WIPOffset;
use vortex_array::ArrayContext;
use vortex_error::VortexResult;
use vortex_flatbuffers::FlatBufferRoot;
use vortex_flatbuffers::WriteFlatBuffer;
use vortex_flatbuffers::footer as fb;
use vortex_layout::LayoutContext;
use vortex_session::registry::ReadContext;

use crate::footer::segment::SegmentSpec;

Expand All @@ -26,9 +25,9 @@ use crate::footer::segment::SegmentSpec;
/// which describes the structure of the data in the file.
pub(crate) struct FooterFlatBufferWriter {
/// The array context containing encodings used in the file.
pub(crate) ctx: ArrayContext,
pub(crate) ctx: ReadContext,
/// The layout context containing the layouts used in the file.
pub(crate) layout_ctx: LayoutContext,
pub(crate) layout_ctx: ReadContext,
/// Specifications for all segments in the file.
pub(crate) segment_specs: Arc<[SegmentSpec]>,
}
Expand All @@ -47,7 +46,7 @@ impl WriteFlatBuffer for FooterFlatBufferWriter {

let array_specs = self
.ctx
.to_ids()
.ids()
.iter()
.map(|e| {
let id = fbb.create_string(e.as_ref());
Expand All @@ -58,7 +57,7 @@ impl WriteFlatBuffer for FooterFlatBufferWriter {

let layout_specs = self
.layout_ctx
.to_ids()
.ids()
.iter()
.map(|e| {
let id = fbb.create_string(e.as_ref());
Expand Down
23 changes: 11 additions & 12 deletions vortex-file/src/footer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub use file_statistics::FileStatistics;
use flatbuffers::root;
use itertools::Itertools;
pub use segment::*;
use vortex_array::ArrayContext;
use vortex_array::dtype::DType;
use vortex_array::vtable::ArrayId;
use vortex_buffer::ByteBuffer;
Expand All @@ -33,12 +32,12 @@ use vortex_error::vortex_bail;
use vortex_error::vortex_err;
use vortex_flatbuffers::FlatBuffer;
use vortex_flatbuffers::footer as fb;
use vortex_layout::LayoutContext;
use vortex_layout::LayoutEncodingId;
use vortex_layout::LayoutRef;
use vortex_layout::layout_from_flatbuffer;
use vortex_layout::session::LayoutSessionExt;
use vortex_session::VortexSession;
use vortex_session::registry::ReadContext;

/// Captures the layout information of a Vortex file.
#[derive(Debug, Clone)]
Expand All @@ -47,7 +46,7 @@ pub struct Footer {
segments: Arc<[SegmentSpec]>,
statistics: Option<FileStatistics>,
// The specific arrays used within the file, in the order they were registered.
array_ctx: ArrayContext,
array_read_ctx: ReadContext,
// The approximate size of the footer in bytes, used for caching and memory management.
approx_byte_size: Option<usize>,
}
Expand All @@ -57,13 +56,13 @@ impl Footer {
root_layout: LayoutRef,
segments: Arc<[SegmentSpec]>,
statistics: Option<FileStatistics>,
array_ctx: ArrayContext,
array_read_ctx: ReadContext,
) -> Self {
Self {
root_layout,
segments,
statistics,
array_ctx,
array_read_ctx,
approx_byte_size: None,
}
}
Expand All @@ -86,27 +85,27 @@ impl Footer {

// Create a LayoutContext from the registry.
let layout_specs = fb_footer.layout_specs();
let layout_ids = layout_specs
let layout_ids: Arc<[_]> = layout_specs
.iter()
.flat_map(|e| e.iter())
.map(|encoding| LayoutEncodingId::new_arc(Arc::from(encoding.id())))
.collect();
let layout_ctx = LayoutContext::new(layout_ids);
let layout_read_ctx = ReadContext::new(layout_ids);

// Create an ArrayContext from the registry.
let array_specs = fb_footer.array_specs();
let array_ids = array_specs
let array_ids: Arc<[_]> = array_specs
.iter()
.flat_map(|e| e.iter())
.map(|encoding| ArrayId::new_arc(Arc::from(encoding.id())))
.collect();
let array_ctx = ArrayContext::new(array_ids);
let array_read_ctx = ReadContext::new(array_ids);

let root_layout = layout_from_flatbuffer(
layout_bytes,
&dtype,
&layout_ctx,
&array_ctx,
&layout_read_ctx,
&array_read_ctx,
session.layouts().registry(),
)?;

Expand All @@ -126,7 +125,7 @@ impl Footer {
root_layout,
segments,
statistics,
array_ctx,
array_read_ctx,
approx_byte_size: Some(approx_byte_size),
})
}
Expand Down
5 changes: 3 additions & 2 deletions vortex-file/src/footer/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use vortex_flatbuffers::FlatBufferRoot;
use vortex_flatbuffers::WriteFlatBuffer;
use vortex_flatbuffers::WriteFlatBufferExt;
use vortex_layout::LayoutContext;
use vortex_session::registry::ReadContext;

use crate::EOF_SIZE;
use crate::Footer;
Expand Down Expand Up @@ -94,8 +95,8 @@ impl FooterSerializer {
let (buffer, footer_segment) = write_flatbuffer(
&mut self.offset,
&FooterFlatBufferWriter {
ctx: self.footer.array_ctx.clone(),
layout_ctx,
ctx: self.footer.array_read_ctx.clone(),
layout_ctx: ReadContext::new(layout_ctx.to_ids()),
segment_specs: self.footer.segments.clone(),
},
)?;
Expand Down
3 changes: 2 additions & 1 deletion vortex-file/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use vortex_layout::sequence::SequentialStreamAdapter;
use vortex_layout::sequence::SequentialStreamExt;
use vortex_session::SessionExt;
use vortex_session::VortexSession;
use vortex_session::registry::ReadContext;

use crate::Footer;
use crate::MAGIC_BYTES;
Expand Down Expand Up @@ -211,7 +212,7 @@ impl VortexWriteOptions {
&dtype,
))
},
ctx,
ReadContext::new(ctx.to_ids()),
);

// Emit the footer buffers and EOF.
Expand Down
2 changes: 1 addition & 1 deletion vortex-ipc/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub mod vortex_ipc::messages

pub enum vortex_ipc::messages::DecoderMessage

pub vortex_ipc::messages::DecoderMessage::Array((vortex_array::serde::ArrayParts, vortex_array::context::ArrayContext, usize))
pub vortex_ipc::messages::DecoderMessage::Array((vortex_array::serde::ArrayParts, vortex_session::registry::ReadContext, usize))

pub vortex_ipc::messages::DecoderMessage::Buffer(vortex_buffer::ByteBuffer)

Expand Down
Loading
Loading