Skip to content

Commit 8979166

Browse files
committed
docs
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 7b48904 commit 8979166

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

vortex-array/src/matcher.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,36 @@ use crate::array::ParentRef;
88
pub trait Matcher {
99
type Match<'a>;
1010

11-
/// Check if the given array matches this matcher type
11+
/// Check if the given array matches this matcher type.
12+
///
13+
/// # Deprecated
14+
///
15+
/// Prefer [`Matcher::matches_parent`]. This method only sees a heap-allocated
16+
/// [`ArrayRef`]; stack-allocated parents constructed by [`ArrayParts::optimize`]
17+
/// flow through `matches_parent` instead.
18+
///
19+
/// Existing implementations can stay; new matchers should override
20+
/// [`Matcher::matches_parent`] (and [`Matcher::try_match_parent`]) directly so they
21+
/// participate in the stack-backed `reduce_parent` dispatch.
22+
///
23+
/// [`ArrayParts::optimize`]: crate::array::ArrayParts::optimize
1224
fn matches(array: &ArrayRef) -> bool {
1325
Self::try_match(array).is_some()
1426
}
1527

1628
/// Try to match the given array, returning the matched view type if successful.
29+
///
30+
/// # Deprecated
31+
///
32+
/// Prefer [`Matcher::try_match_parent`]. This method only sees a heap-allocated
33+
/// [`ArrayRef`]; stack-allocated parents constructed by [`ArrayParts::optimize`]
34+
/// flow through `try_match_parent` instead.
35+
///
36+
/// Existing implementations can stay; new matchers should override
37+
/// [`Matcher::try_match_parent`] directly so they participate in the stack-backed
38+
/// `reduce_parent` dispatch.
39+
///
40+
/// [`ArrayParts::optimize`]: crate::array::ArrayParts::optimize
1741
fn try_match<'a>(array: &'a ArrayRef) -> Option<Self::Match<'a>>;
1842

1943
/// Try to match a [`ParentRef`].

vortex-array/src/optimizer/rules.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ pub trait ArrayReduceRule<V: VTable>: Debug + Send + Sync + 'static {
4949
/// The child sees the parent's type via the associated `Parent` [`Matcher`] and can return
5050
/// a replacement for the parent. This enables optimizations like pushing operations through
5151
/// compression layers (e.g., pushing a scalar function into dictionary values).
52+
///
53+
/// # Migration to `ParentRef`
54+
///
55+
/// New rules should override [`ArrayParentReduceRule::reduce_parent_ref`] directly so
56+
/// they participate in the stack-backed dispatch driven by
57+
/// [`ArrayParts::optimize`](crate::array::ArrayParts::optimize). The default
58+
/// `reduce_parent_ref` falls through to [`reduce_parent`](Self::reduce_parent) via
59+
/// [`Matcher::try_match_parent`], which only matches heap-allocated parents — so
60+
/// rules that only override `reduce_parent` will still fire on heap-backed parents
61+
/// but will miss the stack-backed fast path.
5262
pub trait ArrayParentReduceRule<V: VTable>: Debug + Send + Sync + 'static {
5363
/// The parent array type this rule matches against.
5464
type Parent: Matcher;
@@ -59,6 +69,19 @@ pub trait ArrayParentReduceRule<V: VTable>: Debug + Send + Sync + 'static {
5969
/// - `Ok(Some(new_array))` if the rule applied successfully
6070
/// - `Ok(None)` if the rule doesn't apply
6171
/// - `Err(e)` if an error occurred
72+
///
73+
/// # Deprecated
74+
///
75+
/// Prefer overriding [`ArrayParentReduceRule::reduce_parent_ref`]. This method
76+
/// only sees the parent through [`Matcher::Match`], which for the blanket
77+
/// `impl<V: VTable> Matcher for V` is an [`ArrayView`] holding an `&ArrayRef` —
78+
/// in other words it only fires when the parent is heap-allocated. Rules that
79+
/// override `reduce_parent_ref` instead can rewrite stack-allocated parents
80+
/// constructed by [`ArrayParts::optimize`](crate::array::ArrayParts::optimize)
81+
/// without forcing an `Arc<ArrayInner<V>>` allocation.
82+
///
83+
/// Existing implementations can stay; the default `reduce_parent_ref` continues
84+
/// to delegate here for heap-backed parents.
6285
fn reduce_parent(
6386
&self,
6487
array: ArrayView<'_, V>,

0 commit comments

Comments
 (0)