Conversation
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
|
@claude review this PR |
|
Claude finished @gatesn's task in 9m 6s —— View job PR Review: ScalarFn VTable
OverviewThis PR introduces the 🐛 Bug: Duplicate
|
| Location | Current (stale) | Should be |
|---|---|---|
| Line 32 (table) | ExprSession |
ScalarFnSession |
| Line 54 (code example) | session.expressions().register(...) |
session.scalar_fns().register(...) |
| Line 105 (code example) | .with::<ExprSession>() |
.with::<ScalarFnSession>() |
📄 Documentation: vtables.md migration status is imprecise
File: docs/developer-guide/internals/vtables.md, lines 141–145
Two issues in the ScalarFn -- Done section:
-
Missing
ScalarFnRef: Line 144 lists the components asScalarFnVTable,ScalarFnPlugin,ScalarFnInner,DynScalarFn,ScalarFn— but the erased formScalarFnRefis missing. Per the pattern table at line 18, the erased form should beFooRef. The list should be..., ScalarFn<V>, ScalarFnRef. -
Outdated factory function location: Line 145 says "Factory functions (e.g.
root(),lit(),eq()) live inexpr/exprs.rs". This remains true, but the new sub-functions inscalar_fn::fns(e.g. vtable types, reduce adaptors) are now accessed from there — worth clarifying.
⚠️ Dead code: NotSupported in scalar_fn/vtable.rs
File: vortex-array/src/scalar_fn/vtable.rs, line 342
/// A placeholder vtable implementation for unsupported optional functionality of an expression.
pub struct NotSupported;This struct is declared but has no impl for any trait, and is not used anywhere in the codebase (confirmed by search). The counterpart in vtable/mod.rs has an OperationsVTable implementation. If this is intended to be a future helper (e.g., to implement ScalarFnVTable as a no-op sentinel), it needs at minimum a note and ideally a blanket impl. Otherwise it can be removed to avoid confusion.
ℹ️ Minor: unsafe cast in ScalarFnPlugin::new_static
File: vortex-array/src/scalar_fn/plugin.rs, lines 43–48
pub const fn new_static<V: ScalarFnVTable>(vtable: &'static V) -> Self {
// SAFETY: We can safely cast the vtable to a ScalarFnInner since it has the same layout.
let adapted: &'static ScalarFnInner<V> =
unsafe { &*(vtable as *const V as *const ScalarFnInner<V>) };
...
}This is sound given the #[repr(transparent)] on ScalarFnInner<V>, but the safety comment could be more explicit: "SAFETY: ScalarFnInner<V> is #[repr(transparent)] over V, so *const V and *const ScalarFnInner<V> have identical layout and alignment." Minor suggestion.
✅ Architecture looks good
- The vtable pattern is consistent with
ExtDTypeand the design doc. - The separation of
ScalarFnVTable(non-object-safe, typed),DynScalarFn(object-safe, sealed),ScalarFnInner<V>(bridge),ScalarFnRef(erased) andScalarFnPlugin(registry) is clean and well-structured. - The debug-mode execution validation in
typed.rs(row count and dtype checks) is a nice correctness guard. - Making
fnsa public module (pub mod fns) while removing the blanket re-export (pub use fns::*) is a reasonable API boundary decision. - The
SimplifyCtx,ReduceNode,ReduceCtxtraits are well-designed for extensibility.
Summary: 2 small bugs (duplicate _ = expr;, stale "BoundExpression"), 3 stale doc locations in session.md, 1 imprecise doc in vtables.md, and 1 dead-code struct. All minor — the core architecture is solid.
Merging this PR will degrade performance by 12%
Performance Changes
Comparing Footnotes
|
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
The vtable itself describes the behavior of a scalar function. I envisage us turning Expression into an enum in the future where ScalarFn is but one variant.
This PR addresses the naming confusion (and prepares us to add AggregateFn VTable in the near future), as well as unifies the vtable names as per #6093