Skip to content

Remove EncodedValueFactory - #2551

Merged
easbar merged 2 commits into
masterfrom
remove_ev_factory
Apr 5, 2022
Merged

easbar merged 2 commits into
masterfrom
remove_ev_factory

Conversation

@easbar

@easbar easbar commented Apr 5, 2022

Copy link
Copy Markdown
Member

Fixes #2438.

tldr;
Why do we need EncodedValueFactory? We don't. Should we create encoded values in two different places (TagParsers and EncodedValueFactory)? No. Should we support two different ways to initialize GraphHopper that do not even follow the same semantics? Also no.

Our current approach is to configure the GraphHopper class the same way to load graph data as we did when we imported data. This does not make much sense, and we should much rather just load the graph from disk when loading, but this is the way we do it currently. So we should do it the same way no matter if we call init() or not, importOrLoad() or load(). Therefore, I now also build the encoding manager from the GraphHopper class' state when loading without init() (instead of reading the properties file). And since this was the only scenario where we even used EncodedValueFactory it can be removed.

When FlagEncoders are gone (#2463) and encoded values are no longer created in TagParsers (soon) we can revisit this and hopefully some day we will simply load everything from disk when using load()...

Comment on lines +40 to +46
// todo: not sure if this is worth it just to slightly improve the error message
private final Set<String> knownEncodedValues = new HashSet<>(Arrays.asList(
Roundabout.KEY, "car_access", "bike_access", GetOffBike.KEY, RoadClass.KEY, RoadClassLink.KEY, RoadEnvironment.KEY,
RoadAccess.KEY, MaxSpeed.KEY, MaxWeight.KEY, MaxWidth.KEY, MaxAxleLoad.KEY, MaxLength.KEY, Surface.KEY, Smoothness.KEY,
Toll.KEY, TrackType.KEY, BikeNetwork.KEY, FootNetwork.KEY, Hazmat.KEY, HazmatTunnel.KEY, HazmatWater.KEY,
Lanes.KEY, MtbRating.KEY, HikeRating.KEY, HorseRating.KEY, Country.KEY
));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@karussell: If I got this right we used the DefaultEncodedValueFactory here to distinguish between 'invalid identifiers' and names of encoded values that are known to the factory, but were not added to the graph. The only purpose of this seem to be improved error messages. I replaced the hard-coded factory with a hard-coded list of encoded value names here. But actually I think we should consider removing this list. A given graphhopper instance has a list of encoded values stored in the graph. I don't think we should maintain a list of encoded values that aren't there, but could be there... At least not until we use such a list of encoded values that could be there (a registry in a way) to actually create the encoded values. Anyway, I updated this list according to: #2438 (comment).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, sure. Let's remove this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See #2554

@easbar
easbar merged commit 043652f into master Apr 5, 2022
@easbar
easbar deleted the remove_ev_factory branch April 5, 2022 09:03
@easbar easbar added this to the 6.0 milestone Apr 5, 2022
@karussell karussell mentioned this pull request Apr 6, 2022
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.

Why do we need EncodedValueFactory?

2 participants