Skip to content

Add paging deduplication when cropping. - #5458

Merged
t2gran merged 3 commits into
opentripplanner:dev-2.xfrom
entur:dedupe_filter
Nov 20, 2023
Merged

Add paging deduplication when cropping.#5458
t2gran merged 3 commits into
opentripplanner:dev-2.xfrom
entur:dedupe_filter

Conversation

@eibakke

@eibakke eibakke commented Oct 27, 2023

Copy link
Copy Markdown
Contributor

Summary

Creates deduplication filter and adds deduplication information into the page cursor.

The paging deduplication compares an ItinerarySortKey from the page cursor to the set of itineraries to be returned. It then removes itineraries that sort on the "inside" of the ItinerarySortKey - ie. before the ItinerarySortKey when the tail is cropped and after the ItinerarySortKey when the head is cropped.

Issue

#5040

This PR solves the issue of duplicate itineraries described in the page cursor doc: https://github.com/opentripplanner/OpenTripPlanner/tree/dev-2.x/src/main/java/org/opentripplanner/model/plan/pagecursor#sort-by-arrival--crop-search-window

During implementation I discovered that duplicates can appear when paging in all four directions (forward and backward for arrive by and depart after searches). This change fixes the issue in all of them with a general solution.

Unit tests

I've added new unit tests and modified existing ones as needed. I've also tested extensively locally with conditions that uncovered duplicate issues in all directions.

Documentation

I've added documentation as JavaDoc. I will update the page cursor readme in a follow up change.

@eibakke

eibakke commented Oct 27, 2023

Copy link
Copy Markdown
Contributor Author

This change depends on pull requests #5436 and #5450.

@codecov

codecov Bot commented Oct 27, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 50 lines in your changes are missing coverage. Please review.

Comparison is base (112e9ad) 66.85% compared to head (3afb997) 66.90%.
Report is 81 commits behind head on dev-2.x.

Files Patch % Lines
...er/model/plan/pagecursor/PageCursorSerializer.java 0.00% 25 Missing and 2 partials ⚠️
...lanner/model/plan/pagecursor/ItineraryPageCut.java 33.33% 14 Missing ⚠️
...erchain/deletionflagger/PagingDuplicateFilter.java 81.25% 1 Missing and 2 partials ⚠️
...n/deletionflagger/NumItinerariesFilterResults.java 77.77% 1 Missing and 1 partial ⚠️
...rithm/mapping/RouteRequestToFilterChainMapper.java 0.00% 1 Missing and 1 partial ⚠️
...ntripplanner/model/plan/pagecursor/PageCursor.java 75.00% 0 Missing and 1 partial ⚠️
...m/filterchain/ItineraryListFilterChainBuilder.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5458      +/-   ##
=============================================
+ Coverage      66.85%   66.90%   +0.05%     
- Complexity     15655    15734      +79     
=============================================
  Files           1817     1823       +6     
  Lines          70160    70366     +206     
  Branches        7383     7403      +20     
=============================================
+ Hits           46904    47081     +177     
- Misses         20798    20820      +22     
- Partials        2458     2465       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@t2gran t2gran added this to the 2.5 (next release) milestone Oct 27, 2023
@eibakke
eibakke marked this pull request as ready for review November 9, 2023 08:12
@eibakke
eibakke requested a review from a team as a code owner November 9, 2023 08:12
@leonardehrenfried

Copy link
Copy Markdown
Member

Can you merge dev2.x to get rid of the flaky test?

Bartosz-Kruba
Bartosz-Kruba previously approved these changes Nov 13, 2023
@eibakke
eibakke marked this pull request as ready for review November 13, 2023 14:04
@eibakke

eibakke commented Nov 13, 2023

Copy link
Copy Markdown
Contributor Author

Finally successfully merged in dev2.x - messed up a lot on the way, but back in a good state now.

@t2gran t2gran added !Bug Apply to issues describing a bug and PRs witch fixes it. !Improvement A functional improvement or micro feature labels Nov 14, 2023
Bartosz-Kruba
Bartosz-Kruba previously approved these changes Nov 16, 2023
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/PageCursor.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/PageCursor.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/PageCursorFactory.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/PageCursorFactory.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/ItineraryPageCut.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/ItineraryPageCut.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/ItineraryPageCut.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/ItineraryPageCut.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/ItineraryPageCut.java Outdated
Comment thread src/main/java/org/opentripplanner/model/plan/pagecursor/ItineraryPageCut.java Outdated

@t2gran t2gran left a 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.

There is a few small refactorings that should be done here, but I will do those in another PR.

@t2gran
t2gran merged commit 4f947cd into opentripplanner:dev-2.x Nov 20, 2023
@t2gran
t2gran deleted the dedupe_filter branch November 20, 2023 19:48
t2gran pushed a commit that referenced this pull request Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Bug Apply to issues describing a bug and PRs witch fixes it. !Improvement A functional improvement or micro feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants