Skip to content

Simplify ignore_malformed handling for synthetic souce in aggregate_metric_double#109888

Merged
lkts merged 3 commits intoelastic:mainfrom
lkts:refactor_aggregate_metric_double_ignore_malformed
Jun 20, 2024
Merged

Simplify ignore_malformed handling for synthetic souce in aggregate_metric_double#109888
lkts merged 3 commits intoelastic:mainfrom
lkts:refactor_aggregate_metric_double_ignore_malformed

Conversation

@lkts
Copy link
Copy Markdown
Contributor

@lkts lkts commented Jun 18, 2024

This PR reworks the logic to follow the pattern from #109882. This also fixes the edge case of array of values some of which are malformed.

@lkts lkts added >non-issue :StorageEngine/Mapping The storage related side of mappings labels Jun 18, 2024
* Typical use case is to gather field values from doc_values and append malformed values
* stored in a different field in case of ignore_malformed being enabled.
*/
public class CompositeSyntheticFieldLoader implements SourceLoader.SyntheticFieldLoader {
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.

This is all from #109882.

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@lkts
Copy link
Copy Markdown
Contributor Author

lkts commented Jun 19, 2024

@elasticmachine update branch


if (malformedDataForSyntheticSource != null) {
context.doc().add(IgnoreMalformedStoredValues.storedField(name(), malformedDataForSyntheticSource));
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This blocks gets repeated, consider moving it to a helper in IgnoreMalformedStoredValues

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.

I'll leave it if you don't mind i don't think it's too bad of a repetition.

name(),
new AggregateMetricSyntheticFieldLoader(name(), simpleName(), metrics),
new CompositeSyntheticFieldLoader.MalformedValuesLayer(name())
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cute :)

if (metricHasValue.isEmpty()) {
return;
}
b.startObject(simpleName);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar question, why do we need this?

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.

See #109882.


- match:
_source:
metric: [{"min": 18.2,"max": 100.0, "value_count": 1}, "hey", 123, 456]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar comment about missing the [123, 456] pair.

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.

See #109882.

Copy link
Copy Markdown
Member

@kkrik-es kkrik-es left a comment

Choose a reason for hiding this comment

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

👍

@lkts lkts merged commit e41a10e into elastic:main Jun 20, 2024
@lkts lkts deleted the refactor_aggregate_metric_double_ignore_malformed branch June 20, 2024 18:07
@felixbarny felixbarny mentioned this pull request Aug 6, 2024
50 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants