Fix issue where stop points are sometimes added twice to index - #5552
Merged
habrahamsson-skanetrafiken merged 1 commit intoDec 12, 2023
Conversation
This only happens when there are duplicate JourneyPattern in the netex files.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5552 +/- ##
=============================================
- Coverage 67.19% 67.18% -0.01%
- Complexity 16040 16041 +1
=============================================
Files 1850 1850
Lines 70921 70922 +1
Branches 7410 7409 -1
=============================================
- Hits 47653 47652 -1
- Misses 20801 20802 +1
- Partials 2467 2468 +1 ☔ View full report in Codecov by Sentry. |
t2gran
approved these changes
Dec 6, 2023
jtorin
approved these changes
Dec 7, 2023
Member
|
When a duplicate is encountered it should result in an issue being added to the issue report. It might/might not be the case here, can you test if that is the case @jtorin ? If not we should add that, you may merge this PR and add another on or just append a commit this this - it is up to you. |
Contributor
Author
|
@t2gran That's a good point. I'll merge this and add that in a separate PR. |
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.
Summary
When netex data contains duplicate JourneyPatterns the scheduledStopPointsIndex will get duplicates of all the stop points for those JourneyPatterns during graph build. When the graph is loaded this will result in strange IndexOutOfBoundsExceptions in the TransferMapper.
Issue
NetexMapper uses a
Multimapfor the scheduledStopPointsIndex. But the semantics of a multimap is that putting to a key that already exists will extend any existing data that has already been added. This is not really the behaviour we want in this case.This PR fixes this issue by replacing the
Multimapwith aMap<List>. This way we will replace the current values when calling putAll().I suppose that duplicate JourneyPatterns could cause all kinds of other problems, so to solve the underlying issue we should really add some validation of the netex data for this. But I think these changes are worthwhile anyway, since it makes the code less brittle.
Unit tests
There aren't any tests for this code that I could find, and writing them feels a bit out of scope for this PR.
Documentation
Nothing needed.
Bumping the serialization version id
Nope