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

BREAKING CHANGE: add non-geospatial option #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeffp123
Copy link

📇 Description

This adds a new non-geospatial option.

I still have yet to update the comments and document and add more test cases. I can add those things if there is any interest in this PR.

For now, I mostly wanted to confirm that it can be done.

🚨 Checklist

  • My changes do not introduce backwards compatibility issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have actively considered and searched for potential security issues and did address these.

🧪 Tests

  • I have added missing tests for related code.
  • I have manually tested my code for regression on existing functionality.
  • I have added tests that prove my fix is effective or that my feature works.

Copy link
Collaborator

@slavik-pastushenko slavik-pastushenko left a comment

Choose a reason for hiding this comment

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

Thanks for contributing!

I left a few comments. One more thing, can you update the README.md file by updating the Options and Usage sections, please?

@@ -61,6 +61,9 @@ pub struct Supercluster {

/// Clusters metadata.
cluster_props: Vec<JsonObject>,

/// Use non-geospatial coordinates?
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use . in the end instead of ?.

Copy link
Collaborator

Choose a reason for hiding this comment

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

and maybe describe what it means so it is easier for everyone to understand.

/// # Returns
///
/// A new `Supercluster` instance with the given configuration.
pub fn new_non_geospatial(options: Options) -> Self {
Copy link
Collaborator

@slavik-pastushenko slavik-pastushenko Dec 26, 2024

Choose a reason for hiding this comment

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

I don't think we need a new method that is exactly the same except for the use_non_geospatial_coords property value. We can reuse the existing new by setting the cluster_type enum property from the options parameter.

Copy link
Author

Choose a reason for hiding this comment

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

Can you advise how to do this? I am fairly new to Rust, and I cannot think of a way to add a property to Options without breaking backwards compatibility.

Copy link
Collaborator

@slavik-pastushenko slavik-pastushenko Dec 26, 2024

Choose a reason for hiding this comment

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

Sure,

Copy link
Author

Choose a reason for hiding this comment

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

That does not sound right. If let's say I add a new parameter Options is_non_geospatial: bool, then any place that I set the Options that are passed to Supercluster will need to include is_non_geospatial in those options.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about using an enum instead of a boolean flag? This way it is clearer which cluster type we want to use. Check the comments above about this suggestion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, we can use an enum type to control it instead of a boolean flag.
The only place we need options is when we initialise Supercluster.

Copy link
Author

Choose a reason for hiding this comment

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

Ok. So, I add:

cluster_type: ClusterType

to Options.

Now any previous code that instantiates a new Supercluster that wants to use the default geo-spatial use-case will break because cluster_type is missing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Correct, we introduce a breaking change but I will mention it in the upcoming Changelog.md.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, as long as you are cool with it, I like this a lot more.

I was mostly trying to protect against a breaking change.

In other languages (i.e. Python), I would just introduce the new option with a default value. I wish there was some way to do something similar in Rust. Alas, Rust demands being explicit. Not a bad thing, but just different.

Ok, I will introduce the breaking change as suggested!

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks!
I will update CI to generate release notes and it will be visible that we generated a breaking change.

data: &[f64],
i: usize,
cluster_props: &[JsonObject],
use_non_geospatial_coords: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update the description of the get_cluster_json for this property.

Copy link
Collaborator

Choose a reason for hiding this comment

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

it can be an enum value from cluster_type instead of a boolean flag.

@@ -61,6 +61,9 @@ pub struct Supercluster {

/// Clusters metadata.
cluster_props: Vec<JsonObject>,

/// Use non-geospatial coordinates?
use_non_geospatial_coords: bool,
Copy link
Collaborator

@slavik-pastushenko slavik-pastushenko Dec 26, 2024

Choose a reason for hiding this comment

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

What about replacing it with an enum:

pub enum ClusterType {
 GeoSpatial,
 
 NonGeoSpatial,
}

and use it instead of a boolean flag. This way it will be easier to understand and maintain.

@slavik-pastushenko slavik-pastushenko added the feature New feature or request label Dec 26, 2024
@slavik-pastushenko slavik-pastushenko linked an issue Dec 26, 2024 that may be closed by this pull request
@slavik-pastushenko slavik-pastushenko changed the title adds non-geospatial option BREAKING CHANGE: add non-geospatial option Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for non-geospatial?
2 participants