Repository navigation
fix(rust/sedona-functions): check collections member by member in ST_IsClosed - #1602
Merged
paleolimbot merged 1 commit intoNov 23, 2026
Merged
Conversation
…IsClosed Since apache#1600, is_geometry_empty() looks into a collection's members, recursing into nested collections, until it finds one that is not empty. is_geometry_closed() called it at every level before recursing into the members, so for a collection nested d levels deep around a non-empty geometry each level searched all the levels below it again: O(d^2) work. Collections are now handled before the emptiness check: an empty member is not closed, so checking the members also covers a collection whose members are all empty, and only a collection without members needs its own check. Results are unchanged; a new test pins them for collections. Closes apache#1601. Generated-by: Claude Code (Claude)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1601.
Summary
Since #1600,
is_geometry_emptylooks into a collection's members, recursing into nested collections, until it finds one that is not empty.ST_IsClosedcalled it on every geometry before recursing into a collection's members, so for a collection nested around a non-empty geometry each level searched all the levels below it again, and a collection nested d levels deep took O(d²) work.is_geometry_closednow handles a collection before the emptiness check, as suggested in #1601. An empty member is not closed, so checking the members also covers a collection whose members are all empty. Only a collection without members needs its own check, and it still returnsfalse. Results are unchanged.Time per call of
is_geometry_closedon a collection nested around one point (debug build, Linux, all three measured in the same run). This PR brings it back to what it was before #1600:main(with #1600)Test plan
udf_collectionstest: empty collections, collections whose members are all empty, an empty member next to a non-empty one, and closed and open members, nested and not. It passes before and after this change, and fails if the check for a collection without members is removed. All seven cases match PostGIS 3.6.4.cargo test -p sedona-functions(669 passed),cargo clippy -p sedona-functions --all-targets -- -D warnings, andcargo fmt --all -- --check(Linux).