Skip to content

Commit 9397843

Browse files
committed
Improve RowFn batch documentation
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent 3ad7710 commit 9397843

5 files changed

Lines changed: 21 additions & 16 deletions

File tree

‎vortex-array/src/scalar_fn/unstable/row/batch/args.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
//! Execution arguments paired with the metadata selected during planning.
55
//!
66
//! [`BorrowedExecutionArgs`] can point at original or sliced arrays while retaining the dtypes,
7-
//! output dtype, and null policy of the original batch plan.
7+
//! output dtype, and execution policy of the original batch plan.
88
99
use vortex_error::VortexResult;
1010
use vortex_error::vortex_err;
1111

12+
use super::RowPolicy;
1213
use crate::ArrayRef;
1314
use crate::dtype::DType;
1415
use crate::scalar_fn::ExecutionArgs;
15-
use crate::scalar_fn::unstable::row::visitor::RowPolicy;
1616

1717
/// A borrowed [`ExecutionArgs`] view with the metadata selected for its row function.
1818
///

‎vortex-array/src/scalar_fn/unstable/row/batch/execute/mod.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pub(crate) use output::finalize_kernel_output;
2929
impl Batch {
3030
/// Apply constant folding and null handling around `kernel`.
3131
///
32-
/// When the mask contains valid and invalid rows, `try_valid_rows` executes only valid rows
33-
/// over the original inputs. Every result is checked against the planned shape and dtype.
32+
/// For a partially valid batch, `try_valid_rows` executes only valid rows over the original
33+
/// inputs. Every result is checked against the planned shape and dtype.
3434
pub(crate) fn execute(
3535
&self,
3636
kernel: impl Fn(BorrowedExecutionArgs<'_>, &mut ExecutionCtx) -> VortexResult<ArrayRef>,
@@ -53,8 +53,9 @@ impl Batch {
5353
return Ok(self.all_null());
5454
}
5555

56-
// All inputs constant, and their conjoined validity proves every row non-null. This sees
57-
// through extension and masked wrappers just like argument decoding does.
56+
// All inputs are constant, and their conjoined validity proves that every row is non-null.
57+
// The constant check sees through extension and masked wrappers, just like argument
58+
// decoding.
5859
if self.row_count > 0
5960
&& self.validity.definitely_no_nulls()
6061
&& self.inputs.iter().all(|input| batch_const(input).is_some())

‎vortex-array/src/scalar_fn/unstable/row/batch/mod.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! A batch is the set of same-length input columns supplied in one scalar-function call. A row
77
//! function handles typed values for one logical row. This module adds the columnar concerns around
8-
//! that row function: planning the output and null strategy, preserving batch constants,
8+
//! that row function: planning the output and null handling, preserving batch constants,
99
//! propagating strict validity, selecting an execution strategy, and validating the finished
1010
//! output.
1111
//!
@@ -46,12 +46,12 @@ pub(crate) struct Batch {
4646
/// The input dtypes, collected with the columns and reused by both planning and execution.
4747
arg_dtypes: SmallVec<[DType; 4]>,
4848

49-
/// The conjoined input validity, so a row of the output is valid iff it is valid in every
50-
/// input. Conjoining is lazy, and nothing materializes it unless the null handling asks.
49+
/// The conjoined input validity. An output row is valid exactly when it is valid in every
50+
/// input. Conjoining is lazy, and null handling materializes the mask only when required.
5151
validity: Validity,
5252

53-
/// The dtype the function declares for these inputs, which the kernel's output is reconciled
54-
/// against. Already widened to nullable if any input is nullable.
53+
/// The declared output dtype, widened to nullable when any input is nullable. Kernel output is
54+
/// reconciled against this dtype.
5555
result_dtype: DType,
5656

5757
/// The non-nullable dtype the dispatched output capability builds, computed while planning.

‎vortex-array/src/scalar_fn/unstable/row/types/element/output.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ pub trait OutputElement: 'static + Sized {
1919
/// [`OutputSink`]: crate::scalar_fn::unstable::row::OutputSink
2020
fn element_dtype() -> DType;
2121

22-
/// Build a column from one value per row. Called once per batch.
22+
/// Build an all-valid column from one value per row.
23+
///
24+
/// The returned column must contain `values.len()` rows and match
25+
/// [`element_dtype`](Self::element_dtype) except for outer nullability. The framework calls
26+
/// this method once per batch.
2327
fn build(values: Vec<Self>) -> ArrayRef;
2428
}

‎vortex-array/src/scalar_fn/unstable/row/vtable.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ use vortex_error::vortex_ensure_eq;
1414
use vortex_mask::Mask;
1515
use vortex_session::VortexSession;
1616

17+
use super::batch::Batch;
18+
use super::batch::BorrowedExecutionArgs;
1719
use super::row_fn::RowFn;
1820
use super::visitor::BatchPlanner;
21+
use super::visitor::ExecuteRows;
22+
use super::visitor::ExecuteValidRows;
1923
use crate::ArrayRef;
2024
use crate::ExecutionCtx;
2125
use crate::dtype::DType;
@@ -26,10 +30,6 @@ use crate::scalar_fn::ChildName;
2630
use crate::scalar_fn::ExecutionArgs;
2731
use crate::scalar_fn::ScalarFnId;
2832
use crate::scalar_fn::ScalarFnVTable;
29-
use crate::scalar_fn::unstable::row::batch::Batch;
30-
use crate::scalar_fn::unstable::row::batch::BorrowedExecutionArgs;
31-
use crate::scalar_fn::unstable::row::visitor::ExecuteRows;
32-
use crate::scalar_fn::unstable::row::visitor::ExecuteValidRows;
3333

3434
impl<F: RowFn> ScalarFnVTable for F {
3535
type Options = F::Options;

0 commit comments

Comments
 (0)