zhangfengcdt commented on code in PR #683:
URL: https://github.com/apache/sedona-db/pull/683#discussion_r2913069180


##########
c/sedona-s2geography/src/register.rs:
##########
@@ -14,35 +14,20 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
+
+use datafusion_common::Result;
+use sedona_common::sedona_internal_err;
 use sedona_expr::scalar_udf::ScalarKernelRef;
+use std::sync::OnceLock;
 
-use crate::scalar_kernel;
+static S2_SCALAR_KERNELS: OnceLock<Result<Vec<(String, ScalarKernelRef)>>> = 
OnceLock::new();
 
-pub fn scalar_kernels() -> Vec<(&'static str, ScalarKernelRef)> {
-    vec![
-        ("st_area", scalar_kernel::st_area_impl()),
-        ("st_centroid", scalar_kernel::st_centroid_impl()),
-        ("st_closestpoint", scalar_kernel::st_closest_point_impl()),
-        ("st_contains", scalar_kernel::st_contains_impl()),
-        ("st_convexhull", scalar_kernel::st_convex_hull_impl()),
-        ("st_difference", scalar_kernel::st_difference_impl()),
-        ("st_distance", scalar_kernel::st_distance_impl()),
-        ("st_equals", scalar_kernel::st_equals_impl()),
-        ("st_intersection", scalar_kernel::st_intersection_impl()),
-        ("st_intersects", scalar_kernel::st_intersects_impl()),
-        (
-            "st_lineinterpolatepoint",
-            scalar_kernel::st_line_interpolate_point_impl(),
-        ),
-        (
-            "st_linelocatepoint",
-            scalar_kernel::st_line_locate_point_impl(),
-        ),
-        ("st_length", scalar_kernel::st_length_impl()),
-        ("st_symdifference", scalar_kernel::st_sym_difference_impl()),
-        ("st_maxdistance", scalar_kernel::st_max_distance_impl()),
-        ("st_perimeter", scalar_kernel::st_perimeter_impl()),
-        ("st_shortestline", scalar_kernel::st_shortest_line_impl()),
-        ("st_union", scalar_kernel::st_union_impl()),
-    ]
+pub fn scalar_kernels() -> Result<Vec<(&'static str, ScalarKernelRef)>> {

Review Comment:
   I like this change and now match based on names. Since this is a public 
function and entry to the kernel functions, could we add some document here? 
such as "Initialize s2geography scalar kernels via extension ABI. lazy loading, 
return named pairs ..."



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to