-
Notifications
You must be signed in to change notification settings - Fork 25.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
[TSDB] Add support for downsampling aggregate_metric_double
fields
#90029
Conversation
to the test index mapping
Change how we serialize metrics to doc
for computing metrics
Pinging @elastic/es-analytics-geo (Team:Analytics) |
...gin/rollup/src/main/java/org/elasticsearch/xpack/downsample/AbstractRollupFieldProducer.java
Outdated
Show resolved
Hide resolved
assert fieldType != null : "Unknown field type for field: [" + field + "]"; | ||
Map<String, FieldValueFetcher> fetchers = new HashMap<>(); | ||
|
||
if (fieldType instanceof AggregateDoubleMetricFieldMapper.AggregateDoubleMetricFieldType aggMetricFieldType) { |
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.
Is this one of the threads you'd pull on to fix the other instanceof
checks? If the field type built the fetcher - or if we had a Map<Class<FieldType>, FetcherFactory>
or something?
...rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
} else { | ||
if (context.fieldExistsInIndex(field)) { |
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.
Include only the fields that exist in the index, instead of all mapped field.
This should improve downsampling performance for cases such as ECS schema.
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/downsample/FieldValueFetcher.java
Show resolved
Hide resolved
...rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java
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.
java code looks fine to me. I'd love to plumb the instanceof
checks through another way, but that's fine for a follow up change. I wish you luck fighting your gradle demons.
} | ||
|
||
public TimeseriesFieldTypeHelper build(final String timestampField) throws IOException { | ||
final MapperService mapperService = indicesService.createIndexMapperServiceForValidation(indexMetadata); | ||
final CompressedXContent sourceIndexCompressedXContent = new CompressedXContent(indexMapping); | ||
mapperService.merge(MapperService.SINGLE_MAPPING_NAME, sourceIndexCompressedXContent, MapperService.MergeReason.INDEX_TEMPLATE); |
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.
Was this important?
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.
Ah. It moved.
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.
Yes, I moved it one level up so that I can reuse the MapperService
instance
rollup module extends mapper-aggregate-metric instead of importing it via `api`. This solves some Classloading issues
from rollup build.gradle file
@elasticmachine run elasticsearch-ci/docs |
Moved FieldValueFetcher in the mappers package so that it can be retrieved through the MappedFieldType and remove the instanceof clause
@nik9000 I have sorted out the classloading issue. I had to modify the rollup x-pack plugin so that it extends the Finally, I made an effort to move the With all those changes, I think the PR is ready for one more review. |
/** | ||
* Create a helper class to fetch value field data. | ||
*/ | ||
public FieldValueFetcher fieldValueFetcher(SearchExecutionContext 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 know that naming this fieldValueFetcher
looks confusing, especially when the method is right below a method named valueFetcher
, but I did not have any better idea (maybe fieldDataFetcher
, but again there's fieldDataBuilder
). I am open to suggestions
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 would prefer to keep this in the rollup module, but this works for now. I can put together a followup PR with some ideas once this is merged. Or I can try. And if I fail then, well, I'll know.
/** | ||
* Utility class used for fetching field values by reading field data | ||
*/ | ||
class FieldValueFetcher { |
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.
This class became an interface
and moved into server module in the org.elasticsearch.index.mapper
package.
The static methods were moved in the RollupShardIndexer
class
final Map<String, FormattedDocValues> docValuesFetchers = new LinkedHashMap<>(fieldValueFetchers.size()); | ||
for (FieldValueFetcher fetcher : fieldValueFetchers) { | ||
for (Map.Entry<String, FormattedDocValues> e : fetcher.getLeaves(ctx).entrySet()) { | ||
if (searchContext.fieldExistsInIndex(e.getKey())) { |
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 field does not exist in the index, it will be ignored even if it exists in the mapping. This should improve performance for use cases such as ECS
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.
I do think it's be nice to keep the fetchers in the rollup module and I think I know how. But let's get this in and I can make a PR and we can see if it's a reasonable way.
/** | ||
* Create a helper class to fetch value field data. | ||
*/ | ||
public FieldValueFetcher fieldValueFetcher(SearchExecutionContext 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 would prefer to keep this in the rollup module, but this works for now. I can put together a followup PR with some ideas once this is merged. Or I can try. And if I fail then, well, I'll know.
/** | ||
* Interface for retrieving field values by reading field data | ||
*/ | ||
public interface FieldValueFetcher { |
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 it's in server
it's nice to have a very good name. Its a FormattedDocValuesFetcher
or something. I dunno. Probably not worth changing it now. If I can't figure out a good way to move it back to the module then we should rename it.
This reverts commit 69664b0.
I reverted the last change. I moved the |
@elasticmachine run elasticsearch-ci/bwc |
@elasticmachine run elasticsearch-ci/part-1 |
This PR adds support for downsampling metric fields of type
aggregate_metric_double
, enabling the rollup-of-rollups functionality.