Repository navigation
Refactor unfavoring of virtual edges (#885) - #909
Conversation
There was a problem hiding this comment.
The intention was to make the semantics of enforceHeadingByEdgeId more clear by renaming this method to unfavorVirtualEdgePair.
There was a problem hiding this comment.
Do you have a test case showing this bug?
There was a problem hiding this comment.
The bug was that multiple invocations of enforceHeadingByEdgeId added more and more edges to modifiedEdges. clearUnfavoredStatus() would then go over all previous edges again although their unfavored status had already been cleared.
However, this bug was not observable before because modifiedEdges could not be accessed from outside this class.
There was a problem hiding this comment.
Can we reduce this to List<EdgeIteratorState> or is the implementation necessary?
There was a problem hiding this comment.
The implementation class should not be necessary for graphhopper/map-matching#70.
One thing I didn't like about VirtualEdgeIteratorState is that detach() is not supported. If we return List<VirtualEdgeIteratorState> here, the user can at least figure out if it is supported. (Unfortunately, he would have to figure this out from the code since it is not explained in the javadoc.)
There was a problem hiding this comment.
Then I think we should still use EdgeIteratorState and if people need detach we have to implement this :) (in another issue). The less stuff is public the better for refactoring later on.
There was a problem hiding this comment.
Do you have a test case showing this bug?
There was a problem hiding this comment.
Can we reduce this to List<EdgeIteratorState> or is the implementation necessary?
boldtrn
left a comment
There was a problem hiding this comment.
Nice PR @stefanholder. Would you mind adding a Testcase that shows the issue described in #885 and that it is solved by your PR?
2303b15 to
70b8d34
Compare
Done.
Done. |
| private List<VirtualEdgeIteratorState> modifiedEdges = new ArrayList<VirtualEdgeIteratorState>(5); | ||
|
|
||
| // Use LinkedHashSet for predictable iteration order. | ||
| private final Set<VirtualEdgeIteratorState> unfavoredEdges = new LinkedHashSet<>(5); |
There was a problem hiding this comment.
Now using Set instead of List to store unfavoredEdges.
|
@boldtrn please confirm & merge (as here just one author it is safe to 'squash and merge') |
|
Hmmh, why isn't it added to the latest commit? |
Simply speaking, because adding something and deleting the same in a single commit results in no change. The test cases of the first commit test |
|
Ok, then you mean 'lost' in the sense for historical reasons. Makes sense. @boldtrn |
Sure. Happy for you to close it when merged, or I can. |
| VirtualEdgeIteratorState incomingEdgeReverse = (VirtualEdgeIteratorState) queryGraph.getEdgeIteratorState(1, incomingEdge.getBaseNode()); | ||
| boolean expect = true; // expect incoming edge to be avoided | ||
| assertEquals(expect, incomingEdge.getBool(EdgeIteratorState.K_UNFAVORED_EDGE, !expect)); | ||
| expect = false; // expect reverse incoming edge not to be avoided |
There was a problem hiding this comment.
Why not remove expect = false. That way it would fail before your PR => Showing the issue. Then you add your PR and therefore fix the failing test case. The order is not important at this point :).
There was a problem hiding this comment.
Actually, it only fails with expect = false, which shows the issue. However, this test becomes obsolete with this PR, see above.
|
@stefanholder Thanks for adding a test.
The reason why I asked you to add a test was to document the issue and make sure that we don't add a similar issue by mistake in the future. See my comment. But maybe I am overthinking this issue? I will approve my review, that's probably somethin @karussell has to decide. |
@karussell, squashing a PR via the github UI always changes the author to the person that does the squash merging. I just verified this with a test squash. The reason behind this is that github uses the Note that it's possible to disable squash merging in the github repository options. Squashing without changing authorship can be done manually using |
|
Merged, thanks @stefanholder.
Sorry, I think I was over complicating things with this test. I was hoping to write a test that shows #885, but since we changed the API of the method, this is not possible. |
The author will be still the original author (see 'git log'), still github will show the one who merged it. |
Sure, still this is useful e.g. if the pull requester does not know about this and the PR contains several intermediate commits. For the future I would suggest the following (where we can disable squashing): we merge the PR even if some commits are 'superfluous' but ask the contributor to squash as much as possible. WDYT?
From my experiences with github this has the same effect to the author entry as doing the squash in the UI |
Doesn't GitHub show both? |
That was what I meant. In the git log you only see the original author. |
|
@stefanholder I hope it was ok that I squashed the PR? Do you think we should add the test in the commit history? |
Yes, it's OK. I think it would have been better to merge both commits so that the failing test would still be in the git history but this is a minor thing. |
In general I think this is a good idea but some contributors might not be familiar with squashing via
Not for squashed merges via the github UI. I just tested this with a fork of https://github.com/graphhopper/jsprit. After a squashed merge of the last two commits github changes the author to me and sets [email protected] as the committer (I used I guess that github sets the person as the author who created the pull request. This would explain why @karussell was set as the committer for graphhopper/map-matching#49. When I did a rebase merging of the last two commits with github UI, the author stayed the same but the committer was changed to the person doing the rebase merging: This also happens when manually merging a commit of somebody else into another branch. |




This addresses issue #885.
Also needed for graphhopper/map-matching#70