Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove error and ctor options from direct ctors #530

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

peterstace
Copy link
Owner

@peterstace peterstace commented Sep 20, 2023

Description

Modify direct constructors (NewPoint etc.) to no longer perform validation at all. The direct constructors are for more advanced use cases where geometries are being constructed from other geometries or raw sequences of floats. Things like custom geometric algorithms come to mind. Because these are for advanced use cases, making users validate manually is reasonable.

Modifying direct constructors removes error handling mismatch, with users no longer having to handle errors that can never occur (when validation is disabled). It also eliminates the situation where constructor options would sometimes be ignored, and simplifies the rules around what validation occurs during direct construction (i.e. now none is performed).

See #525 for more context.

Check List

Have you:

  • Added unit tests? Yes.

  • Add cmprefimpl tests? (if appropriate?) N/A.

  • Updated release notes? (if appropriate?) No. This will be done when all constructor option changes are complete.

Related Issue

Benchmark Results

Benchmark results are attached. Some notes about the apparent regressions:

  • MultiPolygon validation is now slower, because it also validates that the Polygons in the collection are valid. This is a functionality change, so it's expected that this would be reflected in the benchmark results.
  • Some WKB Parsing now uses more memory (although has about the same wall time). I'm not really sure what's going on there. It's pretty minor, and I don't think worth tracking down.

results.txt

Modify direct constructors (`NewPoint` etc.) to no longer perform
validation at all. The direct constructors are for more advanced use
cases where geometries are being constructed from other geometries or
raw sequences of floats. Things like custom geometric algorithms come to
mind. Because these are for advanced use cases, making users validate
manually is reasonable.

Modifying direct constructors removes error handling mismatch, with
users no longer having to handle errors that can never occur (when
validation is disabled). It also eliminates the situation where
constructor options would sometimes be ignored, and simplifies the rules
around what validation occurs during direct construction (i.e. now none
is performed).
@peterstace peterstace self-assigned this Sep 20, 2023
@@ -81,6 +81,9 @@ func setOp(a Geometry, include func([2]bool) bool, b Geometry) (Geometry, error)
if err != nil {
return Geometry{}, wrap(err, "internal error extracting geometry")
}
if err := g.Validate(); err != nil {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation is removed from extractGeometry, so it occurs right at the end now.

A similar pattern is used for the parsers (WKB etc.) as well.

@peterstace
Copy link
Owner Author

Thanks for reviewing @albertteoh , I really appreciate it 😁

Base automatically changed from remove_validation_from_transform_xy to master September 26, 2023 19:03
@peterstace peterstace merged commit d18df4e into master Sep 26, 2023
1 check passed
@peterstace peterstace deleted the remove_error_and_ctor_options_from_direct_ctors branch September 26, 2023 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants