-
Notifications
You must be signed in to change notification settings - Fork 26k
MetricsInfoOperator refactoring #142935
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
Merged
leontyevdv
merged 6 commits into
elastic:main
from
leontyevdv:refactor/metrics-info-refactoring
Feb 24, 2026
Merged
MetricsInfoOperator refactoring #142935
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4ff9489
MetricsInfoOperator rafctoring
leontyevdv ba89a09
Update docs/changelog/142935.yaml
leontyevdv 1a4eef0
MetricsInfoOperator rafctoring
leontyevdv 026a85b
Merge branch 'main' into refactor/metrics-info-refactoring
leontyevdv 304e9d0
Delete docs/changelog/142935.yaml
leontyevdv 33ded39
Polish MetricsInfoOperator
leontyevdv 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| area: ES|QL | ||
| issues: [] | ||
| pr: 142935 | ||
| summary: '`MetricsInfoOperator` rafctoring' | ||
| type: enhancement |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -199,7 +199,7 @@ public enum Mode { | |
| /** | ||
| * Creates an INITIAL-mode operator (data nodes). | ||
| */ | ||
| public MetricsInfoOperator(BlockFactory blockFactory, MetricFieldLookup fieldLookup, int metadataSourceChannel, int indexChannel) { | ||
| private MetricsInfoOperator(BlockFactory blockFactory, MetricFieldLookup fieldLookup, int metadataSourceChannel, int indexChannel) { | ||
|
Member
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. You can even keep a single constructor as private, and pass the right combination of args in each factory.
Contributor
Author
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. That's even better. Polished. Thanks! |
||
| this.mode = Mode.INITIAL; | ||
| this.blockFactory = blockFactory; | ||
| this.breaker = blockFactory.breaker(); | ||
|
|
@@ -215,7 +215,7 @@ public MetricsInfoOperator(BlockFactory blockFactory, MetricFieldLookup fieldLoo | |
| * @param channels the 6 input channel indices mapping to | ||
| * [metric_name, data_stream, unit, metric_type, field_type, dimension_fields] | ||
| */ | ||
| public MetricsInfoOperator(BlockFactory blockFactory, int[] channels) { | ||
| private MetricsInfoOperator(BlockFactory blockFactory, int[] channels) { | ||
| this.mode = Mode.FINAL; | ||
| this.blockFactory = blockFactory; | ||
| this.breaker = blockFactory.breaker(); | ||
|
|
@@ -246,6 +246,7 @@ private void addInputInitial(Page page) { | |
| BytesRefBlock indexBlock = page.getBlock(indexChannel); | ||
|
|
||
| BytesRef indexScratch = new BytesRef(); | ||
| BytesRef sourceScratch = new BytesRef(); | ||
|
|
||
| for (int p = 0; p < page.getPositionCount(); p++) { | ||
| if (metadataSource.isNull(p)) { | ||
|
|
@@ -257,7 +258,7 @@ private void addInputInitial(Page page) { | |
|
|
||
| String indexName = indexBlock.getBytesRef(p, indexScratch).utf8ToString(); | ||
| String dataStreamName = resolveDataStreamName(indexName); | ||
| Map<String, Object> metadata = parseMetadataSource(metadataSource, p); | ||
| Map<String, Object> metadata = parseMetadataSource(metadataSource, p, sourceScratch); | ||
| if (metadata == null) { | ||
| continue; | ||
| } | ||
|
|
@@ -530,11 +531,11 @@ private static void appendMultiValued(BytesRefBlock.Builder builder, Set<String> | |
| } | ||
| } | ||
|
|
||
| private Map<String, Object> parseMetadataSource(BytesRefBlock metadataSource, int position) { | ||
| private Map<String, Object> parseMetadataSource(BytesRefBlock metadataSource, int position, BytesRef sourceScratch) { | ||
| if (metadataSource == null || metadataSource.isNull(position)) { | ||
| return null; | ||
| } | ||
| BytesRef bytes = metadataSource.getBytesRef(position, new BytesRef()); | ||
| BytesRef bytes = metadataSource.getBytesRef(position, sourceScratch); | ||
| try ( | ||
| var parser = XContentType.JSON.xContent() | ||
| .createParser(XContentParserConfiguration.EMPTY, bytes.bytes, bytes.offset, bytes.length) | ||
|
|
||
Oops, something went wrong.
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.
Given it doesn't change functionality, should we add
>non-issueThere 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, thanks! Added a tag