Repository navigation
Conversation
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Merging this PR will degrade performance by 13.29%3 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Summary
An alternative to #10702, to compare against it. A lambda passed to
list_transformcan read values from outside it: a column, another lambda's parameter, orrow_idx(). Unlike #10702, the lambda is never rewritten. The call takes what the body reads as one more child, the lambda's environment, and binding resolves$and outer parameters against it.Changes
Lambda::environment()packs what the body reads from outside into one struct, cut down to the fields it reads:$for the row, an outer parameter under its own name, androw_idx()orrow_count()under its id.list_transform(list, lambda)passes the environment as a second child, soreplace, field pruning and the scan'srow_idx()see it.Lambda::bindandreturn_dtypetake the environment's fields. The lambda's inputs are its parameters followed by those fields, so@pstill binds as$.p, and$binds as$.$.Lambda::newaccepts outside reads; binding without the environment is the error. A parameter can't be named$.take. A list view with an environment is copied apart into a list first, since overlapping views share elements between rows.list_transformstays strict: the environment is a non-nullable struct, so it is never null.Compared with #10702
(x, a) -> (@x + @a)(x) -> (@x + $.a)a,x_2, …BoundLambda::rebind)list_transformdoes todayrebindTesting
$, an outer parameter androw_count(). Binding without the environment is an error.list_transform: Capture values read from outsidelist_transformlambdas #10702's cases (a column, null and constant values, overlapping list views, nested lambdas reading a column or the outer parameter), plus a field of a nullable struct.replace($, $.s)rewrites the environment and leaves the body alone (vortex-expr). A scan readsrow_idx()inside a lambda (vortex-layout).cargo nextest run -p vortex-array -p vortex-layout -p vortex-expr(5,459 passed), clippy, fmt, and the new doc examples.Follow-up
take, now that RunEnd is in vortex-array (Move RunEnd into vortex-array #10703).list_transformlambdas #10702 does, if we want it.