-
Notifications
You must be signed in to change notification settings - Fork 25.8k
ESQL: Added Sample operator NamedWritable to plugin #131541
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
ivancea
merged 5 commits into
elastic:main
from
ivancea:fix-sample-operator-serialization
Jul 21, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d550915
ESQL: Added Sample operator NamedWritable to plugin
ivancea 2bbea48
Update docs/changelog/131541.yaml
ivancea 508e0bc
Added SampleOperator Status serialization test, and changed its rows …
ivancea 5af1d5e
Added transport versions
ivancea b321464
Merge branch 'main' into fix-sample-operator-serialization
ivancea 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 @@ | ||
| pr: 131541 | ||
| summary: Added Sample operator `NamedWritable` to plugin | ||
| area: ES|QL | ||
| type: bug | ||
| issues: [] |
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
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
72 changes: 72 additions & 0 deletions
72
...l/compute/src/test/java/org/elasticsearch/compute/operator/SampleOperatorStatusTests.java
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,72 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.compute.operator; | ||
|
|
||
| import org.elasticsearch.common.Strings; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
| import org.elasticsearch.test.ESTestCase; | ||
|
|
||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| public class SampleOperatorStatusTests extends AbstractWireSerializingTestCase<SampleOperator.Status> { | ||
| public static SampleOperator.Status simple() { | ||
| return new SampleOperator.Status(500012, 200012, 123, 111, 222); | ||
| } | ||
|
|
||
| public static String simpleToJson() { | ||
| return """ | ||
| { | ||
| "collect_nanos" : 500012, | ||
| "collect_time" : "500micros", | ||
| "emit_nanos" : 200012, | ||
| "emit_time" : "200micros", | ||
| "pages_processed" : 123, | ||
| "rows_received" : 111, | ||
| "rows_emitted" : 222 | ||
| }"""; | ||
| } | ||
|
|
||
| public void testToXContent() { | ||
| assertThat(Strings.toString(simple(), true, true), equalTo(simpleToJson())); | ||
| } | ||
|
|
||
| @Override | ||
| protected Writeable.Reader<SampleOperator.Status> instanceReader() { | ||
| return SampleOperator.Status::new; | ||
| } | ||
|
|
||
| @Override | ||
| public SampleOperator.Status createTestInstance() { | ||
| return new SampleOperator.Status( | ||
| randomNonNegativeLong(), | ||
| randomNonNegativeLong(), | ||
| randomNonNegativeInt(), | ||
| randomNonNegativeLong(), | ||
| randomNonNegativeLong() | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| protected SampleOperator.Status mutateInstance(SampleOperator.Status instance) { | ||
| long collectNanos = instance.collectNanos(); | ||
| long emitNanos = instance.emitNanos(); | ||
| int pagesProcessed = instance.pagesProcessed(); | ||
| long rowsReceived = instance.rowsReceived(); | ||
| long rowsEmitted = instance.rowsEmitted(); | ||
| switch (between(0, 4)) { | ||
| case 0 -> collectNanos = randomValueOtherThan(collectNanos, ESTestCase::randomNonNegativeLong); | ||
| case 1 -> emitNanos = randomValueOtherThan(emitNanos, ESTestCase::randomNonNegativeLong); | ||
| case 2 -> pagesProcessed = randomValueOtherThan(pagesProcessed, ESTestCase::randomNonNegativeInt); | ||
| case 3 -> rowsReceived = randomValueOtherThan(rowsReceived, ESTestCase::randomNonNegativeLong); | ||
| case 4 -> rowsEmitted = randomValueOtherThan(rowsEmitted, ESTestCase::randomNonNegativeLong); | ||
| default -> throw new UnsupportedOperationException(); | ||
| } | ||
| return new SampleOperator.Status(collectNanos, emitNanos, pagesProcessed, rowsReceived, rowsEmitted); | ||
| } | ||
| } |
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
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.
RandomSamplingIteratoruses anintformaxDoc. So if more thanMAX_INTrows are process, something else breaks.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.
Not really an issue introduced by this PR though