[TSDB] Add support for downsampling aggregate_metric_double fields #90029
[TSDB] Add support for downsampling aggregate_metric_double fields #90029csoulios merged 29 commits intoelastic:mainfrom
aggregate_metric_double fields #90029Conversation
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.
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.
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
nik9000
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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
nik9000
left a comment
There was a problem hiding this comment.
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.
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.
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.