-
Notifications
You must be signed in to change notification settings - Fork 1.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
Update indexes in timetable snapshot #6007
Merged
vpaturet
merged 13 commits into
opentripplanner:dev-2.x
from
entur:update_indexes_in_timetable_snapshot
Sep 11, 2024
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5b71ff1
Update indexes in timetable snapshot
vpaturet db7ccb4
Apply review suggestions
vpaturet c1c809c
Rename boolean fields in record
vpaturet 0caf435
Apply review suggestion
vpaturet 1a5c1d5
Fix TransitService.getAllXXX methods
vpaturet e176b0b
Fix indexing of pattern by stop
vpaturet 49f29b4
Update GTFS unit tests
vpaturet 9baf38b
Ensure null-safe lookup on immutable map
vpaturet f34b32d
Use CollectionsView in DefaultTransitService
vpaturet c0c88ff
Remove redundant null-check
vpaturet dae1122
Apply review suggestions
vpaturet f579cbe
Fix merge conflict
vpaturet c21826b
Merge branch 'dev-2.x' into update_indexes_in_timetable_snapshot
vpaturet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,59 @@ | ||
package org.opentripplanner.ext.siri; | ||
|
||
import java.time.LocalDate; | ||
import javax.annotation.Nonnull; | ||
import java.util.Objects; | ||
import javax.annotation.Nullable; | ||
import org.opentripplanner.transit.model.network.StopPattern; | ||
import org.opentripplanner.transit.model.network.TripPattern; | ||
import org.opentripplanner.transit.model.timetable.RealTimeTripTimes; | ||
import org.opentripplanner.transit.model.timetable.TripOnServiceDate; | ||
import org.opentripplanner.transit.model.timetable.TripTimes; | ||
|
||
/** | ||
* Represents the SIRI real-time update of a single trip. | ||
* @param stopPattern the stop pattern to which belongs the updated trip. | ||
* @param tripTimes the new trip times for the updated trip. | ||
* @param serviceDate the service date for which this update applies (updates are valid only for one service date) | ||
* @param addedTripOnServiceDate optionally if this trip update adds a new trip, the TripOnServiceDate corresponding to this new trip. | ||
* @param addedTripPattern optionally if this trip update adds a new trip pattern , the new trip pattern to this new trip. | ||
* @param routeCreation true if an added trip cannot be registered under an existing route and a new route must be created. | ||
*/ | ||
record TripUpdate( | ||
@Nonnull StopPattern stopPattern, | ||
@Nonnull TripTimes tripTimes, | ||
@Nonnull LocalDate serviceDate | ||
) {} | ||
StopPattern stopPattern, | ||
TripTimes tripTimes, | ||
LocalDate serviceDate, | ||
@Nullable TripOnServiceDate addedTripOnServiceDate, | ||
@Nullable TripPattern addedTripPattern, | ||
boolean routeCreation | ||
) { | ||
public TripUpdate { | ||
Objects.requireNonNull(stopPattern); | ||
Objects.requireNonNull(tripTimes); | ||
Objects.requireNonNull(serviceDate); | ||
} | ||
|
||
/** | ||
* Create a trip update for an existing trip. | ||
*/ | ||
public TripUpdate( | ||
StopPattern stopPattern, | ||
RealTimeTripTimes updatedTripTimes, | ||
LocalDate serviceDate | ||
) { | ||
this(stopPattern, updatedTripTimes, serviceDate, null, null, false); | ||
} | ||
|
||
/** | ||
* Return true if this trip update creates a new trip pattern. | ||
*/ | ||
public boolean tripPatternCreation() { | ||
return addedTripPattern != null; | ||
} | ||
|
||
/** | ||
* Return true if this trip update creates a new trip. | ||
*/ | ||
public boolean tripCreation() { | ||
return addedTripOnServiceDate != null; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/opentripplanner/model/RealTimeTripUpdate.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.opentripplanner.model; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Objects; | ||
import javax.annotation.Nullable; | ||
import org.opentripplanner.transit.model.network.TripPattern; | ||
import org.opentripplanner.transit.model.timetable.TripOnServiceDate; | ||
import org.opentripplanner.transit.model.timetable.TripTimes; | ||
|
||
/** | ||
* Represents the real-time update of a single trip. | ||
* @param pattern the pattern to which belongs the updated trip. This can be a new pattern created in real-time. | ||
* @param updatedTripTimes the new trip times for the updated trip. | ||
* @param serviceDate the service date for which this update applies (updates are valid only for one service date) | ||
* @param addedTripOnServiceDate optionally if this trip update adds a new trip, the TripOnServiceDate corresponding to this new trip. | ||
* @param tripCreation true if this update creates a new trip, not present in scheduled data. | ||
* @param routeCreation true if an added trip cannot be registered under an existing route and a new route must be created. | ||
*/ | ||
public record RealTimeTripUpdate( | ||
TripPattern pattern, | ||
TripTimes updatedTripTimes, | ||
LocalDate serviceDate, | ||
@Nullable TripOnServiceDate addedTripOnServiceDate, | ||
boolean tripCreation, | ||
boolean routeCreation | ||
) { | ||
public RealTimeTripUpdate { | ||
Objects.requireNonNull(pattern); | ||
Objects.requireNonNull(updatedTripTimes); | ||
Objects.requireNonNull(serviceDate); | ||
} | ||
|
||
/** | ||
* Create a real-time update for an existing trip. | ||
*/ | ||
public RealTimeTripUpdate( | ||
TripPattern pattern, | ||
TripTimes updatedTripTimes, | ||
LocalDate serviceDate | ||
) { | ||
this(pattern, updatedTripTimes, serviceDate, null, false, false); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
It's pretty difficult to follow the logic with the different trip patterns being created/fetched depending on if it's an added trip or modified trip. Also this tripPatternCache seems to have a very similar responsibility to the indexes in the snapshot.
But it looks like you are keeping the behaviour the same as previously. So I'm ok with this and we can do any further improvements in a future PR.
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 agree, this is quite convoluted and should be addressed in a follow-up PR.