@@ -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
@@ -115,6 +102,7 @@ mod tests {
115102 use vortex_array:: VortexSessionExecute ;
116103 use vortex_array:: arrays:: ConstantArray ;
117104 use vortex_array:: arrays:: PrimitiveArray ;
105+ use vortex_array:: arrays:: scalar_fn:: ScalarFnFactoryExt ;
118106 use vortex_array:: assert_arrays_eq;
119107 use vortex_array:: dtype:: DType ;
120108 use vortex_array:: dtype:: Nullability ;
@@ -159,7 +147,7 @@ mod tests {
159147
160148 let a = point_column ( vec ! [ 0.0 , 3.0 , 0.0 , 3.0 ] , vec ! [ 0.0 , 0.0 , 4.0 , 4.0 ] ) ?;
161149 let b = point_constant ( 0.0 , 0.0 , 4 , & mut ctx) ?;
162- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
150+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
163151
164152 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 0.0 , 3.0 , 4.0 , 5.0 ] ) ;
165153 Ok ( ( ) )
@@ -173,7 +161,7 @@ mod tests {
173161
174162 let a = point_column ( vec ! [ 0.0 , 1.0 ] , vec ! [ 0.0 , 1.0 ] ) ?;
175163 let b = point_column ( vec ! [ 3.0 , 1.0 ] , vec ! [ 4.0 , 1.0 ] ) ?;
176- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
164+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
177165
178166 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 5.0 , 0.0 ] ) ;
179167 Ok ( ( ) )
@@ -190,7 +178,7 @@ mod tests {
190178 let single = polygon_column ( vec ! [ vec![ ring] ] ) ?. execute_scalar ( 0 , & mut ctx) ?;
191179 let square = ConstantArray :: new ( single, 2 ) . into_array ( ) ;
192180 let points = point_column ( vec ! [ 7.0 , 2.0 ] , vec ! [ 2.0 , 2.0 ] ) ?;
193- let distance = GeoDistance :: try_new_array ( points, square) ? . into_array ( ) ;
181+ let distance = GeoDistance . try_new_array ( points. len ( ) , EmptyOptions , [ points , square] ) ? ;
194182
195183 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 3.0 , 0.0 ] ) ;
196184 Ok ( ( ) )
@@ -204,7 +192,7 @@ mod tests {
204192
205193 let a = point_constant ( 0.0 , 0.0 , 4 , & mut ctx) ?;
206194 let b = point_column ( vec ! [ 0.0 , 3.0 , 0.0 , 3.0 ] , vec ! [ 0.0 , 0.0 , 4.0 , 4.0 ] ) ?;
207- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
195+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
208196
209197 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 0.0 , 3.0 , 4.0 , 5.0 ] ) ;
210198 Ok ( ( ) )
@@ -218,7 +206,7 @@ mod tests {
218206
219207 let a = point_constant ( 0.0 , 0.0 , 3 , & mut ctx) ?;
220208 let b = point_constant ( 3.0 , 4.0 , 3 , & mut ctx) ?;
221- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
209+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
222210
223211 assert_eq ! ( distances( distance, & mut ctx) ?, vec![ 5.0 , 5.0 , 5.0 ] ) ;
224212 Ok ( ( ) )
@@ -245,7 +233,7 @@ mod tests {
245233
246234 let a = nullable_point_column ( vec ! [ Some ( ( 0.0 , 0.0 ) ) , None , Some ( ( 3.0 , 4.0 ) ) ] ) ?;
247235 let b = point_constant ( 0.0 , 0.0 , 3 , & mut ctx) ?;
248- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
236+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
249237
250238 let expected = PrimitiveArray :: new (
251239 vec ! [ 0.0f64 , 0.0 , 5.0 ] ,
@@ -264,7 +252,7 @@ mod tests {
264252
265253 let a = nullable_point_column ( vec ! [ Some ( ( 0.0 , 0.0 ) ) , None , Some ( ( 0.0 , 0.0 ) ) ] ) ?;
266254 let b = nullable_point_column ( vec ! [ Some ( ( 3.0 , 4.0 ) ) , Some ( ( 1.0 , 1.0 ) ) , None ] ) ?;
267- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
255+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
268256
269257 let expected = PrimitiveArray :: new (
270258 vec ! [ 5.0f64 , 0.0 , 0.0 ] ,
@@ -284,7 +272,8 @@ mod tests {
284272 let point_dtype = point_column ( vec ! [ 0.0 ] , vec ! [ 0.0 ] ) ?. dtype ( ) . as_nullable ( ) ;
285273 let null_const = ConstantArray :: new ( Scalar :: null ( point_dtype) , 3 ) . into_array ( ) ;
286274 let b = point_column ( vec ! [ 0.0 , 3.0 , 0.0 ] , vec ! [ 0.0 , 0.0 , 4.0 ] ) ?;
287- let distance = GeoDistance :: try_new_array ( null_const, b) ?. into_array ( ) ;
275+ let distance =
276+ GeoDistance . try_new_array ( null_const. len ( ) , EmptyOptions , [ null_const, b] ) ?;
288277
289278 let expected = PrimitiveArray :: new ( vec ! [ 0.0f64 ; 3 ] , Validity :: AllInvalid ) . into_array ( ) ;
290279 assert_arrays_eq ! ( distance, expected, & mut ctx) ;
@@ -299,7 +288,7 @@ mod tests {
299288
300289 let a = nullable_point_column ( vec ! [ None , None ] ) ?;
301290 let b = point_constant ( 0.0 , 0.0 , 2 , & mut ctx) ?;
302- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
291+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
303292
304293 let expected = PrimitiveArray :: new ( vec ! [ 0.0f64 ; 2 ] , Validity :: AllInvalid ) . into_array ( ) ;
305294 assert_arrays_eq ! ( distance, expected, & mut ctx) ;
@@ -315,7 +304,7 @@ mod tests {
315304
316305 let a = nullable_point_column ( vec ! [ Some ( ( 0.0 , 0.0 ) ) , None ] ) ?;
317306 let b = nullable_point_column ( vec ! [ None , Some ( ( 1.0 , 1.0 ) ) ] ) ?;
318- let distance = GeoDistance :: try_new_array ( a, b ) ? . into_array ( ) ;
307+ let distance = GeoDistance . try_new_array ( a. len ( ) , EmptyOptions , [ a , b ] ) ? ;
319308
320309 let expected = PrimitiveArray :: new ( vec ! [ 0.0f64 ; 2 ] , Validity :: AllInvalid ) . into_array ( ) ;
321310 assert_arrays_eq ! ( distance, expected, & mut ctx) ;
@@ -332,8 +321,8 @@ mod tests {
332321
333322 let a = point_column ( vec ! [ ] , vec ! [ ] ) ?;
334323 let b = point_column ( vec ! [ ] , vec ! [ ] ) ?;
335- let result = GeoDistance :: try_new_array ( a , b ) ?
336- . into_array ( )
324+ let result = GeoDistance
325+ . try_new_array ( a . len ( ) , EmptyOptions , [ a , b ] ) ?
337326 . execute :: < Canonical > ( & mut ctx) ?
338327 . into_array ( ) ;
339328
0 commit comments