Skip to content

The sixth revision#11

Merged
habedi merged 43 commits into
mainfrom
develop
Aug 23, 2025
Merged

The sixth revision#11
habedi merged 43 commits into
mainfrom
develop

Conversation

@habedi

@habedi habedi commented Aug 23, 2025

Copy link
Copy Markdown
Owner

This revision adds the R*-tree implementation. It also refactors existing spatial trees. The changes improve performance, safety, and the API.

  • Added a complete R*-tree implementation for 2D and 3D points. See Implement additional trees #2
  • Refactored core logic for all trees to improve performance and reduce code duplication.
  • Replaced internal panics with Result types for safer error handling.
  • Added kNN search support to the Python bindings.
  • Expanded the test suite to cover serialization, underflow, and other edge cases.
  • Updated the documentation with a feature roadmap and new examples.
  • Fixed a lot of bugs.

habedi added 30 commits August 21, 2025 23:44
- Minor formatting improvements across multiple files
- Refactored `RTree` `knn_search` logic to fix redundant tuple syntax
- Introduced 2D and 3D point support with corresponding tests
- Expanded `BoundingVolume` trait with `overlap` and `margin` methods
- Updated `kNN` and `range_search` methods to accept a generic `DistanceMetric`.
- Unified benchmarks and tests to explicitly utilize `EuclideanDistance`.
- Demonstrated `ManhattanDistance` implementation in examples.
- Implemented bulk insertion benchmarks for Quadtree, Octree, KdTree, RTree, and RStarTree in 2D and 3D.
- Updated tests to validate bulk insertion for all supported spatial tree structures.
- Refactored Python examples to use bulk insertion methods.
- Adjusted benchmark parameters for consistency and added new criterion configuration.
- Implemented serialization and deserialization for Quadtree, Octree, KdTree, RTree, and RStarTree using `serde`.
- Added serialization examples to Python and Rust examples.
- Created comprehensive unit tests and benchmarks for serialization and deserialization.
- Refactored code to ensure compatibility with the new serialization features.
…pand README examples

- Implemented benchmark functions for bounding box range search using R*-tree in 2D and 3D.
- Updated the `benches` group to include new benchmark tests.
- Expanded README with detailed usage examples for bulk insertion, querying, and serialization across all spatial tree structures.
…nd serialization sections into the main README.
- Clarified installation and usage descriptions in the main README.
- Updated `pyspart/README.md` to improve example references and reorganize content.
- Included Spart logo at the top of the README.
- Added an acknowledgements section for logo attribution.
- Added details about Spart's Python bindings, including installation and usage instructions.
- Enhanced README with notes on supported features, development status, and additional documentation references.
- Improved formatting for concepts and debugging sections.
- Added extensive test cases for `knn_search`, `range_search`, and `delete` operations, including edge cases for various tree structures (Quadtree, Octree, KDTree, RTree, and RStarTree).
- Documented new tree behaviors and edge cases in the main and PySpart READMEs.
- Updated `knn_search` to handle `k=0` gracefully across all trees.
- Simplified and streamlined insertion process for clarity and reduced redundancy.
- Added `unreachable!` checks to enforce boundary logic consistency.
- Implemented robust delete logic for managing node underflows by reinserting orphaned entries.
- Introduced `min_entries` field to enforce minimum occupancy during deletions.
- Expanded test suite to validate underflow scenarios and ensure correctness across edge cases.
- Introduced forced reinsertion mechanism to handle node overflows during insertion, improving tree balancing.
- Refactored insertion logic to include recursive handling of overflows and node splitting.
- Added a test case to validate forced reinsertion behavior and tree height stability.
…l errors with `unwrap`

