-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Doc values sparse index on _tsid fields #122699
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
Doc values sparse index on _tsid fields #122699
Conversation
5412486 to
1b210b0
Compare
1b210b0 to
25749f4
Compare
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
| context.doc().add(new SortedDocValuesField(fieldType().name(), timeSeriesId)); | ||
|
|
||
| if (this.useDocValuesSkipper && this.indexCreatedVersion.onOrAfter(IndexVersions.TIME_SERIES_ID_DOC_VALUES_SPARSE_INDEX)) { | ||
| context.doc().add(SortedDocValuesField.indexedField(fieldType().name(), timeSeriesId)); |
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.
SortedDocValuesField#indexedField creates a new SortedDocValuesField using a private static FieldType that has the skip index enabled. It's the same as discussed for SortedNumericDocValuesField in #122161 (comment)
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.
Thanks @jordan-powers! I left two comments.
| public static final String NAME = "_tsid"; | ||
| public static final String CONTENT_TYPE = "_tsid"; | ||
| public static final TimeSeriesIdFieldType FIELD_TYPE = new TimeSeriesIdFieldType(); | ||
| public static final TimeSeriesIdFieldMapper INSTANCE = new TimeSeriesIdFieldMapper(); |
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 reason why this is a singleton constant is to reduce memory usage of MapperService. Meta field mappers that can be initialized as a constant are a constant. A node can have many MapperService instances (one per allocated index).
I think can just define two singleton instances here and then decide to use which in IndexMode#timeSeriesIdFieldMapper(...) based on index versions and whether the feature flag is enabled?
|
|
||
| private TimeSeriesIdFieldMapper() { | ||
| private final IndexVersion indexCreatedVersion; | ||
| private final boolean useDocValuesSkipper; |
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 we can avoid passing down index version here. We can set useDocValuesSkipper based on the following expressions: indexVersion.onOrAfter(IndexVersions.TIME_SERIES_ID_DOC_VALUES_SPARSE_INDEX) && context.getIndexSettings().useDocValuesSkipper()?
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.
LGTM
This PR exends the work done in #122161 and #121751 to also use the doc values sparse index for the _tsid fields in time-series mode indices.