@@ -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.
5262pub 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