Kontinuation commented on code in PR #169:
URL: https://github.com/apache/sedona-db/pull/169#discussion_r2392216585


##########
rust/sedona-spatial-join/src/index.rs:
##########
@@ -557,32 +537,15 @@ impl SpatialIndex {
             }
         };
 
-        // Use pre-computed cached geometries for performance
-        let geometries = &self.cached_geometries;
-
-        if geometries.is_empty() {
-            return Ok(JoinResultMetrics {
-                count: 0,
-                candidate_count: 0,
-            });
-        }
-
-        // Choose distance metric based on use_spheroid parameter
-        let distance_metric: Box<dyn DistanceMetric<f32>> = if use_spheroid {
-            // For spheroid (geodesic) distance, we use the Haversine formula 
as an approximation for now.
-            // The distance metric will be used to calculate distances between 
geometries for ranking purposes.
-            Box::new(HaversineDistance::default())
-        } else {
-            Box::new(EuclideanDistance)
-        };
+        // Create an indexed distance metric adapter for KNN queries with 
cached distance metrics
+        let indexed_metric = self.create_knn_adapter(use_spheroid);

Review Comment:
   The geometry cache in the KNN adapter is not reused across multiple 
`query_knn` calls. This renders the cache mostly useless.



-- 
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