Skip to content
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 APIs work per-segment like Lucene's Collector. #10389

Merged
merged 1 commit into from Apr 7, 2015

Conversation

jpountz
Copy link
Contributor

@jpountz jpountz commented Apr 2, 2015

We still have a lot of APIs that use setNextReader in order to change the
current segment that should be considered. This commit moves such APIs to
getLeafXXX() instead to be more in-line with Lucene 5's collector API.

I also renamed setDocId to setDocument to be more in-line with the doc values
APIs.

@jpountz
Copy link
Contributor Author

jpountz commented Apr 2, 2015

Hmm, I had not realized this PR was getting so large... If you need any guidance for the reviews please let me know. There is one place where the refactoring was not straightforward: ExpressionScript. The reason is that if the script references the score, you need a Scorer object to be in the context, but with this new API, the scorer can only be set AFTER the per-segment script has been created. So what I did is that I re-instanciate the values in setScorer. /cc @rjernst

For the record, this PR will break existing script plugins as it splits SearchScript into SearchScript and LeafSearchScript, the former being only responsible for creating per-leaf LeafSearchScript objects. I will fix them when this PR gets in. /cc @dadoonet

@dadoonet
Copy link
Member

dadoonet commented Apr 2, 2015

Thank you so much @jpountz!

@jpountz jpountz self-assigned this Apr 3, 2015
@jpountz
Copy link
Contributor Author

jpountz commented Apr 3, 2015

@rjernst FYI I assigned you for the review like we discussed.

@jpountz jpountz assigned rjernst and unassigned jpountz Apr 3, 2015
if (this.reader == context.reader()) { // if we are called with the same reader, don't invalidate source
public void setSource(LeafReaderContext context, int docId) {
if (this.reader == context.reader() && this.docId == docId) {
// if we are called with the same docId, don't invalidate source
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe say document instead of docId? since the check is technically same docId in the same segment?

@rjernst
Copy link
Member

rjernst commented Apr 4, 2015

LGTM, just a couple minor comments.

@jpountz
Copy link
Contributor Author

jpountz commented Apr 7, 2015

I pushed a new commit that addresses comments. Will merge soon.

We still have a lot of APIs that use setNextReader in order to change the
current segment that should be considered. This commit moves such APIs to
getLeafXXX() instead to be more in-line with Lucene 5's collector API.

I also renamed setDocId to setDocument to be more in-line with the doc values
APIs.

Close elastic#10389
@jpountz jpountz force-pushed the enhancement/per_segment_apis branch from 85792a8 to 967a4e2 Compare April 7, 2015 16:16
jpountz added a commit that referenced this pull request Apr 7, 2015
Internal: Make APIs work per-segment like Lucene's Collector.

Close #10389
@jpountz jpountz merged commit 22472b7 into elastic:master Apr 7, 2015
@jpountz jpountz deleted the enhancement/per_segment_apis branch April 7, 2015 16:17
jpountz added a commit to elastic/elasticsearch-lang-javascript that referenced this pull request Apr 9, 2015
jpountz added a commit to elastic/elasticsearch-lang-mvel that referenced this pull request Apr 9, 2015
jpountz added a commit to elastic/elasticsearch-lang-python that referenced this pull request Apr 9, 2015
@clintongormley clintongormley changed the title Internal: Make APIs work per-segment like Lucene's Collector. Make APIs work per-segment like Lucene's Collector. Jun 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants