-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Implement fields fetch for runtime fields #61995
Merged
nik9000
merged 27 commits into
elastic:master
from
nik9000:runtime_fields_fetch_fields_take_two
Sep 15, 2020
+640
−341
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
17f46a6
Implement fields fetch for runtime fields
nik9000 9be09d7
Doc
nik9000 186a911
Merge branch 'master' into runtime_fields_fetch_fields_take_two
nik9000 9b4b344
Use clean nested context
nik9000 9565d7d
Date nanos!
nik9000 ef3b2a4
Update test now that we force the right resolution in the formatter
nik9000 af9da06
Delay building all fetchers
nik9000 56405f5
Fixup
nik9000 e494412
Map
nik9000 7099198
Merge branch 'master' into runtime_fields_fetch_fields_take_two
nik9000 6313a12
Pass lookup when building
nik9000 6a6584b
Cleanup
nik9000 4e5bd65
Close over lookup
nik9000 c668838
Remove oops
nik9000 103df6a
Something is up with dates
nik9000 c63a886
Revert "Map"
nik9000 d7315fe
Merge branch 'master' into runtime_fields_fetch_fields_take_two
nik9000 f92f8a5
Revert "Close over lookup"
nik9000 122663c
Fetch lookup
nik9000 77f130c
Rename k plz
nik9000 0fe6b3d
Merge branch 'master' into runtime_fields_fetch_fields_take_two
nik9000 3790f5e
Compile plz
nik9000 459808f
Merge branch 'master' into runtime_fields_fetch_fields_take_two
nik9000 2055c32
Compile
nik9000 d9e6209
Iter
nik9000 137ac90
oops
nik9000 d666f3f
Merge branch 'master' into runtime_fields_fetch_fields_take_two
nik9000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,10 @@ | |
|
||
import org.apache.lucene.util.Accountable; | ||
import org.elasticsearch.common.lease.Releasable; | ||
import org.elasticsearch.index.mapper.DocValueFetcher; | ||
import org.elasticsearch.search.DocValueFormat; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* The thread safe {@link org.apache.lucene.index.LeafReader} level cache of the data. | ||
|
@@ -37,4 +41,26 @@ public interface LeafFieldData extends Accountable, Releasable { | |
*/ | ||
SortedBinaryDocValues getBytesValues(); | ||
|
||
/** | ||
* Return a value fetcher for this leaf implementation. | ||
*/ | ||
default DocValueFetcher.Leaf getLeafValueFetcher(DocValueFormat format) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks much better, thank you! |
||
SortedBinaryDocValues values = getBytesValues(); | ||
return new DocValueFetcher.Leaf() { | ||
javanna marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@Override | ||
public boolean advanceExact(int docId) throws IOException { | ||
return values.advanceExact(docId); | ||
} | ||
|
||
@Override | ||
public int docValueCount() throws IOException { | ||
return values.docValueCount(); | ||
} | ||
|
||
@Override | ||
public Object nextValue() throws IOException { | ||
return format.format(values.nextValue()); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder if in all places where we carry around the search lookup, we should not rather make it a supplier like we did in fielddataBuilder.
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 we did the
Supplier
we could automaticallyforkAndTrackReferences
when you callget
on it which is kind of neat. I like it!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.
@jtibshirani what do you think? I was under the impression that the lookup is not used in many places, and maybe we could / should create it lazily. We do that already in fielddataBuilder, though it is some indirection that may make the code harder to read.
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.
Hmm - I don't think we can know from the signature how to fork....
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.
Wait wait wait, we don't need to forkAndTrackReferences because getting doc values does that for us. Ignore that. I think we're actually fine without the Supplier then. Because the only thing it'd let us do is lazily build the
SearchLookup
but that class isn't that heavy so I don't think it is worth it. And we need theSourceLookup
anyway because the fetch phase is pretty centralized around it.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.
Possibly dumb question - is it worth putting it into the SearchContext, rather than having it as an extra parameter here?
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.
It is all but a dumb question to me. In fact when I saw the new argument the first thing I did was checking that it was not already available in search context :)
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 don't want to add it to
SearchContext
because it'd have a huge blast radius. I think it'd be reasonable to make aFetchContext
which has both things. But I don't think it is worth it because there are only 2 arguments..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.
FetchContext
might be an interesting followup, but sure let's leave it for now.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 if we did
FetchContext
I'd want it to be smaller than theSearchContext
. That thing is just too big....