- Updated all `new` constructors in tree structures (RTree, RStarTree, Quadtree, Octree, and KdTree) to explicitly handle potential `Result` types using `.unwrap()`.
- Adjusted benchmarks, tests, and Python bindings to match the new safety mechanism.
- Simplified error management during tree initialization.
- Refactored delete and insert benchmarks to use explicit `iter_with_setup` for clearer setup and execution separation.
- Removed intermediate `info!` logging from KNN and range search benchmarks for cleaner output.
- Increased `BENCH_NUM_INSERT` to 10,000 for more comprehensive test coverage.
…_common`

- Moved shared algorithms (delete, range search, KNN, MBR computation) into `rtree_common` module.
- Unified `EntryAccess` and `NodeAccess` traits to abstract R-tree and R*-tree implementations.
- Simplified RTree and RStarTree structures by delegating common functionality to `rtree_common`.
- Removed duplicated code and added reusable trait implementations.
- Simplified `RTree` and `RStarTree` implementations by eliminating the need for the `Ord` trait on point data.
- Replaced tuple-based k-NN heap with `HeapItem` struct to handle ties and maintain consistent ordering.
- Adjusted k-NN search logic for both 2D and 3D variants to integrate with the new heap structure.
…es and streamline ownership semantics across spatial trees, tests, and benchmarks.
- Added `r_star_tree.py` example to demonstrate 2D and 3D R*-tree usage for k-NN and range searches.
- Introduced `bench_serialization` module and integrated it into the benchmarking suite for testing serialization performance.
…nd RStarTree

- Simplified k-NN heap logic by replacing the custom `OrdDist` implementation with `OrderedFloat<f64>`.
- Reduced redundancy and improved consistency across spatial tree structures.
- Renamed `r_star_tree.py` to `rstar_tree.py` for consistency.
- Added Python quick-start and per-example run instructions in `pyspart/examples/README.md`.
- Updated Rust `examples/README.md` with an entry for R*-tree.
- Updated root `README.md` to include Python R*-tree examples and steps.
- Extended Makefile to include `rstar_tree.py` in `make run-py-examples`.
habedi added 13 commits August 23, 2025 09:45
…-tree and R-tree

- Moved `compute_group_mbr` and `search_node` functions to a shared module (`rtree_common`) to improve code reuse.
- Updated `compute_group_mbr` to return `Option` for safer handling of empty inputs.
- Replaced unwraps with safe handling (`if let` and `expect`) for bounding volume computations.
- Simplified k-NN and range query implementations for readability.
… across spatial trees and update related tests and assertions
…nd Python GIL for safe cloning; simplify k-NN and range query mappings by removing redundant clones.
…icking

- Updated `BSPBounds` trait to return `Result` for `center` and `extent` methods.
- Replaced `panic!` with `Err` for invalid dimensions in `Rectangle`, `Cube`, and related implementations.
- Adjusted `KdPoint` trait and implementations to return `Result` for `coord` method.
- Replaced unwraps with proper error handling in R*-tree and k-d tree logic for coordinate and center access.
…andling and dimension inference

- Removed `new(k)` constructor in favor of `new()` with inferred dimensions.
- Added `DimensionMismatch` error for insertions with incompatible dimensions.
- Updated insert and bulk insert methods to return `Result` instead of panicking.
- Adjusted tests and examples to align with new KdTree API.
- Removed unused benchmark functions and `dead_code` warnings.
- Simplified KdTree insert methods to improve error handling and comply with new API updates.
- Streamlined benchmark definitions to remove unnecessary helpers and reduce verbosity.
- Removed dimension parameter from `KdTree::new()` for consistency with updated API.
- Updated insert methods to use `Result` handling and suppress unused values.
- Simplified geometry imports in benchmarks by removing unused types.
- Updated `insert_bulk` in Python bindings to suppress unused value warnings.
- Added k-NN search functionality (`knn_search`) to 2D and 3D R-trees in examples.
- Enhanced test cases with assertions for k-NN search in 2D and 3D R-trees.
- Updated README to indicate missing features in Python bindings.
…, Manhattan distance, and structured initialization examples
- Added `.github/FUNDING.yml` with GitHub sponsor details.
- Updated pre-commit configuration to include explicit `pre-commit` stages for format and lint hooks.
@habedi habedi self-assigned this Aug 23, 2025
@habedi habedi added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Aug 23, 2025
@codecov

codecov Bot commented Aug 23, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.21346% with 325 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.79%. Comparing base (9f0b42f) to head (1fa164d).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/r_star_tree.rs 75.29% 106 Missing ⚠️
src/octree.rs 66.52% 79 Missing ⚠️
src/r_tree.rs 59.63% 67 Missing ⚠️
src/kd_tree.rs 76.59% 22 Missing ⚠️
src/quadtree.rs 78.00% 22 Missing ⚠️
pyspart/src/lib.rs 0.00% 11 Missing ⚠️
src/geometry.rs 71.79% 11 Missing ⚠️
src/rtree_common.rs 90.38% 5 Missing ⚠️
src/exceptions.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
+ Coverage   65.40%   72.79%   +7.39%     
==========================================
  Files           7       10       +3     
  Lines        1240     1908     +668     
==========================================
+ Hits          811     1389     +578     
- Misses        429      519      +90     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@habedi habedi merged commit 8a053ad into main Aug 23, 2025
10 checks passed
@habedi habedi deleted the develop branch August 23, 2025 11:31
habedi added a commit that referenced this pull request Aug 26, 2025
habedi added a commit that referenced this pull request Oct 3, 2025
habedi added a commit that referenced this pull request Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant