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


##########
rust/sedona-spatial-join/src/partitioning/flat.rs:
##########
@@ -0,0 +1,177 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Flat (linear scan) spatial partitioner.
+//!
+//! This module provides a minimal partitioner that shares the same
+//! intersection semantics as [`crate::partitioning::rtree::RTreePartitioner`]
+//! but avoids the RTree indexing overhead. It stores partition boundaries
+//! in a flat array and performs a linear scan to classify each query
+//! bounding box.
+//!
+//! The partitioner follows the standard spatial partition semantics:
+//! - Returns [`SpatialPartition::Regular`] when exactly one boundary
+//!   intersects the query bbox.
+//! - Returns [`SpatialPartition::Multi`] when multiple boundaries
+//!   intersect the query bbox.
+//! - Returns [`SpatialPartition::None`] when no boundary intersects
+//!   the query bbox.
+
+use datafusion_common::Result;
+use geo::Rect;
+use sedona_geometry::bounding_box::BoundingBox;
+
+use crate::partitioning::util::{bbox_to_geo_rect, rect_intersection_area, 
rects_intersect};
+use crate::partitioning::{SpatialPartition, SpatialPartitioner};
+
+/// Spatial partitioner that linearly scans partition boundaries.
+pub struct FlatPartitioner {
+    boundaries: Vec<Rect<f32>>,
+    num_partitions: usize,
+}
+
+impl FlatPartitioner {
+    /// Create a new flat partitioner from explicit partition boundaries.
+    pub fn new(boundaries: Vec<BoundingBox>) -> Result<Self> {

Review Comment:
   There's going to be just a few of them so it is not a big deal here.
   
   Another place to consider is bounding box sampling 
(https://github.com/apache/sedona-db/pull/442). We'll save several megabytes of 
memory per partition. The total size of sampled bounding boxes won't be too 
large so we won't risk consuming too much additional memory by not using 
`BoundingBox2d`, so I decided to leave it as is for now.



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