Skip to content

Factor out filling of TopDocs in SearchPhaseController#23380

Merged
s1monw merged 2 commits intoelastic:masterfrom
s1monw:factor_out_fill_topdocs
Feb 27, 2017
Merged

Factor out filling of TopDocs in SearchPhaseController#23380
s1monw merged 2 commits intoelastic:masterfrom
s1monw:factor_out_fill_topdocs

Conversation

@s1monw
Copy link
Copy Markdown
Contributor

@s1monw s1monw commented Feb 27, 2017

Previously this code was duplicated across the 3 different topdocs variants
we have. It also had no real unittest (where we tested with holes in the results)
which caused a sneaky bug where the comparison used result.size() vs results.size()
causing several NPEs downstream. This change adds a static method to fill the top docs
that is shared across all variants and adds a unittest that would have caught the issue
very quickly.

Closes #19356
Closes #23357

Previously this code was duplicated across the 3 different topdocs variants
we have. It also had no real unittest (where we tested with holes in the results)
which caused a sneaky bug where the comparison used `result.size()` vs `results.size()`
causing several NPEs downstream. This change adds a static method to fill the top docs
that is shared across all variants and adds a unittest that would have caught the issue
very quickly.

Closes elastic#19356
Closes elastic#23357
@s1monw s1monw added :Search/Search Search-related issues that do not fall into other categories >bug review v5.4.0 v6.0.0-alpha1 labels Feb 27, 2017
@s1monw s1monw requested a review from jpountz February 27, 2017 09:45
Copy link
Copy Markdown
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

LGTM

Supplier<T> emptySupplier) {
if (results.size() != shardTopDocs.length) {
// TopDocs#merge can't deal with null shard TopDocs
final T empty = emptySupplier.get();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the supplier seems to be only useful to save one object allocation, maybe getting rid of it would make things simpler?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

true! I fixed it

Copy link
Copy Markdown
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

LGTM

@s1monw s1monw merged commit b8e2d12 into elastic:master Feb 27, 2017
@s1monw s1monw deleted the factor_out_fill_topdocs branch February 27, 2017 10:44
s1monw added a commit that referenced this pull request Feb 27, 2017
Previously this code was duplicated across the 3 different topdocs variants
we have. It also had no real unittest (where we tested with holes in the results)
which caused a sneaky bug where the comparison used `result.size()` vs `results.size()`
causing several NPEs downstream. This change adds a static method to fill the top docs
that is shared across all variants and adds a unittest that would have caught the issue
very quickly.

Closes #19356
Closes #23357
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 27, 2017
* master:
  [TEST]  make headers case-insensitive when running yaml tests
  [TEST] randomize request content_type between all of the supported formats
  [TEST] add support for binary responses to REST tests infra
  [TEST] don't check exact size in mapper-size yaml test
  [TEST] move test for binary field to specific test file that sets Content-Type header explicitly
  [TEST] move filters aggs wrapper query builder rewriting test to integ tests
  [TEST] create HttpEntity earlier in REST tests
  [TEST] Remove content type auto-detection while parsing request body in REST tests
  Factor out filling of TopDocs in SearchPhaseController (elastic#23380)
  Add info method to High Level Rest client (elastic#23350)
  Prevent negative `from` parameter in SearchSourceBuilder (elastic#23358)
  reduce the number of iterations in testPrimaryRelocationWhileIndexing and flush every 5
  rollback unneeded change in testNotifyOnDisconnect
  disable sampling in testNotifyOnDisconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Search/Search Search-related issues that do not fall into other categories v5.4.0 v6.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants