@@ -7,7 +7,6 @@ use geo::Distance;
77use geo:: Euclidean ;
88use vortex_array:: ArrayRef ;
99use vortex_array:: ExecutionCtx ;
10- use vortex_array:: arrays:: ScalarFnArray ;
1110use vortex_array:: dtype:: DType ;
1211use vortex_array:: dtype:: Nullability ;
1312use vortex_array:: dtype:: PType ;
@@ -19,7 +18,6 @@ use vortex_array::scalar_fn::EmptyOptions;
1918use vortex_array:: scalar_fn:: ExecutionArgs ;
2019use vortex_array:: scalar_fn:: ScalarFnId ;
2120use vortex_array:: scalar_fn:: ScalarFnVTable ;
22- use vortex_array:: scalar_fn:: TypedScalarFnInstance ;
2321use vortex_error:: VortexResult ;
2422use vortex_session:: VortexSession ;
2523use vortex_session:: registry:: CachedId ;
@@ -32,17 +30,6 @@ use crate::scalar_fn::execute::execute_null_propagating;
3230#[ derive( Debug , Clone , Default , PartialEq , Eq , Hash ) ]
3331pub struct GeoDistance ;
3432
35- impl GeoDistance {
36- /// A lazy `ScalarFnArray` computing the per-row distance between operands `a` and `b`; either may
37- /// be constant. The output length is taken from `a`.
38- pub fn try_new_array ( a : ArrayRef , b : ArrayRef ) -> VortexResult < ScalarFnArray > {
39- ScalarFnArray :: try_new (
40- TypedScalarFnInstance :: new ( GeoDistance , EmptyOptions ) . erased ( ) ,
41- vec ! [ a, b] ,
42- )
43- }
44- }
45-
4633impl ScalarFnVTable for GeoDistance {
4734 type Options = EmptyOptions ;
4835
@@ -110,6 +97,7 @@ mod tests {
11097 use vortex_array:: VortexSessionExecute ;
11198 use vortex_array:: arrays:: ConstantArray ;
11299 use vortex_array:: arrays:: PrimitiveArray ;
100+ use vortex_array:: arrays:: scalar_fn:: ScalarFnFactoryExt ;
113101 use vortex_array:: assert_arrays_eq;
114102 use vortex_array:: dtype:: DType ;
115103 use vortex_array:: dtype:: Nullability ;
@@ -153,7 +141,7 @@ mod tests {
153141
154142 let a = point_column ( vec ! [ 0.0 , 3.0 , 0.0 , 3.0 ] , vec ! [ 0.0 , 0.0 , 4.0 , 4.0 ] ) ?;
155143 let b = point_constant ( 0.0 , 0.0 , 4 , & mut ctx) ?;
156- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
144+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
157145
158146 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 0.0 , 3.0 , 4.0 , 5.0 ] ) ;
159147 Ok ( ( ) )
@@ -167,7 +155,7 @@ mod tests {
167155
168156 let a = point_column ( vec ! [ 0.0 , 1.0 ] , vec ! [ 0.0 , 1.0 ] ) ?;
169157 let b = point_column ( vec ! [ 3.0 , 1.0 ] , vec ! [ 4.0 , 1.0 ] ) ?;
170- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
158+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
171159
172160 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 5.0 , 0.0 ] ) ;
173161 Ok ( ( ) )
@@ -181,7 +169,7 @@ mod tests {
181169
182170 let a = point_constant ( 0.0 , 0.0 , 4 , & mut ctx) ?;
183171 let b = point_column ( vec ! [ 0.0 , 3.0 , 0.0 , 3.0 ] , vec ! [ 0.0 , 0.0 , 4.0 , 4.0 ] ) ?;
184- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
172+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
185173
186174 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 0.0 , 3.0 , 4.0 , 5.0 ] ) ;
187175 Ok ( ( ) )
@@ -195,7 +183,7 @@ mod tests {
195183
196184 let a = point_constant ( 0.0 , 0.0 , 3 , & mut ctx) ?;
197185 let b = point_constant ( 3.0 , 4.0 , 3 , & mut ctx) ?;
198- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
186+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
199187
200188 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 5.0 , 5.0 , 5.0 ] ) ;
201189 Ok ( ( ) )
@@ -222,7 +210,7 @@ mod tests {
222210
223211 let a = nullable_point_column ( vec ! [ Some ( ( 0.0 , 0.0 ) ) , None , Some ( ( 3.0 , 4.0 ) ) ] ) ?;
224212 let b = point_constant ( 0.0 , 0.0 , 3 , & mut ctx) ?;
225- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
213+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
226214
227215 let expected = PrimitiveArray :: new (
228216 vec ! [ 0.0f64 , 0.0 , 5.0 ] ,
@@ -241,7 +229,7 @@ mod tests {
241229
242230 let a = nullable_point_column ( vec ! [ Some ( ( 0.0 , 0.0 ) ) , None , Some ( ( 0.0 , 0.0 ) ) ] ) ?;
243231 let b = nullable_point_column ( vec ! [ Some ( ( 3.0 , 4.0 ) ) , Some ( ( 1.0 , 1.0 ) ) , None ] ) ?;
244- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
232+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
245233
246234 let expected = PrimitiveArray :: new (
247235 vec ! [ 5.0f64 , 0.0 , 0.0 ] ,
@@ -261,7 +249,8 @@ mod tests {
261249 let point_dtype = point_column ( vec ! [ 0.0 ] , vec ! [ 0.0 ] ) ?. dtype ( ) . as_nullable ( ) ;
262250 let null_const = ConstantArray :: new ( Scalar :: null ( point_dtype) , 3 ) . into_array ( ) ;
263251 let b = point_column ( vec ! [ 0.0 , 3.0 , 0.0 ] , vec ! [ 0.0 , 0.0 , 4.0 ] ) ?;
264- let distance = GeoDistance :: try_new_array ( null_const, b) ?. into_array ( ) ;
252+ let distance =
253+ GeoDistance . try_new_array ( null_const. len ( ) , EmptyOptions , [ null_const, b] ) ?;
265254
266255 let expected = PrimitiveArray :: new ( vec ! [ 0.0f64 ; 3 ] , Validity :: AllInvalid ) . into_array ( ) ;
267256 assert_arrays_eq ! ( distance, expected, & mut ctx) ;
@@ -276,7 +265,7 @@ mod tests {
276265
277266 let a = nullable_point_column ( vec ! [ None , None ] ) ?;
278267 let b = point_constant ( 0.0 , 0.0 , 2 , & mut ctx) ?;
279- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
268+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
280269
281270 let expected = PrimitiveArray :: new ( vec ! [ 0.0f64 ; 2 ] , Validity :: AllInvalid ) . into_array ( ) ;
282271 assert_arrays_eq ! ( distance, expected, & mut ctx) ;
@@ -292,7 +281,7 @@ mod tests {
292281
293282 let a = nullable_point_column ( vec ! [ Some ( ( 0.0 , 0.0 ) ) , None ] ) ?;
294283 let b = nullable_point_column ( vec ! [ None , Some ( ( 1.0 , 1.0 ) ) ] ) ?;
295- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
284+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
296285
297286 let expected = PrimitiveArray :: new ( vec ! [ 0.0f64 ; 2 ] , Validity :: AllInvalid ) . into_array ( ) ;
298287 assert_arrays_eq ! ( distance, expected, & mut ctx) ;
@@ -309,8 +298,8 @@ mod tests {
309298
310299 let a = point_column ( vec ! [ ] , vec ! [ ] ) ?;
311300 let b = point_column ( vec ! [ ] , vec ! [ ] ) ?;
312- let result = GeoDistance :: try_new_array ( a , b ) ?
313- . into_array ( )
301+ let result = GeoDistance
302+ . try_new_array ( a . len ( ) , EmptyOptions , [ a , b ] ) ?
314303 . execute :: < Canonical > ( & mut ctx) ?
315304 . into_array ( ) ;
316305
0 commit comments