-
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
Cluster consolidated stops in geocoder #5907
Cluster consolidated stops in geocoder #5907
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5907 +/- ##
=============================================
+ Coverage 69.45% 69.47% +0.01%
- Complexity 17064 17082 +18
=============================================
Files 1927 1932 +5
Lines 73578 73615 +37
Branches 7549 7550 +1
=============================================
+ Hits 51106 51146 +40
+ Misses 19847 19845 -2
+ Partials 2625 2624 -1 ☔ View full report in Codecov by Sentry. |
I looked at Truth vs AssertJ. They are similar. AssertJ is a bit more open, but Truth is probably a bit more well designed. This is written by the people creating Truth, but seems to be fairly objective and the best comparison I could find. I also looked at a few key numbers on the github repo (stars/users/activity) and they both seems to be maintained and mature. Conclusion: I like Truth slightly better than AssertJ. I support starting to experiment with Truth (the core lib only) and decide later if we want to keep it or not. This do add "another lib" witch a OTP developer should master. There are pitfalls, so it everyone doing reviews need to spend time on learning it, if we decide to go "all in". |
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.
Works on clustered bus stops in Atlanta as far as I have tested. Just one comment typo but otherwise it looks solid.
src/ext/java/org/opentripplanner/ext/geocoder/configure/GeocoderModule.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.
If I got it right(not sure if I am), then the LuceneIndex should not be request-scoped (building the index for revery request). I do not think it need to depend on the TransitService, it could use only the stop-model?
LOG.info("Creating debug client geocoder lucene index"); | ||
LuceneIndex.forServer(createServerContext()); | ||
LOG.info("Initializing geocoder"); | ||
this.factory.luceneIndex(); |
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.
The factory create a new instance every time you call it? I do not think this code has any effect?
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.
The LuceneIndex is annotated as @Singleton
:
OpenTripPlanner/src/ext/java/org/opentripplanner/ext/geocoder/configure/GeocoderModule.java
Line 19 in a714a53
@Singleton |
The idea here is to initialize the geocoder eagerly rather than on the first request.
@@ -87,6 +90,9 @@ public interface ConstructApplicationFactory { | |||
|
|||
StreetLimitationParameters streetLimitationParameters(); | |||
|
|||
@Nullable | |||
LuceneIndex luceneIndex(); |
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 think this is creating the index - reindexing for every request?
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.
You should pass it in using the builder if you do not want it to be created every time.
@@ -65,9 +70,12 @@ public class LuceneIndex implements Serializable { | |||
private final SuggestIndexSearcher searcher; | |||
private final StopClusterMapper stopClusterMapper; | |||
|
|||
public LuceneIndex(TransitService transitService) { | |||
public LuceneIndex( | |||
TransitService transitService, |
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.
The transit service is request scoped, is the LuceneIndex request-scoped?
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.
No, it isn't and I've reworked this in the newest commits. However, I do need a few methods from TransitService. Is it ok to instantiate it myself or should I create my own wrapper around the TransitModel?
9158967
to
e604a3c
Compare
e604a3c
to
a714a53
Compare
Note to self: add comment to LuceneIndex constructor. |
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 will come back to this after doing the DI on the API resources.
Summary
This connects two sandbox features with each other: IBI's consolidated stops and and the geocoder.
In order to do this, the
LuceneIndex
was moved out of the Graph and into a Dagger module which instantiates it (or not) based on the feature flags.cc @miles-grant-ibigroup
Unit tests
I added a unit test.
Most importantly, it adds a dependency on the assertion library
truth
by Google which allows you to write assertions against collections (among other things) which have very helpful error messages, like this: