Skip to content
Closed
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
48 changes: 48 additions & 0 deletions vortex-row/public-api.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ pub trait vortex_row::encode::RowEncodeKernel: vortex_array::array::vtable::VTab

pub fn vortex_row::encode::RowEncodeKernel::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::encode::RowEncodeKernel for vortex_array::arrays::constant::vtable::Constant

pub fn vortex_array::arrays::constant::vtable::Constant::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::encode::RowEncodeKernel for vortex_array::arrays::dict::vtable::Dict

pub fn vortex_array::arrays::dict::vtable::Dict::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::encode::RowEncodeKernel for vortex_array::arrays::patched::vtable::Patched

pub fn vortex_array::arrays::patched::vtable::Patched::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

pub fn vortex_row::encode::dispatch_encode(&vortex_array::array::erased::ArrayRef, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<()>

pub mod vortex_row::options
Expand Down Expand Up @@ -266,6 +278,18 @@ pub trait vortex_row::size::RowSizeKernel: vortex_array::array::vtable::VTable

pub fn vortex_row::size::RowSizeKernel::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::size::RowSizeKernel for vortex_array::arrays::constant::vtable::Constant

pub fn vortex_array::arrays::constant::vtable::Constant::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::size::RowSizeKernel for vortex_array::arrays::dict::vtable::Dict

pub fn vortex_array::arrays::dict::vtable::Dict::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::size::RowSizeKernel for vortex_array::arrays::patched::vtable::Patched

pub fn vortex_array::arrays::patched::vtable::Patched::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

pub fn vortex_row::size::dispatch_size(&vortex_array::array::erased::ArrayRef, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<()>

pub struct vortex_row::RowEncode
Expand Down Expand Up @@ -412,10 +436,34 @@ pub trait vortex_row::RowEncodeKernel: vortex_array::array::vtable::VTable

pub fn vortex_row::RowEncodeKernel::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::encode::RowEncodeKernel for vortex_array::arrays::constant::vtable::Constant

pub fn vortex_array::arrays::constant::vtable::Constant::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::encode::RowEncodeKernel for vortex_array::arrays::dict::vtable::Dict

pub fn vortex_array::arrays::dict::vtable::Dict::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::encode::RowEncodeKernel for vortex_array::arrays::patched::vtable::Patched

pub fn vortex_array::arrays::patched::vtable::Patched::row_encode_into(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &[u32], &mut [u32], &mut [u8], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

pub trait vortex_row::RowSizeKernel: vortex_array::array::vtable::VTable

pub fn vortex_row::RowSizeKernel::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::size::RowSizeKernel for vortex_array::arrays::constant::vtable::Constant

pub fn vortex_array::arrays::constant::vtable::Constant::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::size::RowSizeKernel for vortex_array::arrays::dict::vtable::Dict

pub fn vortex_array::arrays::dict::vtable::Dict::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

impl vortex_row::size::RowSizeKernel for vortex_array::arrays::patched::vtable::Patched

pub fn vortex_array::arrays::patched::vtable::Patched::row_size_contribution(vortex_array::array::view::ArrayView<'_, Self>, vortex_row::options::SortField, &mut [u32], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<core::option::Option<()>>

pub fn vortex_row::compute_row_sizes(&[vortex_array::array::erased::ArrayRef], &[vortex_row::options::SortField], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::array::erased::ArrayRef>

pub fn vortex_row::convert_columns(&[vortex_array::array::erased::ArrayRef], &[vortex_row::options::SortField], &mut vortex_array::executor::ExecutionCtx) -> vortex_error::VortexResult<vortex_array::arrays::listview::vtable::ListViewArray>
Expand Down
23 changes: 20 additions & 3 deletions vortex-row/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use vortex_array::arrays::Constant;
use vortex_array::arrays::ListViewArray;
use vortex_array::arrays::Primitive;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::dict::Dict;
use vortex_array::arrays::patched::Patched;
use vortex_array::dtype::DType;
use vortex_array::dtype::Nullability;
use vortex_array::dtype::PType;
Expand Down Expand Up @@ -462,9 +464,9 @@ fn encode_constant_arith(

/// Dispatch a single column's encoding into the shared `out` buffer.
///
/// For PR 1 this is just the canonicalize-then-`codec::field_encode` fallback path.
/// In-crate fast paths for `Constant`/`Dict`/`Patched` and the inventory-based registry
/// for downstream encodings are added in PR 3.
/// Tries the in-crate per-encoding fast paths first, then falls back to canonicalization.
/// Per-encoding kernels currently return `Ok(None)` (stubs added alongside the trait); the
/// real impls land in follow-up commits. The downstream-encoding registry is added next.
pub fn dispatch_encode(
col: &ArrayRef,
field: SortField,
Expand All @@ -473,6 +475,21 @@ pub fn dispatch_encode(
out: &mut [u8],
ctx: &mut ExecutionCtx,
) -> VortexResult<()> {
if let Some(view) = col.as_opt::<Constant>()
&& Constant::row_encode_into(view, field, offsets, cursors, out, ctx)?.is_some()
{
return Ok(());
}
if let Some(view) = col.as_opt::<Dict>()
&& Dict::row_encode_into(view, field, offsets, cursors, out, ctx)?.is_some()
{
return Ok(());
}
if let Some(view) = col.as_opt::<Patched>()
&& Patched::row_encode_into(view, field, offsets, cursors, out, ctx)?.is_some()
{
return Ok(());
}
let canonical = col.clone().execute::<Canonical>(ctx)?;
codec::field_encode(&canonical, field, offsets, cursors, out, ctx)
}
Expand Down
40 changes: 40 additions & 0 deletions vortex-row/src/kernels/constant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Row-encode kernels for `ConstantArray`.
//!
//! Stubs in this commit return `Ok(None)` so the dispatch loop falls back to
//! canonicalization. The real impls land in a follow-up commit.

use vortex_array::ArrayView;
use vortex_array::ExecutionCtx;
use vortex_array::arrays::Constant;
use vortex_error::VortexResult;

use crate::encode::RowEncodeKernel;
use crate::options::SortField;
use crate::size::RowSizeKernel;

impl RowSizeKernel for Constant {
fn row_size_contribution(
_column: ArrayView<'_, Self>,
_field: SortField,
_sizes: &mut [u32],
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<()>> {
Ok(None)
}
}

impl RowEncodeKernel for Constant {
fn row_encode_into(
_column: ArrayView<'_, Self>,
_field: SortField,
_offsets: &[u32],
_cursors: &mut [u32],
_out: &mut [u8],
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<()>> {
Ok(None)
}
}
40 changes: 40 additions & 0 deletions vortex-row/src/kernels/dict.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Row-encode kernels for `DictArray`.
//!
//! Stubs in this commit return `Ok(None)` so the dispatch loop falls back to
//! canonicalization. The real impls land in a follow-up commit.

use vortex_array::ArrayView;
use vortex_array::ExecutionCtx;
use vortex_array::arrays::dict::Dict;
use vortex_error::VortexResult;

use crate::encode::RowEncodeKernel;
use crate::options::SortField;
use crate::size::RowSizeKernel;

impl RowSizeKernel for Dict {
fn row_size_contribution(
_column: ArrayView<'_, Self>,
_field: SortField,
_sizes: &mut [u32],
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<()>> {
Ok(None)
}
}

impl RowEncodeKernel for Dict {
fn row_encode_into(
_column: ArrayView<'_, Self>,
_field: SortField,
_offsets: &[u32],
_cursors: &mut [u32],
_out: &mut [u8],
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<()>> {
Ok(None)
}
}
17 changes: 17 additions & 0 deletions vortex-row/src/kernels/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Per-encoding fast-path implementations of [`RowSizeKernel`] and [`RowEncodeKernel`] for
//! encodings defined in `vortex-array`.
//!
//! Each impl in this module lives here (rather than under the corresponding encoding's
//! `compute` module in `vortex-array`) so the orphan rule is satisfied: the trait is
//! defined in `vortex-row` and the impl is also in `vortex-row`, while the array type
//! (`Constant`, `Dict`, `Patched`) remains in `vortex-array`.
//!
//! [`RowSizeKernel`]: crate::size::RowSizeKernel
//! [`RowEncodeKernel`]: crate::encode::RowEncodeKernel

mod constant;
mod dict;
mod patched;
40 changes: 40 additions & 0 deletions vortex-row/src/kernels/patched.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors

//! Row-encode kernels for `Patched`.
//!
//! Stubs in this commit return `Ok(None)` so the dispatch loop falls back to
//! canonicalization. The real impls land in a follow-up commit.

use vortex_array::ArrayView;
use vortex_array::ExecutionCtx;
use vortex_array::arrays::patched::Patched;
use vortex_error::VortexResult;

use crate::encode::RowEncodeKernel;
use crate::options::SortField;
use crate::size::RowSizeKernel;

impl RowSizeKernel for Patched {
fn row_size_contribution(
_column: ArrayView<'_, Self>,
_field: SortField,
_sizes: &mut [u32],
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<()>> {
Ok(None)
}
}

impl RowEncodeKernel for Patched {
fn row_encode_into(
_column: ArrayView<'_, Self>,
_field: SortField,
_offsets: &[u32],
_cursors: &mut [u32],
_out: &mut [u8],
_ctx: &mut ExecutionCtx,
) -> VortexResult<Option<()>> {
Ok(None)
}
}
1 change: 1 addition & 0 deletions vortex-row/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
pub mod codec;
pub mod convert;
pub mod encode;
mod kernels;
pub mod options;
pub mod size;

Expand Down
24 changes: 21 additions & 3 deletions vortex-row/src/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ use vortex_array::Canonical;
use vortex_array::ExecutionCtx;
use vortex_array::IntoArray;
use vortex_array::VTable;
use vortex_array::arrays::Constant;
use vortex_array::arrays::ConstantArray;
use vortex_array::arrays::PrimitiveArray;
use vortex_array::arrays::StructArray;
use vortex_array::arrays::dict::Dict;
use vortex_array::arrays::patched::Patched;
use vortex_array::dtype::DType;
use vortex_array::dtype::FieldName;
use vortex_array::dtype::FieldNames;
Expand Down Expand Up @@ -256,15 +259,30 @@ impl ScalarFnVTable for RowSize {

/// Dispatch a single column's per-row size contribution.
///
/// For PR 1 this is just the canonicalize-then-`codec::field_size` fallback path. In-crate
/// fast paths for `Constant`/`Dict`/`Patched` and the inventory-based registry for
/// downstream encodings are added in PR 3.
/// Tries the in-crate per-encoding fast paths first, then falls back to canonicalization.
/// Per-encoding kernels currently return `Ok(None)` (stubs added alongside the trait); the
/// real impls land in follow-up commits. The downstream-encoding registry is added next.
pub fn dispatch_size(
col: &ArrayRef,
field: SortField,
sizes: &mut [u32],
ctx: &mut ExecutionCtx,
) -> VortexResult<()> {
if let Some(view) = col.as_opt::<Constant>()
&& Constant::row_size_contribution(view, field, sizes, ctx)?.is_some()
{
return Ok(());
}
if let Some(view) = col.as_opt::<Dict>()
&& Dict::row_size_contribution(view, field, sizes, ctx)?.is_some()
{
return Ok(());
}
if let Some(view) = col.as_opt::<Patched>()
&& Patched::row_size_contribution(view, field, sizes, ctx)?.is_some()
{
return Ok(());
}
let canonical = col.clone().execute::<Canonical>(ctx)?;
codec::field_size(&canonical, field, sizes, ctx)
}
Expand Down
Loading