-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Make StopIndex (counter) part of StopModel - not a global static instance #5488
Make StopIndex (counter) part of StopModel - not a global static instance #5488
Conversation
I'm available to help out if you need me. |
The context is notified when a new entity is build.
Eventually we want the StopModel to maintain the stop index, so the builders need to have reference to the model/model context.
This is needed to be able to create a StopModel for each test - so tests do not use the same model.
… stops, stations ...
a5bd204
to
3089724
Compare
Can you resolve the conflicts? |
…al static context
3089724
to
c0a4198
Compare
I need to get Java 21 locally, before fixing the merge. I planed to inject a context into the builders, so I have more code that I did not commit - I am not to happy with the design - the generics look ugly. And also, I run into a problem with the |
I can also fix the conflicts but it's a bit easier when it's on a branch that I can push to. How about I push this to an branch in the opentripplanner repo which we then merge back to this one? |
c0a4198
to
ebe7083
Compare
The PR is ready to review now, most of the changes is in tests. If you want to review this together we can shedule a meeting - that is the most effective, I can ask @vpaturet to join and hopefully we can merge it. I will move it to OTP Repo so you can edit it directy as well. |
src/ext-test/java/org/opentripplanner/ext/emissions/EmissionsTest.java
Outdated
Show resolved
Hide resolved
…est.java Co-authored-by: Leonard Ehrenfried <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5488 +/- ##
==========================================
Coverage 66.84% 66.85%
- Complexity 15633 15650 +17
==========================================
Files 1816 1817 +1
Lines 70084 70155 +71
Branches 7376 7378 +2
==========================================
+ Hits 46848 46899 +51
- Misses 20779 20798 +19
- Partials 2457 2458 +1
☔ View full report in Codecov by Sentry. |
src/main/java/org/opentripplanner/transit/service/StopModel.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/transit/service/StopModel.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left a few comments that you should take a look at but to me this looks ready for merging.
src/test/java/org/opentripplanner/netex/NetexEpipBundleSmokeTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Leonard Ehrenfried <[email protected]>
✅ tested: street graph -> ser -> transit graph -> ser -> routing (Entur data, whole of Norway) |
I also tested this branch with a German and an American data set. There was no problem. |
Summary
The StopModel should be responsible for the consistency and integrity of all stop related information. If two StopModels exist, then the stop index for both should start at 0 and increase by one for each RegularStop, it is ok with gaps, butmany gaps would lead to poor performance.
Issue
Closes #5480
There are tests witch relay on resetting the global stop-index, these test fail from time to time depending on the order thay are executed.
Design and alternative solutions
The stop model is prepared for injecting a context into the builders - this is something we have planed for, and wanted to do as part of the Transmodel refacoring. So, this PR then become a POK on this - we might change the design later, but we something like this. It is easier to do this on the StopModel, than on the rest of the TransitModel, because the StopModel do not have real-time updates. This is is complex solution, but it allows us to do different things:
Pros/cons: The design is flexible and let us encapsulates each model. Making it easy to test, scale and maintain. It is a bit complex to understand, and if the events between each model is not done right - it become very difficult to debug. So, we want good traceability for events and some kind of "markers/commits" to signal when to publish real-time updates. We will use this with the current copy-on-write strategy. A model is replaced with a new one - allowing trip requests to query a consistent set of models (through the Service interfaces).
Alternatives: In stead of injecting the model into builder we can explicit add entities to the model after a set of entities are created. This is a more common approach, but does not change much - except that it limits the models influence over the entity creation.
Unit tests
This PR refactor many tests, but do not add any new tests.
Documentation
JavaDoc should be updated.
Changelog
No.
Bumping the serialization version id
Yes.