From 5b69390e3598a8e9af415e821ea4b279d121404b Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Wed, 9 Oct 2024 09:17:49 -0700 Subject: [PATCH 01/43] Unmute SecureHdfsSearchableSnapshotsIT --- muted-tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index ef27eeeffc14..435d1b202b0e 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -307,8 +307,6 @@ tests: - class: org.elasticsearch.xpack.restart.MLModelDeploymentFullClusterRestartIT method: testDeploymentSurvivesRestart {cluster=UPGRADED} issue: https://github.com/elastic/elasticsearch/issues/112980 -- class: org.elasticsearch.xpack.searchablesnapshots.hdfs.SecureHdfsSearchableSnapshotsIT - issue: https://github.com/elastic/elasticsearch/issues/113753 - class: org.elasticsearch.ingest.geoip.DatabaseNodeServiceIT method: testNonGzippedDatabase issue: https://github.com/elastic/elasticsearch/issues/113821 From d29f7a112085040d037d76ada13dcce888caba03 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 03:34:38 +1100 Subject: [PATCH 02/43] Mute org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT test {p0=synonyms/60_synonym_rule_get/Synonym set not found} #114432 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 435d1b202b0e..51943d9a587c 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -375,6 +375,9 @@ tests: - class: org.elasticsearch.xpack.inference.services.cohere.CohereServiceTests method: testInfer_StreamRequest issue: https://github.com/elastic/elasticsearch/issues/114385 +- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT + method: test {p0=synonyms/60_synonym_rule_get/Synonym set not found} + issue: https://github.com/elastic/elasticsearch/issues/114432 # Examples: # From 0736bf505e2ef504c2e523bf4dc64bdeaf94a845 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Wed, 9 Oct 2024 19:28:36 +0200 Subject: [PATCH 03/43] Timeout on buildkite artifact upload but do not fail the build (#114430) this workarounds an issue we currently see on windows ci boxes where we run into timeouts in this step in our builds --- .../gradle/internal/ElasticsearchBuildCompletePlugin.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchBuildCompletePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchBuildCompletePlugin.java index ba2f56a9fecd..25ad5bcf8958 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchBuildCompletePlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchBuildCompletePlugin.java @@ -163,7 +163,13 @@ public abstract class ElasticsearchBuildCompletePlugin implements Plugin Date: Wed, 9 Oct 2024 13:56:00 -0400 Subject: [PATCH 04/43] Unmute many tests (#114431) These look to have been muted due to suite timeouts that we've since fixed. Let's try running these again. Closes #109687 Closes #112144 Closes #112624 Closes #113315 Closes #113316 Closes #113327 Closes #113340 --- muted-tests.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 51943d9a587c..47b1bf907d79 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -17,9 +17,6 @@ tests: - class: "org.elasticsearch.xpack.deprecation.DeprecationHttpIT" issue: "https://github.com/elastic/elasticsearch/issues/108628" method: "testDeprecatedSettingsReturnWarnings" -- class: "org.elasticsearch.xpack.test.rest.XPackRestIT" - issue: "https://github.com/elastic/elasticsearch/issues/109687" - method: "test {p0=sql/translate/Translate SQL}" - class: org.elasticsearch.index.store.FsDirectoryFactoryTests method: testStoreDirectory issue: https://github.com/elastic/elasticsearch/issues/110210 @@ -95,9 +92,6 @@ tests: - class: org.elasticsearch.xpack.ml.integration.MlJobIT method: testDeleteJobAfterMissingIndex issue: https://github.com/elastic/elasticsearch/issues/112088 -- class: org.elasticsearch.xpack.test.rest.XPackRestIT - method: test {p0=transform/preview_transforms/Test preview transform latest} - issue: https://github.com/elastic/elasticsearch/issues/112144 - class: org.elasticsearch.smoketest.SmokeTestMultiNodeClientYamlTestSuiteIT issue: https://github.com/elastic/elasticsearch/issues/112147 - class: org.elasticsearch.smoketest.WatcherYamlRestIT @@ -141,9 +135,6 @@ tests: - class: org.elasticsearch.search.basic.SearchWhileRelocatingIT method: testSearchAndRelocateConcurrentlyRandomReplicas issue: https://github.com/elastic/elasticsearch/issues/112515 -- class: org.elasticsearch.xpack.test.rest.XPackRestIT - method: test {p0=terms_enum/10_basic/Test search after on unconfigured constant keyword field} - issue: https://github.com/elastic/elasticsearch/issues/112624 - class: org.elasticsearch.xpack.esql.EsqlAsyncSecurityIT method: testIndexPatternErrorMessageComparison_ESQL_SearchDSL issue: https://github.com/elastic/elasticsearch/issues/112630 @@ -230,21 +221,9 @@ tests: - class: org.elasticsearch.packaging.test.WindowsServiceTests method: test81JavaOptsInJvmOptions issue: https://github.com/elastic/elasticsearch/issues/113313 -- class: org.elasticsearch.xpack.test.rest.XPackRestIT - method: test {p0=esql/50_index_patterns/disjoint_mappings} - issue: https://github.com/elastic/elasticsearch/issues/113315 -- class: org.elasticsearch.xpack.test.rest.XPackRestIT - method: test {p0=wildcard/10_wildcard_basic/Query_string wildcard query} - issue: https://github.com/elastic/elasticsearch/issues/113316 - class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT method: test {p0=mtermvectors/10_basic/Tests catching other exceptions per item} issue: https://github.com/elastic/elasticsearch/issues/113325 -- class: org.elasticsearch.xpack.test.rest.XPackRestIT - method: test {p0=transform/transforms_force_delete/Test force deleting a running transform} - issue: https://github.com/elastic/elasticsearch/issues/113327 -- class: org.elasticsearch.xpack.test.rest.XPackRestIT - method: test {p0=analytics/top_metrics/sort by scaled float field} - issue: https://github.com/elastic/elasticsearch/issues/113340 - class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT method: test {yaml=reference/ccr/apis/follow/post-resume-follow/line_84} issue: https://github.com/elastic/elasticsearch/issues/113343 From fa859c3d3f26ee0e582076b1614c2e9a84435ae5 Mon Sep 17 00:00:00 2001 From: Pat Whelan Date: Wed, 9 Oct 2024 14:15:23 -0400 Subject: [PATCH 05/43] [ML] Remove threading from tests (#113212) We are getting InterruptedExceptions ~1% of the time when running these tests, but we can remove the threading from this test and still verify the one-by-one behavior. Fix #112471 Co-authored-by: Elastic Machine --- muted-tests.yml | 3 - .../external/http/RequestBasedTaskRunner.java | 2 +- .../http/RequestBasedTaskRunnerTests.java | 174 ++++++------------ 3 files changed, 62 insertions(+), 117 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 47b1bf907d79..9dd522ab0e61 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -121,9 +121,6 @@ tests: - class: org.elasticsearch.xpack.esql.action.ManyShardsIT method: testConcurrentQueries issue: https://github.com/elastic/elasticsearch/issues/112424 -- class: org.elasticsearch.xpack.inference.external.http.RequestBasedTaskRunnerTests - method: testLoopOneAtATime - issue: https://github.com/elastic/elasticsearch/issues/112471 - class: org.elasticsearch.ingest.geoip.IngestGeoIpClientYamlTestSuiteIT issue: https://github.com/elastic/elasticsearch/issues/111497 - class: org.elasticsearch.smoketest.SmokeTestIngestWithAllDepsClientYamlTestSuiteIT diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunner.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunner.java index 85aac661e609..4aaf48213f99 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunner.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunner.java @@ -40,7 +40,7 @@ class RequestBasedTaskRunner { * Else, offload to a new thread so we do not block another threadpool's thread. */ public void requestNextRun() { - if (loopCount.getAndIncrement() == 0) { + if (isRunning.get() && loopCount.getAndIncrement() == 0) { var currentThreadPool = EsExecutors.executorName(Thread.currentThread().getName()); if (executorServiceName.equalsIgnoreCase(currentThreadPool)) { run(); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunnerTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunnerTests.java index d24bdbe444f5..7e93e68aae3e 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunnerTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/http/RequestBasedTaskRunnerTests.java @@ -7,21 +7,23 @@ package org.elasticsearch.xpack.inference.external.http; +import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; -import org.junit.After; import org.junit.Before; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.atomic.AtomicReference; import static org.elasticsearch.xpack.inference.InferencePlugin.UTILITY_THREAD_POOL_NAME; -import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool; import static org.hamcrest.Matchers.equalTo; -import static org.mockito.Mockito.spy; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; public class RequestBasedTaskRunnerTests extends ESTestCase { private ThreadPool threadPool; @@ -29,128 +31,74 @@ public class RequestBasedTaskRunnerTests extends ESTestCase { @Before public void setUp() throws Exception { super.setUp(); - threadPool = spy(createThreadPool(inferenceUtilityPool())); + threadPool = mock(); + when(threadPool.executor(UTILITY_THREAD_POOL_NAME)).thenReturn(EsExecutors.DIRECT_EXECUTOR_SERVICE); } - @After - public void tearDown() throws Exception { - terminate(threadPool); - super.tearDown(); + public void testRequestWhileLoopingWillRerunCommand() { + var expectedTimesRerun = randomInt(5); + AtomicInteger counter = new AtomicInteger(0); + + var requestNextRun = new AtomicReference(); + Runnable command = () -> { + if (counter.getAndIncrement() < expectedTimesRerun) { + requestNextRun.get().run(); + } + }; + var runner = new RequestBasedTaskRunner(command, threadPool, UTILITY_THREAD_POOL_NAME); + requestNextRun.set(runner::requestNextRun); + runner.requestNextRun(); + + verify(threadPool, times(1)).executor(eq(UTILITY_THREAD_POOL_NAME)); + verifyNoMoreInteractions(threadPool); + assertThat(counter.get(), equalTo(expectedTimesRerun + 1)); } - public void testLoopOneAtATime() throws Exception { - // count the number of times the runnable is called - var counter = new AtomicInteger(0); + public void testRequestWhileNotLoopingWillQueueCommand() { + AtomicInteger counter = new AtomicInteger(0); - // block the runnable and wait for the test thread to take an action - var lock = new ReentrantLock(); - var condition = lock.newCondition(); - Runnable block = () -> { - try { - try { - lock.lock(); - condition.await(); - } finally { - lock.unlock(); - } - } catch (InterruptedException e) { - fail(e, "did not unblock the thread in time, likely during threadpool terminate"); - } - }; - Runnable unblock = () -> { - try { - lock.lock(); - condition.signalAll(); - } finally { - lock.unlock(); - } - }; + var runner = new RequestBasedTaskRunner(counter::incrementAndGet, threadPool, UTILITY_THREAD_POOL_NAME); - var runner = new RequestBasedTaskRunner(() -> { - counter.incrementAndGet(); - block.run(); - }, threadPool, UTILITY_THREAD_POOL_NAME); + for (int i = 1; i < randomInt(10); i++) { + runner.requestNextRun(); + verify(threadPool, times(i)).executor(eq(UTILITY_THREAD_POOL_NAME)); + assertThat(counter.get(), equalTo(i)); + } + ; + } - // given we have not called requestNextRun, then no thread should have started + public void testCancelBeforeRunning() { + AtomicInteger counter = new AtomicInteger(0); + + var runner = new RequestBasedTaskRunner(counter::incrementAndGet, threadPool, UTILITY_THREAD_POOL_NAME); + runner.cancel(); + runner.requestNextRun(); + + verifyNoInteractions(threadPool); assertThat(counter.get(), equalTo(0)); - verify(threadPool, times(0)).executor(UTILITY_THREAD_POOL_NAME); + } + public void testCancelWhileRunning() { + var expectedTimesRerun = randomInt(5); + AtomicInteger counter = new AtomicInteger(0); + + var runnerRef = new AtomicReference(); + Runnable command = () -> { + if (counter.getAndIncrement() < expectedTimesRerun) { + runnerRef.get().requestNextRun(); + } + runnerRef.get().cancel(); + }; + var runner = new RequestBasedTaskRunner(command, threadPool, UTILITY_THREAD_POOL_NAME); + runnerRef.set(runner); runner.requestNextRun(); - // given that we have called requestNextRun, then 1 thread should run once - assertBusy(() -> { - verify(threadPool, times(1)).executor(UTILITY_THREAD_POOL_NAME); - assertThat(counter.get(), equalTo(1)); - }); - - // given that we have called requestNextRun while a thread was running, and the thread was blocked - runner.requestNextRun(); - // then 1 thread should run once - verify(threadPool, times(1)).executor(UTILITY_THREAD_POOL_NAME); + verify(threadPool, times(1)).executor(eq(UTILITY_THREAD_POOL_NAME)); + verifyNoMoreInteractions(threadPool); assertThat(counter.get(), equalTo(1)); - // given the thread is unblocked - unblock.run(); - // then 1 thread should run twice - verify(threadPool, times(1)).executor(UTILITY_THREAD_POOL_NAME); - assertBusy(() -> assertThat(counter.get(), equalTo(2))); - - // given the thread is unblocked again, but there were only two calls to requestNextRun - unblock.run(); - // then 1 thread should run twice - verify(threadPool, times(1)).executor(UTILITY_THREAD_POOL_NAME); - assertBusy(() -> assertThat(counter.get(), equalTo(2))); - - // given no thread is running, when we call requestNextRun runner.requestNextRun(); - // then a second thread should start for the third run - assertBusy(() -> { - verify(threadPool, times(2)).executor(UTILITY_THREAD_POOL_NAME); - assertThat(counter.get(), equalTo(3)); - }); - - // given the thread is unblocked, then it should exit and rejoin the threadpool - unblock.run(); - assertTrue("Test thread should unblock after all runs complete", terminate(threadPool)); - - // final check - we ran three times on two threads - verify(threadPool, times(2)).executor(UTILITY_THREAD_POOL_NAME); - assertThat(counter.get(), equalTo(3)); - } - - public void testCancel() throws Exception { - // count the number of times the runnable is called - var counter = new AtomicInteger(0); - var latch = new CountDownLatch(1); - var runner = new RequestBasedTaskRunner(() -> { - counter.incrementAndGet(); - try { - latch.await(); - } catch (InterruptedException e) { - fail(e, "did not unblock the thread in time, likely during threadpool terminate"); - } - }, threadPool, UTILITY_THREAD_POOL_NAME); - - // given that we have called requestNextRun, then 1 thread should run once - runner.requestNextRun(); - assertBusy(() -> { - verify(threadPool, times(1)).executor(UTILITY_THREAD_POOL_NAME); - assertThat(counter.get(), equalTo(1)); - }); - - // given that a thread is running, three more calls will be queued - runner.requestNextRun(); - runner.requestNextRun(); - runner.requestNextRun(); - - // when we cancel the thread, then the thread should immediately exit and rejoin - runner.cancel(); - latch.countDown(); - assertTrue("Test thread should unblock after all runs complete", terminate(threadPool)); - - // given that we called cancel, when we call requestNextRun then no thread should start - runner.requestNextRun(); - verify(threadPool, times(1)).executor(UTILITY_THREAD_POOL_NAME); + verifyNoMoreInteractions(threadPool); assertThat(counter.get(), equalTo(1)); } From 8aabc810a8f63639246af323e7122e903bd8aa05 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 05:51:31 +1100 Subject: [PATCH 06/43] Mute org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT test {p0=synonyms/60_synonym_rule_get/Get a synonym rule} #114443 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 9dd522ab0e61..84322a7e67cc 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -354,6 +354,9 @@ tests: - class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT method: test {p0=synonyms/60_synonym_rule_get/Synonym set not found} issue: https://github.com/elastic/elasticsearch/issues/114432 +- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT + method: test {p0=synonyms/60_synonym_rule_get/Get a synonym rule} + issue: https://github.com/elastic/elasticsearch/issues/114443 # Examples: # From b3448ed01d249792ca360203cca650f1f684bed0 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 05:51:43 +1100 Subject: [PATCH 07/43] Mute org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT test {p0=synonyms/60_synonym_rule_get/Synonym rule not found} #114444 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 84322a7e67cc..9e95c7cb9a62 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -357,6 +357,9 @@ tests: - class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT method: test {p0=synonyms/60_synonym_rule_get/Get a synonym rule} issue: https://github.com/elastic/elasticsearch/issues/114443 +- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT + method: test {p0=synonyms/60_synonym_rule_get/Synonym rule not found} + issue: https://github.com/elastic/elasticsearch/issues/114444 # Examples: # From e07c9357aee757064467f6772f168119c7de5110 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Wed, 9 Oct 2024 12:08:00 -0700 Subject: [PATCH 08/43] Bump default timeout for test suites on Windows to 60 minutes (#114428) Co-authored-by: Elastic Machine --- .../gradle/internal/ElasticsearchTestBasePlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java index 3fd59dc7a95f..7a831fbcc146 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java @@ -185,8 +185,8 @@ public abstract class ElasticsearchTestBasePlugin implements Plugin { }); if (OS.current().equals(OS.WINDOWS) && System.getProperty("tests.timeoutSuite") == null) { - // override the suite timeout to 30 mins for windows, because it has the most inefficient filesystem known to man - test.systemProperty("tests.timeoutSuite", "2400000!"); + // override the suite timeout to 60 mins for windows, because it has the most inefficient filesystem known to man + test.systemProperty("tests.timeoutSuite", "3600000!"); } /* From 27faf59db807bfd27c045b810d5efd5307cac291 Mon Sep 17 00:00:00 2001 From: Dan Rubinstein Date: Wed, 9 Oct 2024 15:20:41 -0400 Subject: [PATCH 09/43] Adding chunking settings to GoogleVertexAiService, AzureAiStudioService, and AlibabaCloudSearchService (#113981) * Adding chunking settings to GoogleVertexAiService, AzureAiStudioService, and AlibabaCloudSearchService * Update docs/changelog/113981.yaml * Updating AlibabaService chunkedInfer to handle sparse embedding task types --------- Co-authored-by: Elastic Machine --- docs/changelog/113981.yaml | 6 + .../AlibabaCloudSearchService.java | 57 ++- .../AlibabaCloudSearchEmbeddingsModel.java | 6 +- ...aCloudSearchEmbeddingsServiceSettings.java | 14 +- .../sparse/AlibabaCloudSearchSparseModel.java | 6 +- .../azureaistudio/AzureAiStudioService.java | 49 +- .../AzureAiStudioEmbeddingsModel.java | 9 +- .../googlevertexai/GoogleVertexAiService.java | 48 +- .../GoogleVertexAiEmbeddingsModel.java | 6 +- .../AlibabaCloudSearchServiceTests.java | 449 +++++++++++++++--- ...libabaCloudSearchEmbeddingsModelTests.java | 2 + .../AlibabaCloudSearchSparseModelTests.java | 2 + .../AzureAiStudioServiceTests.java | 329 ++++++++++++- .../AzureAiStudioEmbeddingsModelTests.java | 47 ++ .../GoogleVertexAiServiceTests.java | 413 ++++++++++++++++ .../GoogleVertexAiEmbeddingsModelTests.java | 2 +- 16 files changed, 1354 insertions(+), 91 deletions(-) create mode 100644 docs/changelog/113981.yaml diff --git a/docs/changelog/113981.yaml b/docs/changelog/113981.yaml new file mode 100644 index 000000000000..38f3a6f04ae4 --- /dev/null +++ b/docs/changelog/113981.yaml @@ -0,0 +1,6 @@ +pr: 113981 +summary: "Adding chunking settings to `GoogleVertexAiService,` `AzureAiStudioService,`\ + \ and `AlibabaCloudSearchService`" +area: Machine Learning +type: enhancement +issues: [] diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java index 0bd0eee1aa9a..674509b28388 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java @@ -15,6 +15,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.InferenceService; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; @@ -24,6 +25,8 @@ import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; +import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsBuilder; import org.elasticsearch.xpack.inference.chunking.EmbeddingRequestChunker; import org.elasticsearch.xpack.inference.external.action.alibabacloudsearch.AlibabaCloudSearchActionCreator; import org.elasticsearch.xpack.inference.external.http.sender.DocumentsOnlyInput; @@ -74,11 +77,19 @@ public class AlibabaCloudSearchService extends SenderService { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && List.of(TaskType.TEXT_EMBEDDING, TaskType.SPARSE_EMBEDDING).contains(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap( + removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS) + ); + } + AlibabaCloudSearchModel model = createModel( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), ConfigurationParseContext.REQUEST @@ -99,6 +110,7 @@ public class AlibabaCloudSearchService extends SenderService { TaskType taskType, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage ) { @@ -107,6 +119,7 @@ public class AlibabaCloudSearchService extends SenderService { taskType, serviceSettings, taskSettings, + chunkingSettings, secretSettings, failureMessage, ConfigurationParseContext.PERSISTENT @@ -118,6 +131,7 @@ public class AlibabaCloudSearchService extends SenderService { TaskType taskType, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context @@ -129,6 +143,7 @@ public class AlibabaCloudSearchService extends SenderService { NAME, serviceSettings, taskSettings, + chunkingSettings, secretSettings, context ); @@ -138,6 +153,7 @@ public class AlibabaCloudSearchService extends SenderService { NAME, serviceSettings, taskSettings, + chunkingSettings, secretSettings, context ); @@ -174,11 +190,17 @@ public class AlibabaCloudSearchService extends SenderService { Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && List.of(TaskType.TEXT_EMBEDDING, TaskType.SPARSE_EMBEDDING).contains(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS)); + } + return createModelWithoutLoggingDeprecations( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, secretSettingsMap, parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); @@ -189,11 +211,17 @@ public class AlibabaCloudSearchService extends SenderService { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && List.of(TaskType.TEXT_EMBEDDING, TaskType.SPARSE_EMBEDDING).contains(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS)); + } + return createModelWithoutLoggingDeprecations( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, null, parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); @@ -238,17 +266,36 @@ public class AlibabaCloudSearchService extends SenderService { AlibabaCloudSearchModel alibabaCloudSearchModel = (AlibabaCloudSearchModel) model; var actionCreator = new AlibabaCloudSearchActionCreator(getSender(), getServiceComponents()); - var batchedRequests = new EmbeddingRequestChunker( - inputs.getInputs(), - EMBEDDING_MAX_BATCH_SIZE, - EmbeddingRequestChunker.EmbeddingType.FLOAT - ).batchRequestsWithListeners(listener); + List batchedRequests; + if (ChunkingSettingsFeatureFlag.isEnabled()) { + batchedRequests = new EmbeddingRequestChunker( + inputs.getInputs(), + EMBEDDING_MAX_BATCH_SIZE, + getEmbeddingTypeFromTaskType(alibabaCloudSearchModel.getTaskType()), + alibabaCloudSearchModel.getConfigurations().getChunkingSettings() + ).batchRequestsWithListeners(listener); + } else { + batchedRequests = new EmbeddingRequestChunker( + inputs.getInputs(), + EMBEDDING_MAX_BATCH_SIZE, + getEmbeddingTypeFromTaskType(alibabaCloudSearchModel.getTaskType()) + ).batchRequestsWithListeners(listener); + } + for (var request : batchedRequests) { var action = alibabaCloudSearchModel.accept(actionCreator, taskSettings, inputType); action.execute(new DocumentsOnlyInput(request.batch().inputs()), timeout, request.listener()); } } + private EmbeddingRequestChunker.EmbeddingType getEmbeddingTypeFromTaskType(TaskType taskType) { + return switch (taskType) { + case TaskType.TEXT_EMBEDDING -> EmbeddingRequestChunker.EmbeddingType.FLOAT; + case TaskType.SPARSE_EMBEDDING -> EmbeddingRequestChunker.EmbeddingType.SPARSE; + default -> throw new IllegalArgumentException("Unsupported task type for chunking: " + taskType); + }; + } + /** * For text embedding models get the embedding size and * update the service settings. diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java index 87e5e59ae343..2654ee4d22ce 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -39,6 +40,7 @@ public class AlibabaCloudSearchEmbeddingsModel extends AlibabaCloudSearchModel { String service, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, @Nullable Map secrets, ConfigurationParseContext context ) { @@ -48,6 +50,7 @@ public class AlibabaCloudSearchEmbeddingsModel extends AlibabaCloudSearchModel { service, AlibabaCloudSearchEmbeddingsServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchEmbeddingsTaskSettings.fromMap(taskSettings), + chunkingSettings, DefaultSecretSettings.fromMap(secrets) ); } @@ -59,10 +62,11 @@ public class AlibabaCloudSearchEmbeddingsModel extends AlibabaCloudSearchModel { String service, AlibabaCloudSearchEmbeddingsServiceSettings serviceSettings, AlibabaCloudSearchEmbeddingsTaskSettings taskSettings, + ChunkingSettings chunkingSettings, @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, chunkingSettings), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsServiceSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsServiceSettings.java index 76dfd01f333d..8896e983d3e7 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsServiceSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsServiceSettings.java @@ -13,6 +13,7 @@ import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.core.Nullable; +import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ServiceSettings; import org.elasticsearch.inference.SimilarityMeasure; @@ -81,10 +82,21 @@ public class AlibabaCloudSearchEmbeddingsServiceSettings implements ServiceSetti return similarity; } - public Integer getDimensions() { + @Override + public Integer dimensions() { return dimensions; } + @Override + public SimilarityMeasure similarity() { + return similarity; + } + + @Override + public DenseVectorFieldMapper.ElementType elementType() { + return DenseVectorFieldMapper.ElementType.FLOAT; + } + public Integer getMaxInputTokens() { return maxInputTokens; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java index b551ba389136..0155d8fbc1f0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; @@ -39,6 +40,7 @@ public class AlibabaCloudSearchSparseModel extends AlibabaCloudSearchModel { String service, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, @Nullable Map secrets, ConfigurationParseContext context ) { @@ -48,6 +50,7 @@ public class AlibabaCloudSearchSparseModel extends AlibabaCloudSearchModel { service, AlibabaCloudSearchSparseServiceSettings.fromMap(serviceSettings, context), AlibabaCloudSearchSparseTaskSettings.fromMap(taskSettings), + chunkingSettings, DefaultSecretSettings.fromMap(secrets) ); } @@ -59,10 +62,11 @@ public class AlibabaCloudSearchSparseModel extends AlibabaCloudSearchModel { String service, AlibabaCloudSearchSparseServiceSettings serviceSettings, AlibabaCloudSearchSparseTaskSettings taskSettings, + ChunkingSettings chunkingSettings, @Nullable DefaultSecretSettings secretSettings ) { super( - new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(modelId, taskType, service, serviceSettings, taskSettings, chunkingSettings), new ModelSecrets(secretSettings), serviceSettings.getCommonSettings() ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java index 7981fb393a84..c1ca50d41268 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioService.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -24,6 +25,8 @@ import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; +import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsBuilder; import org.elasticsearch.xpack.inference.chunking.EmbeddingRequestChunker; import org.elasticsearch.xpack.inference.external.action.azureaistudio.AzureAiStudioActionCreator; import org.elasticsearch.xpack.inference.external.http.sender.DocumentsOnlyInput; @@ -90,11 +93,23 @@ public class AzureAiStudioService extends SenderService { ) { if (model instanceof AzureAiStudioModel baseAzureAiStudioModel) { var actionCreator = new AzureAiStudioActionCreator(getSender(), getServiceComponents()); - var batchedRequests = new EmbeddingRequestChunker( - inputs.getInputs(), - EMBEDDING_MAX_BATCH_SIZE, - EmbeddingRequestChunker.EmbeddingType.FLOAT - ).batchRequestsWithListeners(listener); + + List batchedRequests; + if (ChunkingSettingsFeatureFlag.isEnabled()) { + batchedRequests = new EmbeddingRequestChunker( + inputs.getInputs(), + EMBEDDING_MAX_BATCH_SIZE, + EmbeddingRequestChunker.EmbeddingType.FLOAT, + baseAzureAiStudioModel.getConfigurations().getChunkingSettings() + ).batchRequestsWithListeners(listener); + } else { + batchedRequests = new EmbeddingRequestChunker( + inputs.getInputs(), + EMBEDDING_MAX_BATCH_SIZE, + EmbeddingRequestChunker.EmbeddingType.FLOAT + ).batchRequestsWithListeners(listener); + } + for (var request : batchedRequests) { var action = baseAzureAiStudioModel.accept(actionCreator, taskSettings); action.execute(new DocumentsOnlyInput(request.batch().inputs()), timeout, request.listener()); @@ -115,11 +130,19 @@ public class AzureAiStudioService extends SenderService { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap( + removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS) + ); + } + AzureAiStudioModel model = createModel( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), ConfigurationParseContext.REQUEST @@ -146,11 +169,17 @@ public class AzureAiStudioService extends SenderService { Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS)); + } + return createModelFromPersistent( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, secretSettingsMap, parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); @@ -161,11 +190,17 @@ public class AzureAiStudioService extends SenderService { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS)); + } + return createModelFromPersistent( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, null, parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); @@ -186,6 +221,7 @@ public class AzureAiStudioService extends SenderService { TaskType taskType, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context @@ -198,6 +234,7 @@ public class AzureAiStudioService extends SenderService { NAME, serviceSettings, taskSettings, + chunkingSettings, secretSettings, context ); @@ -235,6 +272,7 @@ public class AzureAiStudioService extends SenderService { TaskType taskType, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, Map secretSettings, String failureMessage ) { @@ -243,6 +281,7 @@ public class AzureAiStudioService extends SenderService { taskType, serviceSettings, taskSettings, + chunkingSettings, secretSettings, failureMessage, ConfigurationParseContext.PERSISTENT diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java index a999b9f0312e..edbefe07cff0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModel.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.azureaistudio.embeddings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -44,9 +45,13 @@ public class AzureAiStudioEmbeddingsModel extends AzureAiStudioModel { String service, AzureAiStudioEmbeddingsServiceSettings serviceSettings, AzureAiStudioEmbeddingsTaskSettings taskSettings, + ChunkingSettings chunkingSettings, DefaultSecretSettings secrets ) { - super(new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), new ModelSecrets(secrets)); + super( + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings), + new ModelSecrets(secrets) + ); } public AzureAiStudioEmbeddingsModel( @@ -55,6 +60,7 @@ public class AzureAiStudioEmbeddingsModel extends AzureAiStudioModel { String service, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, @Nullable Map secrets, ConfigurationParseContext context ) { @@ -64,6 +70,7 @@ public class AzureAiStudioEmbeddingsModel extends AzureAiStudioModel { service, AzureAiStudioEmbeddingsServiceSettings.fromMap(serviceSettings, context), AzureAiStudioEmbeddingsTaskSettings.fromMap(taskSettings), + chunkingSettings, DefaultSecretSettings.fromMap(secrets) ); } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java index d9d885004856..ae9219ba3849 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java @@ -16,6 +16,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -23,6 +24,8 @@ import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; +import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsBuilder; import org.elasticsearch.xpack.inference.chunking.EmbeddingRequestChunker; import org.elasticsearch.xpack.inference.external.action.googlevertexai.GoogleVertexAiActionCreator; import org.elasticsearch.xpack.inference.external.http.sender.DocumentsOnlyInput; @@ -70,11 +73,19 @@ public class GoogleVertexAiService extends SenderService { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap( + removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS) + ); + } + GoogleVertexAiModel model = createModel( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, serviceSettingsMap, TaskType.unsupportedTaskTypeErrorMsg(taskType, NAME), ConfigurationParseContext.REQUEST @@ -101,11 +112,17 @@ public class GoogleVertexAiService extends SenderService { Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS)); + } + return createModelFromPersistent( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, secretSettingsMap, parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); @@ -116,11 +133,17 @@ public class GoogleVertexAiService extends SenderService { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + ChunkingSettings chunkingSettings = null; + if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { + chunkingSettings = ChunkingSettingsBuilder.fromMap(removeFromMapOrDefaultEmpty(config, ModelConfigurations.CHUNKING_SETTINGS)); + } + return createModelFromPersistent( inferenceEntityId, taskType, serviceSettingsMap, taskSettingsMap, + chunkingSettings, null, parsePersistedConfigErrorMsg(inferenceEntityId, NAME) ); @@ -179,11 +202,22 @@ public class GoogleVertexAiService extends SenderService { GoogleVertexAiModel googleVertexAiModel = (GoogleVertexAiModel) model; var actionCreator = new GoogleVertexAiActionCreator(getSender(), getServiceComponents()); - var batchedRequests = new EmbeddingRequestChunker( - inputs.getInputs(), - EMBEDDING_MAX_BATCH_SIZE, - EmbeddingRequestChunker.EmbeddingType.FLOAT - ).batchRequestsWithListeners(listener); + List batchedRequests; + if (ChunkingSettingsFeatureFlag.isEnabled()) { + batchedRequests = new EmbeddingRequestChunker( + inputs.getInputs(), + EMBEDDING_MAX_BATCH_SIZE, + EmbeddingRequestChunker.EmbeddingType.FLOAT, + googleVertexAiModel.getConfigurations().getChunkingSettings() + ).batchRequestsWithListeners(listener); + } else { + batchedRequests = new EmbeddingRequestChunker( + inputs.getInputs(), + EMBEDDING_MAX_BATCH_SIZE, + EmbeddingRequestChunker.EmbeddingType.FLOAT + ).batchRequestsWithListeners(listener); + } + for (var request : batchedRequests) { var action = googleVertexAiModel.accept(actionCreator, taskSettings); action.execute(new DocumentsOnlyInput(request.batch().inputs()), timeout, request.listener()); @@ -225,6 +259,7 @@ public class GoogleVertexAiService extends SenderService { TaskType taskType, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, Map secretSettings, String failureMessage ) { @@ -233,6 +268,7 @@ public class GoogleVertexAiService extends SenderService { taskType, serviceSettings, taskSettings, + chunkingSettings, secretSettings, failureMessage, ConfigurationParseContext.PERSISTENT @@ -244,6 +280,7 @@ public class GoogleVertexAiService extends SenderService { TaskType taskType, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, @Nullable Map secretSettings, String failureMessage, ConfigurationParseContext context @@ -255,6 +292,7 @@ public class GoogleVertexAiService extends SenderService { NAME, serviceSettings, taskSettings, + chunkingSettings, secretSettings, context ); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java index 99110045fc3d..3a5fae09b40e 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModel.java @@ -9,6 +9,7 @@ package org.elasticsearch.xpack.inference.services.googlevertexai.embeddings; import org.apache.http.client.utils.URIBuilder; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.ModelSecrets; import org.elasticsearch.inference.TaskType; @@ -35,6 +36,7 @@ public class GoogleVertexAiEmbeddingsModel extends GoogleVertexAiModel { String service, Map serviceSettings, Map taskSettings, + ChunkingSettings chunkingSettings, Map secrets, ConfigurationParseContext context ) { @@ -44,6 +46,7 @@ public class GoogleVertexAiEmbeddingsModel extends GoogleVertexAiModel { service, GoogleVertexAiEmbeddingsServiceSettings.fromMap(serviceSettings, context), GoogleVertexAiEmbeddingsTaskSettings.fromMap(taskSettings), + chunkingSettings, GoogleVertexAiSecretSettings.fromMap(secrets) ); } @@ -59,10 +62,11 @@ public class GoogleVertexAiEmbeddingsModel extends GoogleVertexAiModel { String service, GoogleVertexAiEmbeddingsServiceSettings serviceSettings, GoogleVertexAiEmbeddingsTaskSettings taskSettings, + ChunkingSettings chunkingSettings, @Nullable GoogleVertexAiSecretSettings secrets ) { super( - new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings), + new ModelConfigurations(inferenceEntityId, taskType, service, serviceSettings, taskSettings, chunkingSettings), new ModelSecrets(secrets), serviceSettings ); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java index e8c34eec9617..7cedc36ffa5f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceTests.java @@ -7,12 +7,14 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch; +import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -20,9 +22,12 @@ import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; import org.elasticsearch.xpack.core.inference.action.InferenceAction; +import org.elasticsearch.xpack.core.inference.results.InferenceChunkedSparseEmbeddingResults; import org.elasticsearch.xpack.core.inference.results.InferenceChunkedTextEmbeddingFloatResults; import org.elasticsearch.xpack.core.inference.results.InferenceTextEmbeddingFloatResults; +import org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests; import org.elasticsearch.xpack.inference.external.action.ExecutableAction; import org.elasticsearch.xpack.inference.external.action.alibabacloudsearch.AlibabaCloudSearchActionVisitor; import org.elasticsearch.xpack.inference.external.http.HttpClientManager; @@ -31,28 +36,34 @@ import org.elasticsearch.xpack.inference.external.http.sender.HttpRequestSenderT import org.elasticsearch.xpack.inference.external.http.sender.InferenceInputs; import org.elasticsearch.xpack.inference.external.request.alibabacloudsearch.AlibabaCloudSearchUtils; import org.elasticsearch.xpack.inference.logging.ThrottlerManager; +import org.elasticsearch.xpack.inference.results.SparseEmbeddingResultsTests; import org.elasticsearch.xpack.inference.services.ServiceFields; +import org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion.AlibabaCloudSearchCompletionModelTests; +import org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion.AlibabaCloudSearchCompletionServiceSettingsTests; +import org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion.AlibabaCloudSearchCompletionTaskSettingsTests; import org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings.AlibabaCloudSearchEmbeddingsModel; import org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings.AlibabaCloudSearchEmbeddingsModelTests; import org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings.AlibabaCloudSearchEmbeddingsServiceSettingsTests; import org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings.AlibabaCloudSearchEmbeddingsTaskSettingsTests; -import org.hamcrest.CoreMatchers; +import org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse.AlibabaCloudSearchSparseModel; import org.hamcrest.MatcherAssert; import org.junit.After; import org.junit.Before; import java.io.IOException; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import static org.elasticsearch.xpack.inference.Utils.getPersistedConfigMap; import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool; import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty; +import static org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests.createRandomChunkingSettingsMap; import static org.elasticsearch.xpack.inference.services.ServiceComponentsTests.createWithEmptySettings; import static org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettingsTests.getSecretSettingsMap; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.instanceOf; import static org.mockito.Mockito.mock; @@ -99,6 +110,233 @@ public class AlibabaCloudSearchServiceTests extends ESTestCase { } } + public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkingSettingsProvidedAndFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + ActionListener modelVerificationListener = ActionListener.wrap( + model -> fail("Expected exception, but got model: " + model), + exception -> { + assertThat(exception, instanceOf(ElasticsearchStatusException.class)); + assertThat(exception.getMessage(), containsString("Model configuration contains settings")); + } + ); + + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + getRequestConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ), + modelVerificationListener + ); + } + } + + public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + ActionListener modelVerificationListener = ActionListener.wrap(model -> { + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + }, e -> fail("Model parsing should have succeeded " + e.getMessage())); + + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + getRequestConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ), + modelVerificationListener + ); + } + } + + public void testParseRequestConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + ActionListener modelVerificationListener = ActionListener.wrap(model -> { + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + }, e -> fail("Model parsing should have succeeded " + e.getMessage())); + + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + getRequestConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + getSecretSettingsMap("secret") + ), + modelVerificationListener + ); + } + } + + public void testParsePersistedConfig_CreatesAnEmbeddingsModelWithoutChunkingSettingsWhenFeatureFlagDisabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + getPersistedConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + createRandomChunkingSettingsMap() + ).config() + ); + + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertNull(embeddingsModel.getConfigurations().getChunkingSettings()); + } + } + + public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + getPersistedConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + createRandomChunkingSettingsMap() + ).config() + ); + + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + + public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + var model = service.parsePersistedConfig( + "id", + TaskType.TEXT_EMBEDDING, + getPersistedConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null) + ).config() + ); + + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + + public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWithoutChunkingSettingsWhenFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + var persistedConfig = getPersistedConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + persistedConfig.secrets() + ); + + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertNull(embeddingsModel.getConfigurations().getChunkingSettings()); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + } + } + + public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + var persistedConfig = getPersistedConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + persistedConfig.secrets() + ); + + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + } + } + + public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = new AlibabaCloudSearchService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool))) { + var persistedConfig = getPersistedConfigMap( + AlibabaCloudSearchEmbeddingsServiceSettingsTests.getServiceSettingsMap("service_id", "host", "default"), + AlibabaCloudSearchEmbeddingsTaskSettingsTests.getTaskSettingsMap(null), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ); + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + persistedConfig.secrets() + ); + + assertThat(model, instanceOf(AlibabaCloudSearchEmbeddingsModel.class)); + var embeddingsModel = (AlibabaCloudSearchEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().modelId(), is("service_id")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getHost(), is("host")); + assertThat(embeddingsModel.getServiceSettings().getCommonSettings().getWorkspaceName(), is("default")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + } + } + public void testCheckModelConfig() throws IOException { var senderFactory = HttpRequestSenderTests.createSenderFactory(threadPool, clientManager); @@ -165,49 +403,71 @@ public class AlibabaCloudSearchServiceTests extends ESTestCase { } } - public void testChunkedInfer_Batches() throws IOException { + public void testChunkedInfer_TextEmbeddingBatches() throws IOException { + testChunkedInfer(TaskType.TEXT_EMBEDDING, null); + } + + public void testChunkedInfer_TextEmbeddingChunkingSettingsSetAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + testChunkedInfer(TaskType.TEXT_EMBEDDING, ChunkingSettingsTests.createRandomChunkingSettings()); + } + + public void testChunkedInfer_TextEmbeddingChunkingSettingsNotSetAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + testChunkedInfer(TaskType.TEXT_EMBEDDING, null); + } + + public void testChunkedInfer_SparseEmbeddingBatches() throws IOException { + testChunkedInfer(TaskType.SPARSE_EMBEDDING, null); + } + + public void testChunkedInfer_SparseEmbeddingChunkingSettingsSetAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + testChunkedInfer(TaskType.SPARSE_EMBEDDING, ChunkingSettingsTests.createRandomChunkingSettings()); + } + + public void testChunkedInfer_SparseEmbeddingChunkingSettingsNotSetAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + testChunkedInfer(TaskType.SPARSE_EMBEDDING, null); + } + + public void testChunkedInfer_InvalidTaskType() throws IOException { + var senderFactory = HttpRequestSenderTests.createSenderFactory(threadPool, clientManager); + + try (var service = new AlibabaCloudSearchService(senderFactory, createWithEmptySettings(threadPool))) { + var model = AlibabaCloudSearchCompletionModelTests.createModel( + randomAlphaOfLength(10), + TaskType.COMPLETION, + AlibabaCloudSearchCompletionServiceSettingsTests.createRandom(), + AlibabaCloudSearchCompletionTaskSettingsTests.createRandom(), + null + ); + + PlainActionFuture> listener = new PlainActionFuture<>(); + try { + service.chunkedInfer( + model, + null, + List.of("foo", "bar"), + new HashMap<>(), + InputType.INGEST, + new ChunkingOptions(null, null), + InferenceAction.Request.DEFAULT_TIMEOUT, + listener + ); + } catch (Exception e) { + assertThat(e, instanceOf(IllegalArgumentException.class)); + } + } + } + + private void testChunkedInfer(TaskType taskType, ChunkingSettings chunkingSettings) throws IOException { var input = List.of("foo", "bar"); var senderFactory = HttpRequestSenderTests.createSenderFactory(threadPool, clientManager); try (var service = new AlibabaCloudSearchService(senderFactory, createWithEmptySettings(threadPool))) { - Map serviceSettingsMap = new HashMap<>(); - serviceSettingsMap.put(AlibabaCloudSearchServiceSettings.SERVICE_ID, "service_id"); - serviceSettingsMap.put(AlibabaCloudSearchServiceSettings.HOST, "host"); - serviceSettingsMap.put(AlibabaCloudSearchServiceSettings.WORKSPACE_NAME, "default"); - serviceSettingsMap.put(ServiceFields.DIMENSIONS, 1536); - - Map taskSettingsMap = new HashMap<>(); - - Map secretSettingsMap = new HashMap<>(); - secretSettingsMap.put("api_key", "secret"); - - var model = new AlibabaCloudSearchEmbeddingsModel( - "service", - TaskType.TEXT_EMBEDDING, - AlibabaCloudSearchUtils.SERVICE_NAME, - serviceSettingsMap, - taskSettingsMap, - secretSettingsMap, - null - ) { - public ExecutableAction accept( - AlibabaCloudSearchActionVisitor visitor, - Map taskSettings, - InputType inputType - ) { - return (inferenceInputs, timeout, listener) -> { - InferenceTextEmbeddingFloatResults results = new InferenceTextEmbeddingFloatResults( - List.of( - new InferenceTextEmbeddingFloatResults.InferenceFloatEmbedding(new float[] { 0.0123f, -0.0123f }), - new InferenceTextEmbeddingFloatResults.InferenceFloatEmbedding(new float[] { 0.0456f, -0.0456f }) - ) - ); - - listener.onResponse(results); - }; - } - }; + var model = createModelForTaskType(taskType, chunkingSettings); PlainActionFuture> listener = new PlainActionFuture<>(); service.chunkedInfer( @@ -222,28 +482,103 @@ public class AlibabaCloudSearchServiceTests extends ESTestCase { ); var results = listener.actionGet(TIMEOUT); + assertThat(results, instanceOf(List.class)); assertThat(results, hasSize(2)); - - // first result - { - assertThat(results.get(0), CoreMatchers.instanceOf(InferenceChunkedTextEmbeddingFloatResults.class)); - var floatResult = (InferenceChunkedTextEmbeddingFloatResults) results.get(0); - assertThat(floatResult.chunks(), hasSize(1)); - assertEquals(input.get(0), floatResult.chunks().get(0).matchedText()); - assertTrue(Arrays.equals(new float[] { 0.0123f, -0.0123f }, floatResult.chunks().get(0).embedding())); - } - - // second result - { - assertThat(results.get(1), CoreMatchers.instanceOf(InferenceChunkedTextEmbeddingFloatResults.class)); - var floatResult = (InferenceChunkedTextEmbeddingFloatResults) results.get(1); - assertThat(floatResult.chunks(), hasSize(1)); - assertEquals(input.get(1), floatResult.chunks().get(0).matchedText()); - assertTrue(Arrays.equals(new float[] { 0.0456f, -0.0456f }, floatResult.chunks().get(0).embedding())); + var firstResult = results.get(0); + if (TaskType.TEXT_EMBEDDING.equals(taskType)) { + assertThat(firstResult, instanceOf(InferenceChunkedTextEmbeddingFloatResults.class)); + } else if (TaskType.SPARSE_EMBEDDING.equals(taskType)) { + assertThat(firstResult, instanceOf(InferenceChunkedSparseEmbeddingResults.class)); } } } + private AlibabaCloudSearchModel createModelForTaskType(TaskType taskType, ChunkingSettings chunkingSettings) { + Map serviceSettingsMap = new HashMap<>(); + serviceSettingsMap.put(AlibabaCloudSearchServiceSettings.SERVICE_ID, "service_id"); + serviceSettingsMap.put(AlibabaCloudSearchServiceSettings.HOST, "host"); + serviceSettingsMap.put(AlibabaCloudSearchServiceSettings.WORKSPACE_NAME, "default"); + serviceSettingsMap.put(ServiceFields.DIMENSIONS, 1536); + + Map taskSettingsMap = new HashMap<>(); + + Map secretSettingsMap = new HashMap<>(); + + secretSettingsMap.put("api_key", "secret"); + return switch (taskType) { + case TEXT_EMBEDDING -> createEmbeddingsModel(serviceSettingsMap, taskSettingsMap, chunkingSettings, secretSettingsMap); + case SPARSE_EMBEDDING -> createSparseEmbeddingsModel(serviceSettingsMap, taskSettingsMap, chunkingSettings, secretSettingsMap); + default -> throw new IllegalArgumentException("Unsupported task type for chunking: " + taskType); + }; + } + + private AlibabaCloudSearchModel createEmbeddingsModel( + Map serviceSettingsMap, + Map taskSettingsMap, + ChunkingSettings chunkingSettings, + Map secretSettingsMap + ) { + return new AlibabaCloudSearchEmbeddingsModel( + "service", + TaskType.TEXT_EMBEDDING, + AlibabaCloudSearchUtils.SERVICE_NAME, + serviceSettingsMap, + taskSettingsMap, + chunkingSettings, + secretSettingsMap, + null + ) { + public ExecutableAction accept(AlibabaCloudSearchActionVisitor visitor, Map taskSettings, InputType inputType) { + return (inferenceInputs, timeout, listener) -> { + InferenceTextEmbeddingFloatResults results = new InferenceTextEmbeddingFloatResults( + List.of( + new InferenceTextEmbeddingFloatResults.InferenceFloatEmbedding(new float[] { 0.0123f, -0.0123f }), + new InferenceTextEmbeddingFloatResults.InferenceFloatEmbedding(new float[] { 0.0456f, -0.0456f }) + ) + ); + + listener.onResponse(results); + }; + } + }; + } + + private AlibabaCloudSearchModel createSparseEmbeddingsModel( + Map serviceSettingsMap, + Map taskSettingsMap, + ChunkingSettings chunkingSettings, + Map secretSettingsMap + ) { + return new AlibabaCloudSearchSparseModel( + "service", + TaskType.SPARSE_EMBEDDING, + AlibabaCloudSearchUtils.SERVICE_NAME, + serviceSettingsMap, + taskSettingsMap, + chunkingSettings, + secretSettingsMap, + null + ) { + public ExecutableAction accept(AlibabaCloudSearchActionVisitor visitor, Map taskSettings, InputType inputType) { + return (inferenceInputs, timeout, listener) -> { + listener.onResponse(SparseEmbeddingResultsTests.createRandomResults(2, 1)); + }; + } + }; + } + + public Map getRequestConfigMap( + Map serviceSettings, + Map taskSettings, + Map chunkingSettings, + Map secretSettings + ) { + var requestConfigMap = getRequestConfigMap(serviceSettings, taskSettings, secretSettings); + requestConfigMap.put(ModelConfigurations.CHUNKING_SETTINGS, chunkingSettings); + + return requestConfigMap; + } + private Map getRequestConfigMap( Map serviceSettings, Map taskSettings, diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java index fca0ee11e5c7..957b7149b14f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsModelTests.java @@ -47,6 +47,7 @@ public class AlibabaCloudSearchEmbeddingsModelTests extends ESTestCase { AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, + null, secrets, null ); @@ -65,6 +66,7 @@ public class AlibabaCloudSearchEmbeddingsModelTests extends ESTestCase { AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, + null, secretSettings ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java index 4e9179b66c36..4a89e1fc924a 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseModelTests.java @@ -47,6 +47,7 @@ public class AlibabaCloudSearchSparseModelTests extends ESTestCase { AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, + null, secrets, null ); @@ -65,6 +66,7 @@ public class AlibabaCloudSearchSparseModelTests extends ESTestCase { AlibabaCloudSearchUtils.SERVICE_NAME, serviceSettings, taskSettings, + null, secretSettings ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java index 9c3afc68306b..6c7287120e6c 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/AzureAiStudioServiceTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; import org.elasticsearch.inference.ChunkedInferenceServiceResults; import org.elasticsearch.inference.ChunkingOptions; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; @@ -29,6 +30,7 @@ import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xcontent.XContentType; +import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; import org.elasticsearch.xpack.core.inference.action.InferenceAction; import org.elasticsearch.xpack.core.inference.results.ChatCompletionResults; import org.elasticsearch.xpack.core.inference.results.InferenceChunkedTextEmbeddingFloatResults; @@ -62,6 +64,8 @@ import static org.elasticsearch.xpack.inference.Utils.getInvalidModel; import static org.elasticsearch.xpack.inference.Utils.getPersistedConfigMap; import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool; import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty; +import static org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests.createRandomChunkingSettings; +import static org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests.createRandomChunkingSettingsMap; import static org.elasticsearch.xpack.inference.external.http.Utils.entityAsMap; import static org.elasticsearch.xpack.inference.external.http.Utils.getUrl; import static org.elasticsearch.xpack.inference.external.request.azureaistudio.AzureAiStudioRequestFields.API_KEY_HEADER; @@ -124,6 +128,90 @@ public class AzureAiStudioServiceTests extends ESTestCase { } } + public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkingSettingsProvidedAndFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + try (var service = createService()) { + var serviceSettings = getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", null, null, null, null); + + var config = getRequestConfigMap( + serviceSettings, + getEmbeddingsTaskSettingsMap("user"), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ); + + ActionListener modelVerificationListener = ActionListener.wrap( + model -> fail("Expected exception, but got model: " + model), + exception -> { + assertThat(exception, instanceOf(ElasticsearchStatusException.class)); + assertThat(exception.getMessage(), containsString("Model configuration contains settings")); + } + ); + + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, modelVerificationListener); + } + } + + public void testParseRequestConfig_CreatesAnAzureAiStudioEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = createService()) { + ActionListener modelVerificationListener = ActionListener.wrap(model -> { + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + }, exception -> fail("Unexpected exception: " + exception)); + + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + getRequestConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", null, null, null, null), + getEmbeddingsTaskSettingsMap("user"), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ), + modelVerificationListener + ); + } + } + + public void testParseRequestConfig_CreatesAnAzureAiStudioEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = createService()) { + ActionListener modelVerificationListener = ActionListener.wrap(model -> { + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + }, exception -> fail("Unexpected exception: " + exception)); + + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + getRequestConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", null, null, null, null), + getEmbeddingsTaskSettingsMap("user"), + getSecretSettingsMap("secret") + ), + modelVerificationListener + ); + } + } + public void testParseRequestConfig_CreatesAnAzureAiStudioChatCompletionModel() throws IOException { try (var service = createService()) { ActionListener modelVerificationListener = ActionListener.wrap(model -> { @@ -461,6 +549,89 @@ public class AzureAiStudioServiceTests extends ESTestCase { } } + public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWithoutChunkingSettingsWhenFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + try (var service = createService()) { + var config = getPersistedConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", 1024, true, 512, null), + getEmbeddingsTaskSettingsMap("user"), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ); + + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getServiceSettings().dimensions(), is(1024)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(true)); + assertThat(embeddingsModel.getServiceSettings().maxInputTokens(), is(512)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertNull(embeddingsModel.getConfigurations().getChunkingSettings()); + } + } + + public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = createService()) { + var config = getPersistedConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", 1024, true, 512, null), + getEmbeddingsTaskSettingsMap("user"), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("secret") + ); + + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getServiceSettings().dimensions(), is(1024)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(true)); + assertThat(embeddingsModel.getServiceSettings().maxInputTokens(), is(512)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + + public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = createService()) { + var config = getPersistedConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", 1024, true, 512, null), + getEmbeddingsTaskSettingsMap("user"), + getSecretSettingsMap("secret") + ); + + var model = service.parsePersistedConfigWithSecrets("id", TaskType.TEXT_EMBEDDING, config.config(), config.secrets()); + + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getServiceSettings().dimensions(), is(1024)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(true)); + assertThat(embeddingsModel.getServiceSettings().maxInputTokens(), is(512)); + assertThat(embeddingsModel.getSecretSettings().apiKey().toString(), is("secret")); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + public void testParsePersistedConfig_CreatesAnAzureAiStudioChatCompletionModel() throws IOException { try (var service = createService()) { var config = getPersistedConfigMap( @@ -651,6 +822,84 @@ public class AzureAiStudioServiceTests extends ESTestCase { } } + public void testParsePersistedConfig_WithoutSecretsCreatesAnEmbeddingsModelWithoutChunkingSettingsFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + try (var service = createService()) { + var config = getPersistedConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", 1024, true, 512, null), + getEmbeddingsTaskSettingsMap("user"), + createRandomChunkingSettingsMap(), + Map.of() + ); + + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getServiceSettings().dimensions(), is(1024)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(true)); + assertThat(embeddingsModel.getServiceSettings().maxInputTokens(), is(512)); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertNull(embeddingsModel.getConfigurations().getChunkingSettings()); + } + } + + public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = createService()) { + var config = getPersistedConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", 1024, true, 512, null), + getEmbeddingsTaskSettingsMap("user"), + createRandomChunkingSettingsMap(), + Map.of() + ); + + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getServiceSettings().dimensions(), is(1024)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(true)); + assertThat(embeddingsModel.getServiceSettings().maxInputTokens(), is(512)); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + + public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + try (var service = createService()) { + var config = getPersistedConfigMap( + getEmbeddingsServiceSettingsMap("http://target.local", "openai", "token", 1024, true, 512, null), + getEmbeddingsTaskSettingsMap("user"), + Map.of() + ); + + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, config.config()); + + assertThat(model, instanceOf(AzureAiStudioEmbeddingsModel.class)); + + var embeddingsModel = (AzureAiStudioEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().target(), is("http://target.local")); + assertThat(embeddingsModel.getServiceSettings().provider(), is(AzureAiStudioProvider.OPENAI)); + assertThat(embeddingsModel.getServiceSettings().endpointType(), is(AzureAiStudioEndpointType.TOKEN)); + assertThat(embeddingsModel.getServiceSettings().dimensions(), is(1024)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(true)); + assertThat(embeddingsModel.getServiceSettings().maxInputTokens(), is(512)); + assertThat(embeddingsModel.getTaskSettings().user(), is("user")); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + public void testParsePersistedConfig_WithoutSecretsCreatesChatCompletionModel() throws IOException { try (var service = createService()) { var config = getPersistedConfigMap( @@ -843,6 +1092,61 @@ public class AzureAiStudioServiceTests extends ESTestCase { } public void testChunkedInfer() throws IOException { + var model = AzureAiStudioEmbeddingsModelTests.createModel( + "id", + getUrl(webServer), + AzureAiStudioProvider.OPENAI, + AzureAiStudioEndpointType.TOKEN, + "apikey", + null, + false, + null, + null, + "user", + null + ); + testChunkedInfer(model); + } + + public void testChunkedInfer_ChunkingSettingsSetAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var model = AzureAiStudioEmbeddingsModelTests.createModel( + "id", + getUrl(webServer), + AzureAiStudioProvider.OPENAI, + AzureAiStudioEndpointType.TOKEN, + createRandomChunkingSettings(), + "apikey", + null, + false, + null, + null, + "user", + null + ); + testChunkedInfer(model); + } + + public void testChunkedInfer_ChunkingSettingsNotSetAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var model = AzureAiStudioEmbeddingsModelTests.createModel( + "id", + getUrl(webServer), + AzureAiStudioProvider.OPENAI, + AzureAiStudioEndpointType.TOKEN, + null, + "apikey", + null, + false, + null, + null, + "user", + null + ); + testChunkedInfer(model); + } + + private void testChunkedInfer(AzureAiStudioEmbeddingsModel model) throws IOException { var senderFactory = HttpRequestSenderTests.createSenderFactory(threadPool, clientManager); try (var service = new AzureAiStudioService(senderFactory, createWithEmptySettings(threadPool))) { @@ -877,19 +1181,6 @@ public class AzureAiStudioServiceTests extends ESTestCase { """; webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); - var model = AzureAiStudioEmbeddingsModelTests.createModel( - "id", - getUrl(webServer), - AzureAiStudioProvider.OPENAI, - AzureAiStudioEndpointType.TOKEN, - "apikey", - null, - false, - null, - null, - "user", - null - ); PlainActionFuture> listener = new PlainActionFuture<>(); service.chunkedInfer( model, @@ -1021,6 +1312,18 @@ public class AzureAiStudioServiceTests extends ESTestCase { return new AzureAiStudioService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool)); } + private Map getRequestConfigMap( + Map serviceSettings, + Map taskSettings, + Map chunkingSettings, + Map secretSettings + ) { + var requestConfigMap = getRequestConfigMap(serviceSettings, taskSettings, secretSettings); + requestConfigMap.put(ModelConfigurations.CHUNKING_SETTINGS, chunkingSettings); + + return requestConfigMap; + } + private Map getRequestConfigMap( Map serviceSettings, Map taskSettings, diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java index 5a450f03b4e0..c9b0f905abaa 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsModelTests.java @@ -9,6 +9,7 @@ package org.elasticsearch.xpack.inference.services.azureaistudio.embeddings; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.core.Nullable; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.SimilarityMeasure; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; @@ -109,6 +110,18 @@ public class AzureAiStudioEmbeddingsModelTests extends ESTestCase { String target, AzureAiStudioProvider provider, AzureAiStudioEndpointType endpointType, + ChunkingSettings chunkingSettings, + String apiKey + ) { + return createModel(inferenceId, target, provider, endpointType, chunkingSettings, apiKey, null, false, null, null, null, null); + } + + public static AzureAiStudioEmbeddingsModel createModel( + String inferenceId, + String target, + AzureAiStudioProvider provider, + AzureAiStudioEndpointType endpointType, + ChunkingSettings chunkingSettings, String apiKey, @Nullable Integer dimensions, boolean dimensionsSetByUser, @@ -132,6 +145,40 @@ public class AzureAiStudioEmbeddingsModelTests extends ESTestCase { rateLimitSettings ), new AzureAiStudioEmbeddingsTaskSettings(user), + chunkingSettings, + new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) + ); + } + + public static AzureAiStudioEmbeddingsModel createModel( + String inferenceId, + String target, + AzureAiStudioProvider provider, + AzureAiStudioEndpointType endpointType, + String apiKey, + @Nullable Integer dimensions, + boolean dimensionsSetByUser, + @Nullable Integer maxTokens, + @Nullable SimilarityMeasure similarity, + @Nullable String user, + RateLimitSettings rateLimitSettings + ) { + return new AzureAiStudioEmbeddingsModel( + inferenceId, + TaskType.TEXT_EMBEDDING, + "azureaistudio", + new AzureAiStudioEmbeddingsServiceSettings( + target, + provider, + endpointType, + dimensions, + dimensionsSetByUser, + maxTokens, + similarity, + rateLimitSettings + ), + new AzureAiStudioEmbeddingsTaskSettings(user), + null, new DefaultSecretSettings(new SecureString(apiKey.toCharArray())) ); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java index 6a96d289a819..70ec6522c0fc 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiServiceTests.java @@ -10,12 +10,14 @@ package org.elasticsearch.xpack.inference.services.googlevertexai; import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.inference.ChunkingSettings; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.ModelConfigurations; import org.elasticsearch.inference.TaskType; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockWebServer; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xpack.core.inference.ChunkingSettingsFeatureFlag; import org.elasticsearch.xpack.inference.external.http.HttpClientManager; import org.elasticsearch.xpack.inference.external.http.sender.HttpRequestSender; import org.elasticsearch.xpack.inference.logging.ThrottlerManager; @@ -37,7 +39,9 @@ import java.util.Map; import static org.elasticsearch.xpack.inference.Utils.getPersistedConfigMap; import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool; import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty; +import static org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests.createRandomChunkingSettingsMap; import static org.elasticsearch.xpack.inference.services.ServiceComponentsTests.createWithEmptySettings; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.mock; @@ -107,6 +111,130 @@ public class GoogleVertexAiServiceTests extends ESTestCase { } } + public void testParseRequestConfig_ThrowsElasticsearchStatusExceptionWhenChunkingSettingsProvidedAndFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + try (var service = createGoogleVertexAiService()) { + var config = getRequestConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + "model", + GoogleVertexAiServiceFields.LOCATION, + "location", + GoogleVertexAiServiceFields.PROJECT_ID, + "project" + ) + ), + getTaskSettingsMap(true), + createRandomChunkingSettingsMap(), + getSecretSettingsMap("{}") + ); + + var failureListener = ActionListener.wrap(model -> fail("Expected exception, but got model: " + model), exception -> { + assertThat(exception, instanceOf(ElasticsearchStatusException.class)); + assertThat(exception.getMessage(), containsString("Model configuration contains settings")); + }); + + service.parseRequestConfig("id", TaskType.TEXT_EMBEDDING, config, failureListener); + } + } + + public void testParseRequestConfig_CreatesAGoogleVertexAiEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var serviceAccountJson = """ + { + "some json" + } + """; + + try (var service = createGoogleVertexAiService()) { + ActionListener modelListener = ActionListener.wrap(model -> { + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().serviceAccountJson().toString(), is(serviceAccountJson)); + }, e -> fail("Model parsing should succeeded, but failed: " + e.getMessage())); + + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + getRequestConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId + ) + ), + new HashMap<>(Map.of()), + createRandomChunkingSettingsMap(), + getSecretSettingsMap(serviceAccountJson) + ), + modelListener + ); + } + } + + public void testParseRequestConfig_CreatesAGoogleVertexAiEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var serviceAccountJson = """ + { + "some json" + } + """; + + try (var service = createGoogleVertexAiService()) { + ActionListener modelListener = ActionListener.wrap(model -> { + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().serviceAccountJson().toString(), is(serviceAccountJson)); + }, e -> fail("Model parsing should succeeded, but failed: " + e.getMessage())); + + service.parseRequestConfig( + "id", + TaskType.TEXT_EMBEDDING, + getRequestConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId + ) + ), + new HashMap<>(Map.of()), + getSecretSettingsMap(serviceAccountJson) + ), + modelListener + ); + } + } + public void testParseRequestConfig_CreatesGoogleVertexAiRerankModel() throws IOException { var projectId = "project"; var serviceAccountJson = """ @@ -321,6 +449,161 @@ public class GoogleVertexAiServiceTests extends ESTestCase { } } + public void testParsePersistedConfigWithSecrets_CreatesAGoogleVertexAiEmbeddingsModelWithoutChunkingSettingsWhenFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var autoTruncate = true; + var serviceAccountJson = """ + { + "some json" + } + """; + + try (var service = createGoogleVertexAiService()) { + var persistedConfig = getPersistedConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId, + GoogleVertexAiEmbeddingsServiceSettings.DIMENSIONS_SET_BY_USER, + true + ) + ), + getTaskSettingsMap(autoTruncate), + createRandomChunkingSettingsMap(), + getSecretSettingsMap(serviceAccountJson) + ); + + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + persistedConfig.secrets() + ); + + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(Boolean.TRUE)); + assertThat(embeddingsModel.getTaskSettings(), is(new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate))); + assertNull(embeddingsModel.getConfigurations().getChunkingSettings()); + assertThat(embeddingsModel.getSecretSettings().serviceAccountJson().toString(), is(serviceAccountJson)); + } + } + + public void testParsePersistedConfigWithSecrets_CreatesAGoogleVertexAiEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var autoTruncate = true; + var serviceAccountJson = """ + { + "some json" + } + """; + + try (var service = createGoogleVertexAiService()) { + var persistedConfig = getPersistedConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId, + GoogleVertexAiEmbeddingsServiceSettings.DIMENSIONS_SET_BY_USER, + true + ) + ), + getTaskSettingsMap(autoTruncate), + createRandomChunkingSettingsMap(), + getSecretSettingsMap(serviceAccountJson) + ); + + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + persistedConfig.secrets() + ); + + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(Boolean.TRUE)); + assertThat(embeddingsModel.getTaskSettings(), is(new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate))); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().serviceAccountJson().toString(), is(serviceAccountJson)); + } + } + + public void testParsePersistedConfigWithSecrets_CreatesAnEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var autoTruncate = true; + var serviceAccountJson = """ + { + "some json" + } + """; + + try (var service = createGoogleVertexAiService()) { + var persistedConfig = getPersistedConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId, + GoogleVertexAiEmbeddingsServiceSettings.DIMENSIONS_SET_BY_USER, + true + ) + ), + getTaskSettingsMap(autoTruncate), + getSecretSettingsMap(serviceAccountJson) + ); + + var model = service.parsePersistedConfigWithSecrets( + "id", + TaskType.TEXT_EMBEDDING, + persistedConfig.config(), + persistedConfig.secrets() + ); + + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(Boolean.TRUE)); + assertThat(embeddingsModel.getTaskSettings(), is(new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate))); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + assertThat(embeddingsModel.getSecretSettings().serviceAccountJson().toString(), is(serviceAccountJson)); + } + } + public void testParsePersistedConfigWithSecrets_CreatesGoogleVertexAiRerankModel() throws IOException { var projectId = "project"; var topN = 1; @@ -550,12 +833,142 @@ public class GoogleVertexAiServiceTests extends ESTestCase { } } + public void testParsePersistedConfig_CreatesAGoogleVertexAiEmbeddingsModelWithoutChunkingSettingsWhenFeatureFlagDisabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is disabled", ChunkingSettingsFeatureFlag.isEnabled() == false); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var autoTruncate = true; + + try (var service = createGoogleVertexAiService()) { + var persistedConfig = getPersistedConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId, + GoogleVertexAiEmbeddingsServiceSettings.DIMENSIONS_SET_BY_USER, + true + ) + ), + getTaskSettingsMap(autoTruncate), + createRandomChunkingSettingsMap() + ); + + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(Boolean.TRUE)); + assertThat(embeddingsModel.getTaskSettings(), is(new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate))); + assertNull(embeddingsModel.getConfigurations().getChunkingSettings()); + } + } + + public void testParsePersistedConfig_CreatesAGoogleVertexAiEmbeddingsModelWhenChunkingSettingsProvidedAndFeatureFlagEnabled() + throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var autoTruncate = true; + + try (var service = createGoogleVertexAiService()) { + var persistedConfig = getPersistedConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId, + GoogleVertexAiEmbeddingsServiceSettings.DIMENSIONS_SET_BY_USER, + true + ) + ), + getTaskSettingsMap(autoTruncate), + createRandomChunkingSettingsMap() + ); + + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(Boolean.TRUE)); + assertThat(embeddingsModel.getTaskSettings(), is(new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate))); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + + public void testParsePersistedConfig_CreatesAnEmbeddingsModelWhenChunkingSettingsNotProvidedAndFeatureFlagEnabled() throws IOException { + assumeTrue("Only if 'inference_chunking_settings' feature flag is enabled", ChunkingSettingsFeatureFlag.isEnabled()); + var projectId = "project"; + var location = "location"; + var modelId = "model"; + var autoTruncate = true; + + try (var service = createGoogleVertexAiService()) { + var persistedConfig = getPersistedConfigMap( + new HashMap<>( + Map.of( + ServiceFields.MODEL_ID, + modelId, + GoogleVertexAiServiceFields.LOCATION, + location, + GoogleVertexAiServiceFields.PROJECT_ID, + projectId, + GoogleVertexAiEmbeddingsServiceSettings.DIMENSIONS_SET_BY_USER, + true + ) + ), + getTaskSettingsMap(autoTruncate) + ); + + var model = service.parsePersistedConfig("id", TaskType.TEXT_EMBEDDING, persistedConfig.config()); + + assertThat(model, instanceOf(GoogleVertexAiEmbeddingsModel.class)); + + var embeddingsModel = (GoogleVertexAiEmbeddingsModel) model; + assertThat(embeddingsModel.getServiceSettings().modelId(), is(modelId)); + assertThat(embeddingsModel.getServiceSettings().location(), is(location)); + assertThat(embeddingsModel.getServiceSettings().projectId(), is(projectId)); + assertThat(embeddingsModel.getServiceSettings().dimensionsSetByUser(), is(Boolean.TRUE)); + assertThat(embeddingsModel.getTaskSettings(), is(new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate))); + assertThat(embeddingsModel.getConfigurations().getChunkingSettings(), instanceOf(ChunkingSettings.class)); + } + } + // testInfer tested via end-to-end notebook tests in AppEx repo private GoogleVertexAiService createGoogleVertexAiService() { return new GoogleVertexAiService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool)); } + private Map getRequestConfigMap( + Map serviceSettings, + Map taskSettings, + Map chunkingSettings, + Map secretSettings + ) { + var requestConfigMap = getRequestConfigMap(serviceSettings, taskSettings, secretSettings); + requestConfigMap.put(ModelConfigurations.CHUNKING_SETTINGS, chunkingSettings); + + return requestConfigMap; + } + private Map getRequestConfigMap( Map serviceSettings, Map taskSettings, diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java index ca38bdb6e2c6..68d03d350d06 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsModelTests.java @@ -79,8 +79,8 @@ public class GoogleVertexAiEmbeddingsModelTests extends ESTestCase { null ), new GoogleVertexAiEmbeddingsTaskSettings(autoTruncate), + null, new GoogleVertexAiSecretSettings(new SecureString(randomAlphaOfLength(8).toCharArray())) ); } - } From 510a56bb96fac0972aa578f5db0bfe5feee45c0d Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Wed, 9 Oct 2024 14:07:30 -0600 Subject: [PATCH 10/43] Remove ccs_telemetry feature flag (#113825) This removes `ccs_telemetry` feature flag, and instead introduces an undocumented, true by default setting: - `search.ccs.collect_telemetry` - enables CCS search telemetry collection and `_cluster/stats?include_remote=true`. Can be disabled if this is causing any problems. --- docs/build.gradle | 1 - docs/changelog/113825.yaml | 12 ++++++++++++ .../cluster/stats/ClusterStatsRemoteIT.java | 8 -------- .../search/ccs/CCSUsageTelemetryIT.java | 8 -------- .../cluster/stats/ClusterStatsResponse.java | 14 +++++--------- .../stats/TransportClusterStatsAction.java | 5 +++-- .../action/search/TransportSearchAction.java | 16 ++++++++-------- .../common/settings/ClusterSettings.java | 1 + .../admin/cluster/RestClusterStatsAction.java | 9 +++------ .../org/elasticsearch/search/SearchService.java | 7 +++++++ .../search/CCSUsageTelemetryAsyncSearchIT.java | 8 -------- .../cluster/ClusterStatsMonitoringDocTests.java | 6 +----- 12 files changed, 40 insertions(+), 55 deletions(-) create mode 100644 docs/changelog/113825.yaml diff --git a/docs/build.gradle b/docs/build.gradle index 8a8d9cde4d1a..e495ecacce27 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -123,7 +123,6 @@ testClusters.matching { it.name == "yamlRestTest"}.configureEach { requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0") requiresFeature 'es.failure_store_feature_flag_enabled', Version.fromString("8.12.0") - requiresFeature 'es.ccs_telemetry_feature_flag_enabled', Version.fromString("8.16.0") // TODO Rene: clean up this kind of cross project file references extraConfigFile 'op-jwks.json', project(':x-pack:test:idp-fixture').file("src/main/resources/oidc/op-jwks.json") diff --git a/docs/changelog/113825.yaml b/docs/changelog/113825.yaml new file mode 100644 index 000000000000..6d4090fda7ed --- /dev/null +++ b/docs/changelog/113825.yaml @@ -0,0 +1,12 @@ +pr: 113825 +summary: Cross-cluster search telemetry +area: Search +type: feature +issues: [] +highlight: + title: Cross-cluster search telemetry + body: |- + The cross-cluster search telemetry is collected when cross-cluster searches + are performed, and is returned as "ccs" field in `_cluster/stats` output. + It also add a new parameter `include_remotes=true` to the `_cluster/stats` API + which will collect data from connected remote clusters. diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRemoteIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRemoteIT.java index 81180e291e52..6cc982424524 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRemoteIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRemoteIT.java @@ -14,7 +14,6 @@ import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.FeatureFlag; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder; @@ -23,7 +22,6 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.InternalTestCluster; import org.junit.Assert; -import org.junit.BeforeClass; import java.util.Collection; import java.util.List; @@ -46,7 +44,6 @@ public class ClusterStatsRemoteIT extends AbstractMultiClustersTestCase { private static final String REMOTE2 = "cluster-b"; private static final String INDEX_NAME = "demo"; - private static final FeatureFlag CCS_TELEMETRY_FEATURE_FLAG = new FeatureFlag("ccs_telemetry"); @Override protected boolean reuseClusters() { @@ -63,11 +60,6 @@ public class ClusterStatsRemoteIT extends AbstractMultiClustersTestCase { return Map.of(REMOTE1, false, REMOTE2, true); } - @BeforeClass - protected static void skipIfTelemetryDisabled() { - assumeTrue("Skipping test as CCS_TELEMETRY_FEATURE_FLAG is disabled", CCS_TELEMETRY_FEATURE_FLAG.isEnabled()); - } - public void testRemoteClusterStats() throws ExecutionException, InterruptedException { setupClusters(); final Client client = client(LOCAL_CLUSTER); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java index 3f738d08ab93..c9d34dbf1401 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/ccs/CCSUsageTelemetryIT.java @@ -25,7 +25,6 @@ import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.CollectionUtils; -import org.elasticsearch.common.util.FeatureFlag; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.plugins.Plugin; @@ -40,7 +39,6 @@ import org.elasticsearch.test.AbstractMultiClustersTestCase; import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.usage.UsageService; import org.junit.Assert; -import org.junit.BeforeClass; import org.junit.Rule; import org.junit.rules.TestRule; import org.junit.runner.Description; @@ -73,7 +71,6 @@ public class CCSUsageTelemetryIT extends AbstractMultiClustersTestCase { private static final Logger LOGGER = LogManager.getLogger(CCSUsageTelemetryIT.class); private static final String REMOTE1 = "cluster-a"; private static final String REMOTE2 = "cluster-b"; - private static final FeatureFlag CCS_TELEMETRY_FEATURE_FLAG = new FeatureFlag("ccs_telemetry"); @Override protected boolean reuseClusters() { @@ -88,11 +85,6 @@ public class CCSUsageTelemetryIT extends AbstractMultiClustersTestCase { @Rule public SkipUnavailableRule skipOverride = new SkipUnavailableRule(REMOTE1, REMOTE2); - @BeforeClass - protected static void skipIfTelemetryDisabled() { - assumeTrue("Skipping test as CCS_TELEMETRY_FEATURE_FLAG is disabled", CCS_TELEMETRY_FEATURE_FLAG.isEnabled()); - } - @Override protected Map skipUnavailableForRemoteClusters() { var map = skipOverride.getMap(); diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java index 1a77a3d4d539..5f7c45c5807a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsResponse.java @@ -28,8 +28,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import static org.elasticsearch.action.search.TransportSearchAction.CCS_TELEMETRY_FEATURE_FLAG; - public class ClusterStatsResponse extends BaseNodesResponse implements ToXContentFragment { final ClusterStatsNodes nodesStats; @@ -145,14 +143,12 @@ public class ClusterStatsResponse extends BaseNodesResponse> { diff --git a/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java b/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java index 553ee1d05a05..1645a378446a 100644 --- a/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java @@ -52,9 +52,9 @@ import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.ArrayUtils; import org.elasticsearch.common.util.CollectionUtils; -import org.elasticsearch.common.util.FeatureFlag; import org.elasticsearch.common.util.Maps; import org.elasticsearch.common.util.concurrent.CountDown; import org.elasticsearch.common.util.concurrent.EsExecutors; @@ -128,8 +128,6 @@ public class TransportSearchAction extends HandledTransportAction SHARD_COUNT_LIMIT_SETTING = Setting.longSetting( "action.search.shard_count.limit", @@ -162,6 +160,7 @@ public class TransportSearchAction extends HandledTransportAction 0; + return SearchService.CCS_COLLECT_TELEMETRY.get(settings) && usageBuilder.getRemotesCount() > 0; } public void setRemotes(int count) { diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index 69be30b0b511..8cbacccb915a 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -467,6 +467,7 @@ public final class ClusterSettings extends AbstractScopedSettings { SearchService.MAX_KEEPALIVE_SETTING, SearchService.ALLOW_EXPENSIVE_QUERIES, SearchService.CCS_VERSION_CHECK_SETTING, + SearchService.CCS_COLLECT_TELEMETRY, MultiBucketConsumerService.MAX_BUCKET_SETTING, SearchService.LOW_LEVEL_CANCELLATION_SETTING, SearchService.MAX_OPEN_SCROLL_CONTEXT, diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java index 6379f6594e7c..236c3a1be0c3 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java @@ -11,8 +11,6 @@ package org.elasticsearch.rest.action.admin.cluster; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest; import org.elasticsearch.client.internal.node.NodeClient; -import org.elasticsearch.common.util.FeatureFlag; -import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.Scope; @@ -33,10 +31,9 @@ public class RestClusterStatsAction extends BaseRestHandler { private static final Set SUPPORTED_CAPABILITIES = Set.of( "human-readable-total-docs-size", - "verbose-dense-vector-mapping-stats" + "verbose-dense-vector-mapping-stats", + "ccs-stats" ); - private static final Set SUPPORTED_CAPABILITIES_CCS_STATS = Set.copyOf(Sets.union(SUPPORTED_CAPABILITIES, Set.of("ccs-stats"))); - public static final FeatureFlag CCS_TELEMETRY_FEATURE_FLAG = new FeatureFlag("ccs_telemetry"); private static final Set SUPPORTED_QUERY_PARAMETERS = Set.of("include_remotes", "nodeId", REST_TIMEOUT_PARAM); @Override @@ -73,6 +70,6 @@ public class RestClusterStatsAction extends BaseRestHandler { @Override public Set supportedCapabilities() { - return CCS_TELEMETRY_FEATURE_FLAG.isEnabled() ? SUPPORTED_CAPABILITIES_CCS_STATS : SUPPORTED_CAPABILITIES; + return SUPPORTED_CAPABILITIES; } } diff --git a/server/src/main/java/org/elasticsearch/search/SearchService.java b/server/src/main/java/org/elasticsearch/search/SearchService.java index 70101bbc7fc5..6fff4318e5b3 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchService.java +++ b/server/src/main/java/org/elasticsearch/search/SearchService.java @@ -260,6 +260,13 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv Property.NodeScope ); + public static final Setting CCS_COLLECT_TELEMETRY = Setting.boolSetting( + "search.ccs.collect_telemetry", + true, + Property.Dynamic, + Property.NodeScope + ); + public static final int DEFAULT_SIZE = 10; public static final int DEFAULT_FROM = 0; diff --git a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/CCSUsageTelemetryAsyncSearchIT.java b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/CCSUsageTelemetryAsyncSearchIT.java index 9e17aa25154b..65f9f1384612 100644 --- a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/CCSUsageTelemetryAsyncSearchIT.java +++ b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/CCSUsageTelemetryAsyncSearchIT.java @@ -14,7 +14,6 @@ import org.elasticsearch.action.admin.cluster.stats.CCSTelemetrySnapshot; import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.client.internal.Client; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.FeatureFlag; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.plugins.Plugin; @@ -34,7 +33,6 @@ import org.elasticsearch.xpack.core.search.action.SubmitAsyncSearchAction; import org.elasticsearch.xpack.core.search.action.SubmitAsyncSearchRequest; import org.hamcrest.Matchers; import org.junit.Before; -import org.junit.BeforeClass; import java.util.Arrays; import java.util.Collection; @@ -55,12 +53,6 @@ import static org.hamcrest.Matchers.greaterThan; public class CCSUsageTelemetryAsyncSearchIT extends AbstractMultiClustersTestCase { private static final String REMOTE1 = "cluster-a"; private static final String REMOTE2 = "cluster-b"; - private static final FeatureFlag CCS_TELEMETRY_FEATURE_FLAG = new FeatureFlag("ccs_telemetry"); - - @BeforeClass - protected static void skipIfTelemetryDisabled() { - assumeTrue("Skipping test as CCS_TELEMETRY_FEATURE_FLAG is disabled", CCS_TELEMETRY_FEATURE_FLAG.isEnabled()); - } @Override protected boolean reuseClusters() { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java index 73ceafc0a24b..c3d502e561bd 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java @@ -78,7 +78,6 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; -import static org.elasticsearch.action.search.TransportSearchAction.CCS_TELEMETRY_FEATURE_FLAG; import static org.elasticsearch.common.xcontent.XContentHelper.stripWhitespace; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -847,10 +846,7 @@ public class ClusterStatsMonitoringDocTests extends BaseMonitoringDocTestCase Date: Wed, 9 Oct 2024 14:21:56 -0600 Subject: [PATCH 11/43] (Doc+) Link API doc to parent object - part2 (#113541) * (Doc+) Cross-link CAT APIs to parent object --------- Co-authored-by: Lisa Cawley Co-authored-by: shainaraskas <58563081+shainaraskas@users.noreply.github.com> --- docs/reference/cat/alias.asciidoc | 2 +- docs/reference/cat/allocation.asciidoc | 5 +++-- docs/reference/cat/anomaly-detectors.asciidoc | 2 +- docs/reference/cat/datafeeds.asciidoc | 2 +- docs/reference/cat/dataframeanalytics.asciidoc | 2 +- docs/reference/cat/indices.asciidoc | 4 ++-- docs/reference/cat/master.asciidoc | 2 +- docs/reference/cat/nodeattrs.asciidoc | 2 +- docs/reference/cat/nodes.asciidoc | 2 +- docs/reference/cat/pending_tasks.asciidoc | 3 +-- docs/reference/cat/plugins.asciidoc | 2 +- docs/reference/cat/recovery.asciidoc | 5 ++--- docs/reference/cat/segments.asciidoc | 5 ++--- docs/reference/cat/shards.asciidoc | 11 +++++++---- docs/reference/cat/trainedmodel.asciidoc | 2 +- docs/reference/cat/transforms.asciidoc | 2 +- .../apis/get-datafeed-stats.asciidoc | 2 +- .../ml/anomaly-detection/apis/get-job-stats.asciidoc | 2 +- .../df-analytics/apis/get-dfanalytics-stats.asciidoc | 2 +- .../trained-models/apis/get-trained-models.asciidoc | 2 +- 20 files changed, 31 insertions(+), 30 deletions(-) diff --git a/docs/reference/cat/alias.asciidoc b/docs/reference/cat/alias.asciidoc index b6459eaa93b8..72f949bf11e5 100644 --- a/docs/reference/cat/alias.asciidoc +++ b/docs/reference/cat/alias.asciidoc @@ -12,7 +12,7 @@ consumption, use the <>. ==== Retrieves the cluster's <>, including filter and routing -information. The API does not return data stream aliases. +information. The API does not return <> aliases. [[cat-alias-api-request]] ==== {api-request-title} diff --git a/docs/reference/cat/allocation.asciidoc b/docs/reference/cat/allocation.asciidoc index 0891406d1be4..bbd044c4b8e5 100644 --- a/docs/reference/cat/allocation.asciidoc +++ b/docs/reference/cat/allocation.asciidoc @@ -7,10 +7,11 @@ [IMPORTANT] ==== cat APIs are only intended for human consumption using the command line or {kib} -console. They are _not_ intended for use by applications. +console. They are _not_ intended for use by applications. For application +consumption, use the <>. ==== -Provides a snapshot of the number of shards allocated to each data node +Provides a snapshot of the number of shards <> to each data node and their disk space. diff --git a/docs/reference/cat/anomaly-detectors.asciidoc b/docs/reference/cat/anomaly-detectors.asciidoc index 3416c256881a..68d952d2a853 100644 --- a/docs/reference/cat/anomaly-detectors.asciidoc +++ b/docs/reference/cat/anomaly-detectors.asciidoc @@ -13,7 +13,7 @@ consumption, use the <>. ==== -Returns configuration and usage information about {anomaly-jobs}. +Returns configuration and usage information about {ml-docs}/ml-ad-overview.html[{anomaly-jobs}]. [[cat-anomaly-detectors-request]] ==== {api-request-title} diff --git a/docs/reference/cat/datafeeds.asciidoc b/docs/reference/cat/datafeeds.asciidoc index 9b6481191e59..506812fedaba 100644 --- a/docs/reference/cat/datafeeds.asciidoc +++ b/docs/reference/cat/datafeeds.asciidoc @@ -12,7 +12,7 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns configuration and usage information about {dfeeds}. +Returns configuration and usage information about {ml-docs}/ml-ad-run-jobs.html#ml-ad-datafeeds[{dfeeds}]. [[cat-datafeeds-request]] ==== {api-request-title} diff --git a/docs/reference/cat/dataframeanalytics.asciidoc b/docs/reference/cat/dataframeanalytics.asciidoc index 4c236ecf61ff..ed0f697c36d5 100644 --- a/docs/reference/cat/dataframeanalytics.asciidoc +++ b/docs/reference/cat/dataframeanalytics.asciidoc @@ -13,7 +13,7 @@ consumption, use the <>. ==== -Returns configuration and usage information about {dfanalytics-jobs}. +Returns configuration and usage information about {ml-docs}/ml-dfanalytics.html[{dfanalytics-jobs}]. [[cat-dfanalytics-request]] diff --git a/docs/reference/cat/indices.asciidoc b/docs/reference/cat/indices.asciidoc index 64b90c4f8e35..cf1cc9f825cb 100644 --- a/docs/reference/cat/indices.asciidoc +++ b/docs/reference/cat/indices.asciidoc @@ -11,8 +11,8 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns high-level information about indices in a cluster, including backing -indices for data streams. +Returns high-level information about <> in a cluster, including backing +indices for <>. [[cat-indices-api-request]] diff --git a/docs/reference/cat/master.asciidoc b/docs/reference/cat/master.asciidoc index 42348fc4939d..bcf2b876e450 100644 --- a/docs/reference/cat/master.asciidoc +++ b/docs/reference/cat/master.asciidoc @@ -11,7 +11,7 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns information about the master node, including the ID, bound IP address, +Returns information about the <>, including the ID, bound IP address, and name. diff --git a/docs/reference/cat/nodeattrs.asciidoc b/docs/reference/cat/nodeattrs.asciidoc index 2db0c3fc2027..ff37b430956a 100644 --- a/docs/reference/cat/nodeattrs.asciidoc +++ b/docs/reference/cat/nodeattrs.asciidoc @@ -11,7 +11,7 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns information about custom node attributes. +Returns information about <>. [[cat-nodeattrs-api-request]] ==== {api-request-title} diff --git a/docs/reference/cat/nodes.asciidoc b/docs/reference/cat/nodes.asciidoc index 5f329c00efd7..651c4ef3c7c2 100644 --- a/docs/reference/cat/nodes.asciidoc +++ b/docs/reference/cat/nodes.asciidoc @@ -13,7 +13,7 @@ They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns information about a cluster's nodes. +Returns information about a <>. [[cat-nodes-api-request]] ==== {api-request-title} diff --git a/docs/reference/cat/pending_tasks.asciidoc b/docs/reference/cat/pending_tasks.asciidoc index 5dd6cb068814..f772cdb66d88 100644 --- a/docs/reference/cat/pending_tasks.asciidoc +++ b/docs/reference/cat/pending_tasks.asciidoc @@ -11,8 +11,7 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns cluster-level changes that have not yet been executed, similar to the -<> API. +Returns <> that have not yet been executed. [[cat-pending-tasks-api-request]] ==== {api-request-title} diff --git a/docs/reference/cat/plugins.asciidoc b/docs/reference/cat/plugins.asciidoc index a812556887b7..ae360862a0ed 100644 --- a/docs/reference/cat/plugins.asciidoc +++ b/docs/reference/cat/plugins.asciidoc @@ -12,7 +12,7 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns a list of plugins running on each node of a cluster. +Returns a list of <> running on each node of a cluster. [[cat-plugins-api-request]] diff --git a/docs/reference/cat/recovery.asciidoc b/docs/reference/cat/recovery.asciidoc index c3292fc9971e..7393a8b71908 100644 --- a/docs/reference/cat/recovery.asciidoc +++ b/docs/reference/cat/recovery.asciidoc @@ -11,10 +11,9 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns information about ongoing and completed shard recoveries, -similar to the <> API. +Returns information about ongoing and completed <>. -For data streams, the API returns information about the stream's backing +For <>, the API returns information about the stream's backing indices. [[cat-recovery-api-request]] diff --git a/docs/reference/cat/segments.asciidoc b/docs/reference/cat/segments.asciidoc index 872af679642d..82dc7298a078 100644 --- a/docs/reference/cat/segments.asciidoc +++ b/docs/reference/cat/segments.asciidoc @@ -12,10 +12,9 @@ consumption, use the <>. ==== Returns low-level information about the https://lucene.apache.org/core/[Lucene] -segments in index shards, similar to the <> -API. +segments in index shards. -For data streams, the API returns information about the stream's backing +For <>, the API returns information about the stream's backing indices. [[cat-segments-api-request]] diff --git a/docs/reference/cat/shards.asciidoc b/docs/reference/cat/shards.asciidoc index a2f8541be4ab..812b946ab2c4 100644 --- a/docs/reference/cat/shards.asciidoc +++ b/docs/reference/cat/shards.asciidoc @@ -9,13 +9,16 @@ ==== cat APIs are only intended for human consumption using the command line or {kib} console. -They are _not_ intended for use by applications. +They are _not_ intended for use by applications. For application +consumption, use the <>. ==== -The `shards` command is the detailed view of what nodes contain which shards. -It will tell you if it's a primary or replica, the number of docs, the bytes it takes on disk, and the node where it's located. +The `shards` command is the detailed view of all nodes' shard <>. +It will tell you if the shard is a primary or replica, the number of docs, the +bytes it takes on disk, the node where it's located, and if the shard is +currently <>. -For data streams, the API returns information about the stream's backing indices. +For <>, the API returns information about the stream's backing indices. [[cat-shards-api-request]] ==== {api-request-title} diff --git a/docs/reference/cat/trainedmodel.asciidoc b/docs/reference/cat/trainedmodel.asciidoc index 74e83525ddfe..45c87038f5d6 100644 --- a/docs/reference/cat/trainedmodel.asciidoc +++ b/docs/reference/cat/trainedmodel.asciidoc @@ -12,7 +12,7 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns configuration and usage information about {infer} trained models. +Returns configuration and usage information about {ml-docs}/ml-nlp-deploy-models.html[{infer} trained models]. [[cat-trained-model-request]] diff --git a/docs/reference/cat/transforms.asciidoc b/docs/reference/cat/transforms.asciidoc index 0d4e9b691ac5..53f22f02fbdb 100644 --- a/docs/reference/cat/transforms.asciidoc +++ b/docs/reference/cat/transforms.asciidoc @@ -12,7 +12,7 @@ console. They are _not_ intended for use by applications. For application consumption, use the <>. ==== -Returns configuration and usage information about {transforms}. +Returns configuration and usage information about <>. [[cat-transforms-api-request]] ==== {api-request-title} diff --git a/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc b/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc index a224f3880a1a..0a8f1e802715 100644 --- a/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc +++ b/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc @@ -7,7 +7,7 @@ Get {dfeed} statistics ++++ -Retrieves usage information for {dfeeds}. +Retrieves usage information for {ml-docs}/ml-ad-run-jobs.html#ml-ad-datafeeds[{dfeeds}]. [[ml-get-datafeed-stats-request]] == {api-request-title} diff --git a/docs/reference/ml/anomaly-detection/apis/get-job-stats.asciidoc b/docs/reference/ml/anomaly-detection/apis/get-job-stats.asciidoc index a5bd188397bb..627109d11e11 100644 --- a/docs/reference/ml/anomaly-detection/apis/get-job-stats.asciidoc +++ b/docs/reference/ml/anomaly-detection/apis/get-job-stats.asciidoc @@ -5,7 +5,7 @@ Get job statistics ++++ -Retrieves usage information for {anomaly-jobs}. +Retrieves usage information for {ml-docs}/ml-ad-overview.html[{anomaly-jobs}]. [[ml-get-job-stats-request]] == {api-request-title} diff --git a/docs/reference/ml/df-analytics/apis/get-dfanalytics-stats.asciidoc b/docs/reference/ml/df-analytics/apis/get-dfanalytics-stats.asciidoc index b193379084db..9037819c9f23 100644 --- a/docs/reference/ml/df-analytics/apis/get-dfanalytics-stats.asciidoc +++ b/docs/reference/ml/df-analytics/apis/get-dfanalytics-stats.asciidoc @@ -6,7 +6,7 @@ Get {dfanalytics-jobs} stats ++++ -Retrieves usage information for {dfanalytics-jobs}. +Retrieves usage information for {ml-docs}/ml-dfanalytics.html[{dfanalytics-jobs}]. [[ml-get-dfanalytics-stats-request]] diff --git a/docs/reference/ml/trained-models/apis/get-trained-models.asciidoc b/docs/reference/ml/trained-models/apis/get-trained-models.asciidoc index f203578c6f1c..ffb46eaa1fe2 100644 --- a/docs/reference/ml/trained-models/apis/get-trained-models.asciidoc +++ b/docs/reference/ml/trained-models/apis/get-trained-models.asciidoc @@ -6,7 +6,7 @@ Get trained models ++++ -Retrieves configuration information for a trained model. +Retrieves configuration information about {ml-docs}/ml-nlp-deploy-models.html[{infer} trained models]. [[ml-get-trained-models-request]] From d907181aa4b0b5d0a1a9933a0b582ce761c36b5b Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 9 Oct 2024 21:23:57 +0100 Subject: [PATCH 12/43] Remove type param from `BaseNodesRequest` (#114399) This type parameter is only needed so that the `.timeout(TimeValue)` method returns a request of the right type, but this still requires an unchecked cast. Yet there's no real need to return anything from this method, we can just use a regular setter. This commit does that. --- .../GetDatabaseConfigurationAction.java | 2 +- .../ingest/geoip/stats/GeoIpStatsAction.java | 2 +- .../NodesCapabilitiesRequest.java | 2 +- .../node/features/NodesFeaturesRequest.java | 2 +- .../hotthreads/NodesHotThreadsRequest.java | 2 +- .../cluster/node/info/NodesInfoRequest.java | 2 +- .../NodesReloadSecureSettingsRequest.java | 2 +- .../shutdown/PrevalidateShardPathRequest.java | 2 +- ...TransportPrevalidateNodeRemovalAction.java | 3 +- .../cluster/node/stats/NodesStatsRequest.java | 2 +- .../cluster/node/usage/NodesUsageRequest.java | 2 +- .../status/TransportNodesSnapshotsStatus.java | 10 +- .../TransportSnapshotsStatusAction.java | 5 +- .../cluster/stats/ClusterStatsRequest.java | 2 +- .../find/FindDanglingIndexRequest.java | 2 +- .../list/ListDanglingIndicesRequest.java | 2 +- .../support/nodes/BaseNodesRequest.java | 7 +- .../nodes/NodesOperationRequestBuilder.java | 4 +- .../support/nodes/TransportNodesAction.java | 2 +- .../cluster/InternalClusterInfoService.java | 2 +- ...ransportNodesListGatewayStartedShards.java | 2 +- .../health/stats/HealthApiStatsAction.java | 2 +- .../TransportNodesListShardStoreMetadata.java | 2 +- .../admin/cluster/RestClusterStatsAction.java | 2 +- .../cluster/RestNodesCapabilitiesAction.java | 4 +- .../cluster/RestNodesHotThreadsAction.java | 2 +- .../admin/cluster/RestNodesInfoAction.java | 2 +- .../admin/cluster/RestNodesStatsAction.java | 2 +- .../admin/cluster/RestNodesUsageAction.java | 2 +- .../RestReloadSecureSettingsAction.java | 2 +- .../node/tasks/CancellableTasksTests.java | 2 +- .../node/tasks/TaskManagerTestCase.java | 4 +- .../cluster/node/tasks/TestTaskPlugin.java | 2 +- .../node/tasks/TransportTasksActionTests.java | 2 +- .../nodes/TransportNodesActionTests.java | 2 +- .../nodeinfo/AutoscalingNodeInfoService.java | 105 +++++++++--------- .../action/AnalyticsStatsAction.java | 2 +- .../NodesDataTiersUsageTransportAction.java | 2 +- .../action/GetInferenceDiagnosticsAction.java | 2 +- .../action/TrainedModelCacheInfoAction.java | 2 +- .../action/ClearSecurityCacheRequest.java | 2 +- .../ClearPrivilegesCacheRequest.java | 2 +- .../action/realm/ClearRealmCacheRequest.java | 2 +- .../action/role/ClearRolesCacheRequest.java | 2 +- ...ServiceAccountCredentialsNodesRequest.java | 2 +- .../spatial/action/SpatialStatsAction.java | 2 +- .../action/GetTransformNodeStatsAction.java | 2 +- .../actions/stats/WatcherStatsRequest.java | 2 +- .../NodesDeprecationCheckRequest.java | 2 +- .../logging/DeprecationCacheResetAction.java | 2 +- .../action/EnrichCoordinatorStatsAction.java | 2 +- .../xpack/eql/plugin/EqlStatsRequest.java | 2 +- .../xpack/esql/plugin/EsqlStatsRequest.java | 2 +- .../ml/action/TransportMlMemoryAction.java | 3 +- .../collector/node/NodeStatsCollector.java | 2 +- ...earRepositoriesMeteringArchiveRequest.java | 2 +- .../action/RepositoriesMeteringRequest.java | 2 +- ...rtSearchableSnapshotCacheStoresAction.java | 2 +- ...rchableSnapshotsNodeCachesStatsAction.java | 2 +- .../xpack/sql/plugin/SqlStatsRequest.java | 2 +- 60 files changed, 124 insertions(+), 123 deletions(-) diff --git a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/direct/GetDatabaseConfigurationAction.java b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/direct/GetDatabaseConfigurationAction.java index 0d1f1d2f9f66..89bc3d1ce5d3 100644 --- a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/direct/GetDatabaseConfigurationAction.java +++ b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/direct/GetDatabaseConfigurationAction.java @@ -41,7 +41,7 @@ public class GetDatabaseConfigurationAction extends ActionType { super(NAME); } - public static class Request extends BaseNodesRequest { + public static class Request extends BaseNodesRequest { private final String[] databaseIds; public Request(String... databaseIds) { diff --git a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpStatsAction.java b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpStatsAction.java index 79865faa3b5b..0fe7cdb4b0d1 100644 --- a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpStatsAction.java +++ b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/stats/GeoIpStatsAction.java @@ -37,7 +37,7 @@ public class GeoIpStatsAction { private GeoIpStatsAction() {/* no instances */} - public static class Request extends BaseNodesRequest implements ToXContentObject { + public static class Request extends BaseNodesRequest implements ToXContentObject { public Request() { super((String[]) null); diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java index 114c6518da9f..bd7d9c551c31 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java @@ -16,7 +16,7 @@ import org.elasticsearch.rest.RestRequest; import java.util.Set; -public class NodesCapabilitiesRequest extends BaseNodesRequest { +public class NodesCapabilitiesRequest extends BaseNodesRequest { private RestRequest.Method method = RestRequest.Method.GET; private String path = "/"; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/features/NodesFeaturesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/features/NodesFeaturesRequest.java index 7ebd4023919e..dfcec2b5891f 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/features/NodesFeaturesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/features/NodesFeaturesRequest.java @@ -11,7 +11,7 @@ package org.elasticsearch.action.admin.cluster.node.features; import org.elasticsearch.action.support.nodes.BaseNodesRequest; -public class NodesFeaturesRequest extends BaseNodesRequest { +public class NodesFeaturesRequest extends BaseNodesRequest { public NodesFeaturesRequest(String... nodes) { super(nodes); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequest.java index 7a5be51e3c06..43a055e5efea 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequest.java @@ -14,7 +14,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.core.TimeValue; import org.elasticsearch.monitor.jvm.HotThreads; -public class NodesHotThreadsRequest extends BaseNodesRequest { +public class NodesHotThreadsRequest extends BaseNodesRequest { final HotThreads.RequestOptions requestOptions; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java index 7413ef90ef32..0aff40ebafaf 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java @@ -18,7 +18,7 @@ import java.util.TreeSet; /** * A request to get node (cluster) level information. */ -public final class NodesInfoRequest extends BaseNodesRequest { +public final class NodesInfoRequest extends BaseNodesRequest { private final NodesInfoMetrics nodesInfoMetrics; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java index dba50efe5440..801047ad2e0c 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java @@ -33,7 +33,7 @@ import java.util.Arrays; /** * Request for a reload secure settings action */ -public class NodesReloadSecureSettingsRequest extends BaseNodesRequest { +public class NodesReloadSecureSettingsRequest extends BaseNodesRequest { /** * The password is used to re-read and decrypt the contents diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathRequest.java index 4998f537a9ac..8a74328eed9d 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateShardPathRequest.java @@ -16,7 +16,7 @@ import java.util.Arrays; import java.util.Objects; import java.util.Set; -public class PrevalidateShardPathRequest extends BaseNodesRequest { +public class PrevalidateShardPathRequest extends BaseNodesRequest { private final Set shardIds; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalAction.java index 560cb391476c..f6885f993fb1 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportPrevalidateNodeRemovalAction.java @@ -229,7 +229,8 @@ public class TransportPrevalidateNodeRemovalAction extends TransportMasterNodeRe ) // Convert to ShardId .collect(Collectors.toSet()); var nodeIds = requestNodes.stream().map(DiscoveryNode::getId).toList().toArray(new String[0]); - var checkShardsRequest = new PrevalidateShardPathRequest(redShards, nodeIds).timeout(request.timeout()); + var checkShardsRequest = new PrevalidateShardPathRequest(redShards, nodeIds); + checkShardsRequest.setTimeout(request.timeout()); client.execute(TransportPrevalidateShardPathAction.TYPE, checkShardsRequest, new ActionListener<>() { @Override public void onResponse(PrevalidateShardPathResponse response) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java index 1b3b3fd473b1..b2c1b9adaf83 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java @@ -25,7 +25,7 @@ import java.util.Set; /** * A request to get node (cluster) level stats. */ -public class NodesStatsRequest extends BaseNodesRequest { +public class NodesStatsRequest extends BaseNodesRequest { private final NodesStatsRequestParameters nodesStatsRequestParameters; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageRequest.java index 4c6c42853943..2961760b8164 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodesUsageRequest.java @@ -11,7 +11,7 @@ package org.elasticsearch.action.admin.cluster.node.usage; import org.elasticsearch.action.support.nodes.BaseNodesRequest; -public class NodesUsageRequest extends BaseNodesRequest { +public class NodesUsageRequest extends BaseNodesRequest { private boolean restActions; private boolean aggregations; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java index 42b71e275bb1..64261c75f0a0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportNodesSnapshotsStatus.java @@ -121,17 +121,13 @@ public class TransportNodesSnapshotsStatus extends TransportNodesAction< } } - public static class Request extends BaseNodesRequest { + public static class Request extends BaseNodesRequest { - private Snapshot[] snapshots; + private final Snapshot[] snapshots; - public Request(String[] nodesIds) { + public Request(String[] nodesIds, Snapshot[] snapshots) { super(nodesIds); - } - - public Request snapshots(Snapshot[] snapshots) { this.snapshots = snapshots; - return this; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java index 13aa4aed1a5b..fd65c422a2e1 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java @@ -141,10 +141,11 @@ public class TransportSnapshotsStatusAction extends TransportMasterNodeAction( threadPool.executor(ThreadPool.Names.SNAPSHOT_META), diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRequest.java index a62db92687e5..d8db2c5e657b 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsRequest.java @@ -19,7 +19,7 @@ import java.util.Map; /** * A request to get cluster level stats. */ -public class ClusterStatsRequest extends BaseNodesRequest { +public class ClusterStatsRequest extends BaseNodesRequest { /** * Should the remote cluster stats be included in the response. */ diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexRequest.java index f8abbf502565..e156e5e8b4fe 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/find/FindDanglingIndexRequest.java @@ -12,7 +12,7 @@ package org.elasticsearch.action.admin.indices.dangling.find; import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.common.Strings; -public class FindDanglingIndexRequest extends BaseNodesRequest { +public class FindDanglingIndexRequest extends BaseNodesRequest { private final String indexUUID; public FindDanglingIndexRequest(String indexUUID) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesRequest.java index 51cabaa5b24e..ee1d84a07e69 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/dangling/list/ListDanglingIndicesRequest.java @@ -12,7 +12,7 @@ package org.elasticsearch.action.admin.indices.dangling.list; import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.common.Strings; -public class ListDanglingIndicesRequest extends BaseNodesRequest { +public class ListDanglingIndicesRequest extends BaseNodesRequest { /** * Filter the response by index UUID. Leave as null to find all indices. */ diff --git a/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesRequest.java b/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesRequest.java index 87aa1044f2c6..ea1c1a7e61a0 100644 --- a/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesRequest.java @@ -23,7 +23,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Objects; -public abstract class BaseNodesRequest> extends ActionRequest { +public abstract class BaseNodesRequest extends ActionRequest { /** * Sequence of node specifications that describe the nodes that this request should target. See {@link DiscoveryNodes#resolveNodes} for @@ -53,14 +53,13 @@ public abstract class BaseNodesRequest return nodesIds; } + @Nullable public TimeValue timeout() { return this.timeout; } - @SuppressWarnings("unchecked") - public final Request timeout(TimeValue timeout) { + public final void setTimeout(@Nullable TimeValue timeout) { this.timeout = timeout; - return (Request) this; } @Override diff --git a/server/src/main/java/org/elasticsearch/action/support/nodes/NodesOperationRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/support/nodes/NodesOperationRequestBuilder.java index 290e0bf97aec..cc65a5697cb3 100644 --- a/server/src/main/java/org/elasticsearch/action/support/nodes/NodesOperationRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/support/nodes/NodesOperationRequestBuilder.java @@ -15,7 +15,7 @@ import org.elasticsearch.client.internal.ElasticsearchClient; import org.elasticsearch.core.TimeValue; public abstract class NodesOperationRequestBuilder< - Request extends BaseNodesRequest, + Request extends BaseNodesRequest, Response extends BaseNodesResponse, RequestBuilder extends NodesOperationRequestBuilder> extends ActionRequestBuilder< Request, @@ -27,7 +27,7 @@ public abstract class NodesOperationRequestBuilder< @SuppressWarnings("unchecked") public RequestBuilder setTimeout(TimeValue timeout) { - request.timeout(timeout); + request.setTimeout(timeout); return (RequestBuilder) this; } diff --git a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java index cae30b76ead4..96b1e1e1efca 100644 --- a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java @@ -46,7 +46,7 @@ import java.util.concurrent.Executor; import static org.elasticsearch.core.Strings.format; public abstract class TransportNodesAction< - NodesRequest extends BaseNodesRequest, + NodesRequest extends BaseNodesRequest, NodesResponse extends BaseNodesResponse, NodeRequest extends TransportRequest, NodeResponse extends BaseNodeResponse, diff --git a/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java b/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java index 2ec19c73d4a2..17bd913ffb72 100644 --- a/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java +++ b/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java @@ -285,7 +285,7 @@ public class InternalClusterInfoService implements ClusterInfoService, ClusterSt nodesStatsRequest.setIncludeShardsStats(false); nodesStatsRequest.clear(); nodesStatsRequest.addMetric(NodesStatsRequestParameters.Metric.FS); - nodesStatsRequest.timeout(fetchTimeout); + nodesStatsRequest.setTimeout(fetchTimeout); client.admin().cluster().nodesStats(nodesStatsRequest, ActionListener.releaseAfter(new ActionListener<>() { @Override public void onResponse(NodesStatsResponse nodesStatsResponse) { diff --git a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java index b7ddb9226ddb..737b90484983 100644 --- a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java +++ b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java @@ -182,7 +182,7 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesAction } } - public static class Request extends BaseNodesRequest { + public static class Request extends BaseNodesRequest { private final ShardId shardId; @Nullable diff --git a/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java b/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java index 94aa3d66f31a..fd3fadcbf1f9 100644 --- a/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java +++ b/server/src/main/java/org/elasticsearch/health/stats/HealthApiStatsAction.java @@ -39,7 +39,7 @@ public class HealthApiStatsAction extends ActionType { + public static class Request extends BaseNodesRequest { public Request() { super((String[]) null); diff --git a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java index dc6b14cec3ca..345a4b41139c 100644 --- a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java +++ b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetadata.java @@ -278,7 +278,7 @@ public class TransportNodesListShardStoreMetadata extends TransportNodesAction< } } - public static class Request extends BaseNodesRequest { + public static class Request extends BaseNodesRequest { private final ShardId shardId; @Nullable diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java index 236c3a1be0c3..6427e6139a7a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java @@ -57,7 +57,7 @@ public class RestClusterStatsAction extends BaseRestHandler { request.paramAsBoolean("include_remotes", false), request.paramAsStringArray("nodeId", null) ); - clusterStatsRequest.timeout(getTimeout(request)); + clusterStatsRequest.setTimeout(getTimeout(request)); return channel -> new RestCancellableNodeClient(client, request.getHttpChannel()).admin() .cluster() .clusterStats(clusterStatsRequest, new NodesResponseRestListener<>(channel)); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java index fcc98c1b5caa..897dd1b52e56 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java @@ -65,8 +65,8 @@ public class RestNodesCapabilitiesAction extends BaseRestHandler { // Handle the 'path' parameter, use "/" as default if not provided String path = URLDecoder.decode(request.param("path", "/"), StandardCharsets.UTF_8); - NodesCapabilitiesRequest r = requestNodes.timeout(getTimeout(request)) - .method(RestRequest.Method.valueOf(request.param("method", "GET"))) + requestNodes.setTimeout(getTimeout(request)); + NodesCapabilitiesRequest r = requestNodes.method(RestRequest.Method.valueOf(request.param("method", "GET"))) .path(path) .parameters(request.paramAsStringArray("parameters", Strings.EMPTY_ARRAY)) .capabilities(request.paramAsStringArray("capabilities", Strings.EMPTY_ARRAY)) diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java index 1d40defdcac6..e84ed3d59be1 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesHotThreadsAction.java @@ -115,7 +115,7 @@ public class RestNodesHotThreadsAction extends BaseRestHandler { request.paramAsBoolean("ignore_idle_threads", HotThreads.RequestOptions.DEFAULT.ignoreIdleThreads()) ) ); - nodesHotThreadsRequest.timeout(getTimeout(request)); + nodesHotThreadsRequest.setTimeout(getTimeout(request)); return channel -> client.execute(TransportNodesHotThreadsAction.TYPE, nodesHotThreadsRequest, new RestResponseListener<>(channel) { @Override public RestResponse buildResponse(NodesHotThreadsResponse response) { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java index 3631e2932366..7c3e2050ff6b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesInfoAction.java @@ -88,7 +88,7 @@ public class RestNodesInfoAction extends BaseRestHandler { } final NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(nodeIds); - nodesInfoRequest.timeout(getTimeout(request)); + nodesInfoRequest.setTimeout(getTimeout(request)); // shortcut, don't do checks if only all is specified if (metrics.size() == 1 && metrics.contains("_all")) { nodesInfoRequest.all(); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java index 8fbfff4b33be..933dd4d966fd 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java @@ -81,7 +81,7 @@ public class RestNodesStatsAction extends BaseRestHandler { Set metricNames = Strings.tokenizeByCommaToSet(request.param("metric", "_all")); NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(nodesIds); - nodesStatsRequest.timeout(getTimeout(request)); + nodesStatsRequest.setTimeout(getTimeout(request)); // level parameter validation nodesStatsRequest.setIncludeShardsStats(NodeStatsLevel.of(request, NodeStatsLevel.NODE) != NodeStatsLevel.NODE); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java index 243acf8f73f2..785ef4bcda55 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesUsageAction.java @@ -50,7 +50,7 @@ public class RestNodesUsageAction extends BaseRestHandler { Set metrics = Strings.tokenizeByCommaToSet(request.param("metric", "_all")); NodesUsageRequest nodesUsageRequest = new NodesUsageRequest(nodesIds); - nodesUsageRequest.timeout(getTimeout(request)); + nodesUsageRequest.setTimeout(getTimeout(request)); if (metrics.size() == 1 && metrics.contains("_all")) { nodesUsageRequest.all(); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java index 7e9f9a185319..1d7742155a3c 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestReloadSecureSettingsAction.java @@ -66,7 +66,7 @@ public final class RestReloadSecureSettingsAction extends BaseRestHandler implem final NodesReloadSecureSettingsRequest reloadSecureSettingsRequest = new NodesReloadSecureSettingsRequest( Strings.splitStringByCommaToArray(request.param("nodeId")) ); - reloadSecureSettingsRequest.timeout(getTimeout(request)); + reloadSecureSettingsRequest.setTimeout(getTimeout(request)); request.withContentOrSourceParamParserOrNull(parser -> { if (parser != null) { final ParsedRequestBody parsedRequestBody = PARSER.parse(parser, null); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java index 158a4f54a5d5..964dc61688a6 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksTests.java @@ -100,7 +100,7 @@ public class CancellableTasksTests extends TaskManagerTestCase { } } - public static class CancellableNodesRequest extends BaseNodesRequest { + public static class CancellableNodesRequest extends BaseNodesRequest { private final String requestName; public CancellableNodesRequest(String requestName, String... nodesIds) { diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java index a61360dab7e3..2ddcaa5d9703 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java @@ -137,8 +137,8 @@ public abstract class TaskManagerTestCase extends ESTestCase { /** * Simulates node-based task that can be used to block node tasks so they are guaranteed to be registered by task manager */ - abstract class AbstractTestNodesAction, NodeRequest extends TransportRequest> - extends TransportNodesAction { + abstract class AbstractTestNodesAction extends + TransportNodesAction { AbstractTestNodesAction( String actionName, diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java index 059197443795..f64dd23e13bb 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TestTaskPlugin.java @@ -196,7 +196,7 @@ public class TestTaskPlugin extends Plugin implements ActionPlugin, NetworkPlugi } } - public static class NodesRequest extends BaseNodesRequest { + public static class NodesRequest extends BaseNodesRequest { private final String requestName; private boolean shouldStoreResult = false; private boolean shouldBlock = true; diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java index 4efe7844d611..3cd0ebb0234b 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TransportTasksActionTests.java @@ -107,7 +107,7 @@ public class TransportTasksActionTests extends TaskManagerTestCase { } } - public static class NodesRequest extends BaseNodesRequest { + public static class NodesRequest extends BaseNodesRequest { private final String requestName; public NodesRequest(String requestName, String... nodesIds) { diff --git a/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java b/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java index 4a3b060c3e1c..7252e5fe928b 100644 --- a/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/nodes/TransportNodesActionTests.java @@ -457,7 +457,7 @@ public class TransportNodesActionTests extends ESTestCase { } } - private static class TestNodesRequest extends BaseNodesRequest { + private static class TestNodesRequest extends BaseNodesRequest { TestNodesRequest(String... nodesIds) { super(nodesIds); } diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/nodeinfo/AutoscalingNodeInfoService.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/nodeinfo/AutoscalingNodeInfoService.java index 7490c7a73aec..9ae376570769 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/nodeinfo/AutoscalingNodeInfoService.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/capacity/nodeinfo/AutoscalingNodeInfoService.java @@ -15,6 +15,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoMetrics; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequestParameters; +import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.support.nodes.BaseNodeResponse; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterChangedEvent; @@ -115,6 +116,18 @@ public class AutoscalingNodeInfoService { return null; } + private static NodesInfoRequest getNodesInfoRequest(NodesStatsResponse nodesStatsResponse, TimeValue timeout) { + // Only gather info for nodes that provided their stats + final var nodeIds = nodesStatsResponse.getNodes() + .stream() + .map(BaseNodeResponse::getNode) + .map(DiscoveryNode::getId) + .toArray(String[]::new); + final var nodesInfoRequest = new NodesInfoRequest(nodeIds).clear().addMetric(NodesInfoMetrics.Metric.OS.metricName()); + nodesInfoRequest.setTimeout(timeout); + return nodesInfoRequest; + } + private void sendToMissingNodes(Function nodeLookup, Set missingNodes) { final Runnable onError = () -> { synchronized (mutex) { @@ -125,7 +138,8 @@ public class AutoscalingNodeInfoService { }; final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest( missingNodes.stream().map(DiscoveryNode::getId).toArray(String[]::new) - ).clear().addMetric(NodesStatsRequestParameters.Metric.OS).timeout(fetchTimeout); + ).clear().addMetric(NodesStatsRequestParameters.Metric.OS); + nodesStatsRequest.setTimeout(fetchTimeout); nodesStatsRequest.setIncludeShardsStats(false); client.admin() .cluster() @@ -134,58 +148,47 @@ public class AutoscalingNodeInfoService { ActionListener.wrap( nodesStatsResponse -> client.admin() .cluster() - .nodesInfo( - // Only gather info for nodes that provided their stats - new NodesInfoRequest( - nodesStatsResponse.getNodes() - .stream() - .map(BaseNodeResponse::getNode) - .map(DiscoveryNode::getId) - .toArray(String[]::new) - ).clear().addMetric(NodesInfoMetrics.Metric.OS.metricName()).timeout(fetchTimeout), - ActionListener.wrap(nodesInfoResponse -> { - final Map builderBuilder = Maps.newHashMapWithExpectedSize( - nodesStatsResponse.getNodes().size() + .nodesInfo(getNodesInfoRequest(nodesStatsResponse, fetchTimeout), ActionListener.wrap(nodesInfoResponse -> { + final Map builderBuilder = Maps.newHashMapWithExpectedSize( + nodesStatsResponse.getNodes().size() + ); + nodesStatsResponse.getNodes() + .forEach( + nodeStats -> builderBuilder.put( + nodeStats.getNode().getEphemeralId(), + AutoscalingNodeInfo.builder().setMemory(nodeStats.getOs().getMem().getAdjustedTotal().getBytes()) + ) ); - nodesStatsResponse.getNodes() - .forEach( - nodeStats -> builderBuilder.put( - nodeStats.getNode().getEphemeralId(), - AutoscalingNodeInfo.builder() - .setMemory(nodeStats.getOs().getMem().getAdjustedTotal().getBytes()) - ) - ); - nodesInfoResponse.getNodes().forEach(nodeInfo -> { - assert builderBuilder.containsKey(nodeInfo.getNode().getEphemeralId()) - : "unexpected missing node when setting processors [" + nodeInfo.getNode().getEphemeralId() + "]"; - builderBuilder.computeIfPresent( - nodeInfo.getNode().getEphemeralId(), - (n, b) -> b.setProcessors(nodeInfo.getInfo(OsInfo.class).getFractionalAllocatedProcessors()) - ); - }); - synchronized (mutex) { - Map builder = new HashMap<>(nodeToMemory); - // Remove all from the builder that failed getting info and stats - Stream.concat(nodesStatsResponse.failures().stream(), nodesInfoResponse.failures().stream()) - .map(FailedNodeException::nodeId) - .map(nodeLookup) - .map(DiscoveryNode::getEphemeralId) - .forEach(builder::remove); + nodesInfoResponse.getNodes().forEach(nodeInfo -> { + assert builderBuilder.containsKey(nodeInfo.getNode().getEphemeralId()) + : "unexpected missing node when setting processors [" + nodeInfo.getNode().getEphemeralId() + "]"; + builderBuilder.computeIfPresent( + nodeInfo.getNode().getEphemeralId(), + (n, b) -> b.setProcessors(nodeInfo.getInfo(OsInfo.class).getFractionalAllocatedProcessors()) + ); + }); + synchronized (mutex) { + Map builder = new HashMap<>(nodeToMemory); + // Remove all from the builder that failed getting info and stats + Stream.concat(nodesStatsResponse.failures().stream(), nodesInfoResponse.failures().stream()) + .map(FailedNodeException::nodeId) + .map(nodeLookup) + .map(DiscoveryNode::getEphemeralId) + .forEach(builder::remove); - // we might add nodes that already died here, - // but those will be removed on next cluster state update anyway and is only a small waste. - builderBuilder.forEach((nodeEphemeralId, memoryProcessorBuilder) -> { - if (memoryProcessorBuilder.canBuild()) { - builder.put(nodeEphemeralId, memoryProcessorBuilder.build()); - } - }); - nodeToMemory = Collections.unmodifiableMap(builder); - } - }, e -> { - onError.run(); - logger.warn(() -> String.format(Locale.ROOT, "Unable to obtain processor info from [%s]", missingNodes), e); - }) - ), + // we might add nodes that already died here, + // but those will be removed on next cluster state update anyway and is only a small waste. + builderBuilder.forEach((nodeEphemeralId, memoryProcessorBuilder) -> { + if (memoryProcessorBuilder.canBuild()) { + builder.put(nodeEphemeralId, memoryProcessorBuilder.build()); + } + }); + nodeToMemory = Collections.unmodifiableMap(builder); + } + }, e -> { + onError.run(); + logger.warn(() -> String.format(Locale.ROOT, "Unable to obtain processor info from [%s]", missingNodes), e); + })), e -> { onError.run(); logger.warn(() -> String.format(Locale.ROOT, "Unable to obtain memory info from [%s]", missingNodes), e); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java index 14fb7c7bf37f..1420b1f86f12 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/analytics/action/AnalyticsStatsAction.java @@ -51,7 +51,7 @@ public class AnalyticsStatsAction extends ActionType implements ToXContentObject { + public static class Request extends BaseNodesRequest implements ToXContentObject { public Request() { super((String[]) null); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datatiers/NodesDataTiersUsageTransportAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datatiers/NodesDataTiersUsageTransportAction.java index 6a544f637772..335a4eaaf584 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datatiers/NodesDataTiersUsageTransportAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/datatiers/NodesDataTiersUsageTransportAction.java @@ -161,7 +161,7 @@ public class NodesDataTiersUsageTransportAction extends TransportNodesAction< return usageStatsByTier; } - public static class NodesRequest extends BaseNodesRequest { + public static class NodesRequest extends BaseNodesRequest { public NodesRequest() { super((String[]) null); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/GetInferenceDiagnosticsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/GetInferenceDiagnosticsAction.java index ef7af21e5e13..db8d1c264ec2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/GetInferenceDiagnosticsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/GetInferenceDiagnosticsAction.java @@ -36,7 +36,7 @@ public class GetInferenceDiagnosticsAction extends ActionType { + public static class Request extends BaseNodesRequest { public Request() { super((String[]) null); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java index 5aa557cd82da..67ecf93acc40 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/TrainedModelCacheInfoAction.java @@ -33,7 +33,7 @@ public class TrainedModelCacheInfoAction extends ActionType { + public static class Request extends BaseNodesRequest { private final DiscoveryNode[] concreteNodes; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheRequest.java index e97670f20bfb..006c2cabe230 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/ClearSecurityCacheRequest.java @@ -14,7 +14,7 @@ import org.elasticsearch.transport.TransportRequest; import java.io.IOException; -public class ClearSecurityCacheRequest extends BaseNodesRequest { +public class ClearSecurityCacheRequest extends BaseNodesRequest { private String cacheName; private String[] keys; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheRequest.java index 6857f43bda25..394b5dbab120 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/privilege/ClearPrivilegesCacheRequest.java @@ -14,7 +14,7 @@ import org.elasticsearch.transport.TransportRequest; import java.io.IOException; -public class ClearPrivilegesCacheRequest extends BaseNodesRequest { +public class ClearPrivilegesCacheRequest extends BaseNodesRequest { private String[] applicationNames; private boolean clearRolesCache = false; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheRequest.java index fe381fc09b74..cc35952f494b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/realm/ClearRealmCacheRequest.java @@ -13,7 +13,7 @@ import org.elasticsearch.transport.TransportRequest; import java.io.IOException; -public class ClearRealmCacheRequest extends BaseNodesRequest { +public class ClearRealmCacheRequest extends BaseNodesRequest { String[] realms; String[] usernames; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheRequest.java index 74d3a2ac85c7..28e75b21a8be 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/role/ClearRolesCacheRequest.java @@ -16,7 +16,7 @@ import java.io.IOException; /** * The request used to clear the cache for native roles stored in an index. */ -public class ClearRolesCacheRequest extends BaseNodesRequest { +public class ClearRolesCacheRequest extends BaseNodesRequest { String[] names; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesRequest.java index 9431ea14097a..c12c830f3712 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/service/GetServiceAccountCredentialsNodesRequest.java @@ -18,7 +18,7 @@ import java.io.IOException; * Request for retrieving service account credentials that are local to each node. * Currently, this means file-backed service tokens. */ -public class GetServiceAccountCredentialsNodesRequest extends BaseNodesRequest { +public class GetServiceAccountCredentialsNodesRequest extends BaseNodesRequest { private final String namespace; private final String serviceName; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java index 80698dcbe022..32dc1550b6aa 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/spatial/action/SpatialStatsAction.java @@ -45,7 +45,7 @@ public class SpatialStatsAction extends ActionType CARTESIANBOUNDS } - public static class Request extends BaseNodesRequest implements ToXContentObject { + public static class Request extends BaseNodesRequest implements ToXContentObject { public Request() { super((String[]) null); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformNodeStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformNodeStatsAction.java index 2ae4593ed3ba..7dd4a7c9d245 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformNodeStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformNodeStatsAction.java @@ -41,7 +41,7 @@ public class GetTransformNodeStatsAction extends ActionType { + public static class NodesStatsRequest extends BaseNodesRequest { public NodesStatsRequest() { super(Strings.EMPTY_ARRAY); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsRequest.java index 2162ec5c38ce..530b3cde6f90 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsRequest.java @@ -16,7 +16,7 @@ import java.io.IOException; /** * The Request to get the watcher stats */ -public class WatcherStatsRequest extends BaseNodesRequest { +public class WatcherStatsRequest extends BaseNodesRequest { private boolean includeCurrentWatches; private boolean includeQueuedWatches; diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckRequest.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckRequest.java index ebe8f036c80a..554c9ef5f0c8 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckRequest.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodesDeprecationCheckRequest.java @@ -12,7 +12,7 @@ import org.elasticsearch.action.support.nodes.BaseNodesRequest; import java.util.Arrays; import java.util.Objects; -public class NodesDeprecationCheckRequest extends BaseNodesRequest { +public class NodesDeprecationCheckRequest extends BaseNodesRequest { public NodesDeprecationCheckRequest(String... nodesIds) { super(nodesIds); diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java index 3e9fbbb5a072..0f374efb520d 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationCacheResetAction.java @@ -37,7 +37,7 @@ public class DeprecationCacheResetAction extends ActionType implements ToXContentObject { + public static class Request extends BaseNodesRequest implements ToXContentObject { public Request() { super((String[]) null); } diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java index 808acee58df3..c38d24392f7e 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/action/EnrichCoordinatorStatsAction.java @@ -45,7 +45,7 @@ public class EnrichCoordinatorStatsAction extends ActionType { + public static class Request extends BaseNodesRequest { public Request() { super(new String[0]); } diff --git a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsRequest.java b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsRequest.java index 56335be32de6..e8753b85d416 100644 --- a/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsRequest.java +++ b/x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plugin/EqlStatsRequest.java @@ -17,7 +17,7 @@ import java.io.IOException; /** * Request to gather usage statistics */ -public class EqlStatsRequest extends BaseNodesRequest { +public class EqlStatsRequest extends BaseNodesRequest { private boolean includeStats; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsRequest.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsRequest.java index 1637bcc335ad..6c1740cac88a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsRequest.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlStatsRequest.java @@ -17,7 +17,7 @@ import java.io.IOException; /** * Request to gather usage statistics */ -public class EsqlStatsRequest extends BaseNodesRequest { +public class EsqlStatsRequest extends BaseNodesRequest { private boolean includeStats; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportMlMemoryAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportMlMemoryAction.java index cefc1f9ad02f..d56b8285522a 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportMlMemoryAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportMlMemoryAction.java @@ -107,7 +107,8 @@ public class TransportMlMemoryAction extends TransportMasterNodeAction { TrainedModelCacheInfoAction.Request trainedModelCacheInfoRequest = new TrainedModelCacheInfoAction.Request( nodesStatsResponse.getNodes().stream().map(NodeStats::getNode).toArray(DiscoveryNode[]::new) - ).timeout(request.ackTimeout()); + ); + trainedModelCacheInfoRequest.setTimeout(request.ackTimeout()); parentTaskClient.execute( TrainedModelCacheInfoAction.INSTANCE, diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java index 8c6ec0c5aa48..3e7581defc62 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsCollector.java @@ -77,7 +77,7 @@ public class NodeStatsCollector extends Collector { NodesStatsRequestParameters.Metric.THREAD_POOL, NodesStatsRequestParameters.Metric.FS ); - request.timeout(getCollectionTimeout()); + request.setTimeout(getCollectionTimeout()); final NodesStatsResponse response = client.admin().cluster().nodesStats(request).actionGet(); ensureNoTimeouts(getCollectionTimeout(), response); diff --git a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/ClearRepositoriesMeteringArchiveRequest.java b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/ClearRepositoriesMeteringArchiveRequest.java index a08852f60736..28d58b4008a1 100644 --- a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/ClearRepositoriesMeteringArchiveRequest.java +++ b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/ClearRepositoriesMeteringArchiveRequest.java @@ -9,7 +9,7 @@ package org.elasticsearch.xpack.repositories.metering.action; import org.elasticsearch.action.support.nodes.BaseNodesRequest; -public final class ClearRepositoriesMeteringArchiveRequest extends BaseNodesRequest { +public final class ClearRepositoriesMeteringArchiveRequest extends BaseNodesRequest { private final long maxVersionToClear; public ClearRepositoriesMeteringArchiveRequest(long maxVersionToClear, String... nodesIds) { diff --git a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringRequest.java b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringRequest.java index d311273dad76..b28257f89956 100644 --- a/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringRequest.java +++ b/x-pack/plugin/repositories-metering-api/src/main/java/org/elasticsearch/xpack/repositories/metering/action/RepositoriesMeteringRequest.java @@ -9,7 +9,7 @@ package org.elasticsearch.xpack.repositories.metering.action; import org.elasticsearch.action.support.nodes.BaseNodesRequest; -public final class RepositoriesMeteringRequest extends BaseNodesRequest { +public final class RepositoriesMeteringRequest extends BaseNodesRequest { public RepositoriesMeteringRequest(String... nodesIds) { super(nodesIds); } diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotCacheStoresAction.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotCacheStoresAction.java index 67cb5cddd988..f7a28d201010 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotCacheStoresAction.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotCacheStoresAction.java @@ -95,7 +95,7 @@ public class TransportSearchableSnapshotCacheStoresAction extends TransportNodes return new NodeCacheFilesMetadata(clusterService.localNode(), cacheService.getCachedSize(request.shardId, request.snapshotId)); } - public static final class Request extends BaseNodesRequest { + public static final class Request extends BaseNodesRequest { private final SnapshotId snapshotId; private final ShardId shardId; diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java index b414ff6daf71..2ffe523f07e3 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/TransportSearchableSnapshotsNodeCachesStatsAction.java @@ -149,7 +149,7 @@ public class TransportSearchableSnapshotsNodeCachesStatsAction extends Transport } } - public static final class NodesRequest extends BaseNodesRequest { + public static final class NodesRequest extends BaseNodesRequest { public NodesRequest(String[] nodes) { super(nodes); } diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsRequest.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsRequest.java index 9f05152b6315..3b1b7832f38f 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsRequest.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlStatsRequest.java @@ -17,7 +17,7 @@ import java.io.IOException; /** * Request to gather usage statistics */ -public class SqlStatsRequest extends BaseNodesRequest { +public class SqlStatsRequest extends BaseNodesRequest { private boolean includeStats; From c4815b3416279f7d952a2904e3efb23fdc0ba755 Mon Sep 17 00:00:00 2001 From: Salvatore Campagna <93581129+salvatore-campagna@users.noreply.github.com> Date: Wed, 9 Oct 2024 22:29:38 +0200 Subject: [PATCH 13/43] LogsDB `host` and `timestamp` mappings tests (#114001) Here we are testing mappings of `host` and `timestamp` fields as they are used as default fields to sort on when using LogsDB. LogsDB uses a `host.name` field mapped as a `keyword` and a `@timestamp` field, required by data streams. Some mappings throw errors as a result of incompatibilities when trying to merge object fields. Such errors are expected. --- x-pack/plugin/logsdb/build.gradle | 6 + .../test/10_logsdb_default_mapping.yml | 254 ++++++++++++++++++ 2 files changed, 260 insertions(+) create mode 100644 x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml diff --git a/x-pack/plugin/logsdb/build.gradle b/x-pack/plugin/logsdb/build.gradle index 466cf69243c8..929d7dad2f5e 100644 --- a/x-pack/plugin/logsdb/build.gradle +++ b/x-pack/plugin/logsdb/build.gradle @@ -23,6 +23,12 @@ base { archivesName = 'x-pack-logsdb' } +restResources { + restApi { + include 'bulk', 'search', '_common', 'indices', 'index', 'cluster', 'data_stream', 'ingest', 'cat', 'capabilities' + } +} + dependencies { compileOnly project(path: xpackModule('core')) testImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml new file mode 100644 index 000000000000..8346221c0106 --- /dev/null +++ b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/10_logsdb_default_mapping.yml @@ -0,0 +1,254 @@ +--- +create logsdb data stream with host.name as keyword: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host.name: + type: "keyword" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + indices.create_data_stream: + name: "logsdb" + + - is_true: acknowledged + +--- +create logsdb data stream with host.name as keyword and timestamp as date: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host.name: + type: "keyword" + "@timestamp": + type: "date" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + indices.create_data_stream: + name: "logsdb" + + - is_true: acknowledged + +--- +create logsdb data stream with host as keyword: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "keyword" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with host as text and multi fields: + - requires: + cluster_features: [ "mapper.keyword_normalizer_synthetic_source" ] + reason: support for normalizer on keyword fields + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "text" + fields: + keyword: + ignore_above: 256 + type: "keyword" + "@timestamp": + type: "date" + format: "strict_date_optional_time" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with host as text: + - requires: + cluster_features: ["mapper.keyword_normalizer_synthetic_source"] + reason: "Support for normalizer on keyword fields" + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "text" + "@timestamp": + type: "date" + format: "strict_date_optional_time" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with host as text and name as double: + - requires: + cluster_features: ["mapper.keyword_normalizer_synthetic_source"] + reason: "Support for normalizer on keyword fields" + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + type: "text" + fields: + name: + type: "double" + "@timestamp": + type: "date" + format: "strict_date_optional_time" + + - do: + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - do: + catch: bad_request + indices.create_data_stream: + name: "logsdb" + + - match: { error.type: "mapper_parsing_exception" } + - match: { error.reason: "Failed to parse mapping: can't merge a non object mapping [host] with an object mapping" } + +--- +create logsdb data stream with timestamp object mapping: + - requires: + cluster_features: ["mapper.keyword_normalizer_synthetic_source"] + reason: "Support for normalizer on keyword fields" + + - do: + cluster.put_component_template: + name: "logsdb-mappings" + body: + template: + settings: + mode: "logsdb" + mappings: + properties: + host: + properties: + name: + type: "keyword" + "@timestamp": + properties: + date: + type: "date" + format: "strict_date_optional_time" + + - do: + catch: bad_request + indices.put_index_template: + name: "logsdb-index-template" + body: + index_patterns: ["logsdb"] + data_stream: {} + composed_of: ["logsdb-mappings"] + + - match: { error.type: "illegal_argument_exception" } + - match: { error.reason: "composable template [logsdb-index-template] template after composition with component templates [logsdb-mappings] is invalid" } From adba420cea003bcda9a07107b1b773722ca51269 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 07:36:15 +1100 Subject: [PATCH 14/43] Mute org.elasticsearch.xpack.inference.InferenceRestIT test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint} #114412 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 9e95c7cb9a62..5225c0016d92 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -360,6 +360,9 @@ tests: - class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT method: test {p0=synonyms/60_synonym_rule_get/Synonym rule not found} issue: https://github.com/elastic/elasticsearch/issues/114444 +- class: org.elasticsearch.xpack.inference.InferenceRestIT + method: test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint} + issue: https://github.com/elastic/elasticsearch/issues/114412 # Examples: # From 1becb3e8a9e1436cc3b727149d72e8824e6b92ee Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Wed, 9 Oct 2024 22:13:11 +0100 Subject: [PATCH 15/43] Prevent flattening of ordered and unordered interval sources (#114234) This PR applies a temporary patch to fix an issue with ordered and unordered intervals source. The flattening that is applied in Lucene modifies the final gap preventing valid queries to match. The fix already exists in Lucene but will be released in Lucene 10.x later this year. Since the bug prevents the combination of ordered and unordered intervals with gaps, this change applies a workaround to ensure that the bug is fixed in Elasticsearch 8x. Relates #113554 --- docs/changelog/114234.yaml | 5 + .../search/query/IntervalQueriesIT.java | 53 +++++++++ .../index/query/IntervalBuilder.java | 2 +- .../elasticsearch/index/query/XIntervals.java | 106 ++++++++++++++++++ .../index/query/IntervalBuilderTests.java | 14 +-- .../query/IntervalQueryBuilderTests.java | 16 +-- 6 files changed, 180 insertions(+), 16 deletions(-) create mode 100644 docs/changelog/114234.yaml create mode 100644 server/src/main/java/org/elasticsearch/index/query/XIntervals.java diff --git a/docs/changelog/114234.yaml b/docs/changelog/114234.yaml new file mode 100644 index 000000000000..0f77ada794be --- /dev/null +++ b/docs/changelog/114234.yaml @@ -0,0 +1,5 @@ +pr: 114234 +summary: Prevent flattening of ordered and unordered interval sources +area: Search +type: bug +issues: [] diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/query/IntervalQueriesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/query/IntervalQueriesIT.java index 7fc93debc65c..def137f9a9ec 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/query/IntervalQueriesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/query/IntervalQueriesIT.java @@ -31,6 +31,7 @@ import java.util.Map; import static java.util.Collections.singletonMap; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits; public class IntervalQueriesIT extends ESIntegTestCase { @@ -64,6 +65,58 @@ public class IntervalQueriesIT extends ESIntegTestCase { ); } + public void testPreserveInnerGap() { + assertAcked(prepareCreate("index").setMapping(""" + { + "_doc" : { + "properties" : { + "text" : { "type" : "text" } + } + } + } + """)); + + indexRandom(true, prepareIndex("index").setId("1").setSource("text", "w1 w2 w3 w4 w5")); + + // ordered + { + var res = prepareSearch("index").setQuery( + new IntervalQueryBuilder( + "text", + new IntervalsSourceProvider.Combine( + Arrays.asList( + new IntervalsSourceProvider.Match("w1 w4", -1, true, null, null, null), + new IntervalsSourceProvider.Match("w5", -1, true, null, null, null) + ), + true, + 1, + null + ) + ) + ); + assertSearchHits(res, "1"); + } + + // unordered + { + var res = prepareSearch("index").setQuery( + new IntervalQueryBuilder( + "text", + new IntervalsSourceProvider.Combine( + Arrays.asList( + new IntervalsSourceProvider.Match("w3", 0, false, null, null, null), + new IntervalsSourceProvider.Match("w4 w1", -1, false, null, null, null) + ), + false, + 0, + null + ) + ) + ); + assertSearchHits(res, "1"); + } + } + private static class EmptyAnalyzer extends Analyzer { @Override diff --git a/server/src/main/java/org/elasticsearch/index/query/IntervalBuilder.java b/server/src/main/java/org/elasticsearch/index/query/IntervalBuilder.java index 46d7fec64194..f21edaeb94f2 100644 --- a/server/src/main/java/org/elasticsearch/index/query/IntervalBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/IntervalBuilder.java @@ -126,7 +126,7 @@ public abstract class IntervalBuilder { if (maxGaps == 0 && ordered) { return Intervals.phrase(sourcesArray); } - IntervalsSource inner = ordered ? Intervals.ordered(sourcesArray) : Intervals.unordered(sourcesArray); + IntervalsSource inner = ordered ? XIntervals.ordered(sourcesArray) : XIntervals.unordered(sourcesArray); if (maxGaps == -1) { return inner; } diff --git a/server/src/main/java/org/elasticsearch/index/query/XIntervals.java b/server/src/main/java/org/elasticsearch/index/query/XIntervals.java new file mode 100644 index 000000000000..7d8552e18f79 --- /dev/null +++ b/server/src/main/java/org/elasticsearch/index/query/XIntervals.java @@ -0,0 +1,106 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.index.query; + +import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.queries.intervals.IntervalIterator; +import org.apache.lucene.queries.intervals.IntervalMatchesIterator; +import org.apache.lucene.queries.intervals.Intervals; +import org.apache.lucene.queries.intervals.IntervalsSource; +import org.apache.lucene.search.QueryVisitor; + +import java.io.IOException; +import java.util.Collection; +import java.util.Objects; + +/** + * Copy of {@link Intervals} that exposes versions of {@link Intervals#ordered} and {@link Intervals#unordered} + * that preserve their inner gaps. + * NOTE: Remove this hack when a version of Lucene with https://github.com/apache/lucene/pull/13819 is used (10.1.0). + */ +public final class XIntervals { + + /** + * Create an ordered {@link IntervalsSource} + * + *

Returns intervals in which the subsources all appear in the given order + * + * @param subSources an ordered set of {@link IntervalsSource} objects + */ + public static IntervalsSource ordered(IntervalsSource... subSources) { + return new DelegateIntervalsSource(Intervals.ordered(subSources)); + } + + /** + * Create an ordered {@link IntervalsSource} + * + *

Returns intervals in which the subsources all appear in the given order + * + * @param subSources an ordered set of {@link IntervalsSource} objects + */ + public static IntervalsSource unordered(IntervalsSource... subSources) { + return new DelegateIntervalsSource(Intervals.unordered(subSources)); + } + + /** + * Wraps a source to avoid aggressive flattening of the ordered and unordered sources. + * The flattening modifies the final gap and is removed in the latest unreleased version of Lucene (10.1). + */ + private static class DelegateIntervalsSource extends IntervalsSource { + private final IntervalsSource delegate; + + private DelegateIntervalsSource(IntervalsSource delegate) { + this.delegate = delegate; + } + + @Override + public IntervalIterator intervals(String field, LeafReaderContext ctx) throws IOException { + return delegate.intervals(field, ctx); + } + + @Override + public IntervalMatchesIterator matches(String field, LeafReaderContext ctx, int doc) throws IOException { + return delegate.matches(field, ctx, doc); + } + + @Override + public void visit(String field, QueryVisitor visitor) { + delegate.visit(field, visitor); + } + + @Override + public int minExtent() { + return delegate.minExtent(); + } + + @Override + public Collection pullUpDisjunctions() { + return delegate.pullUpDisjunctions(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DelegateIntervalsSource that = (DelegateIntervalsSource) o; + return Objects.equals(delegate, that.delegate); + } + + @Override + public int hashCode() { + return Objects.hash(delegate); + } + + @Override + public String toString() { + return delegate.toString(); + } + } +} diff --git a/server/src/test/java/org/elasticsearch/index/query/IntervalBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/IntervalBuilderTests.java index 3476655c705a..7005f17663d0 100644 --- a/server/src/test/java/org/elasticsearch/index/query/IntervalBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/IntervalBuilderTests.java @@ -46,7 +46,7 @@ public class IntervalBuilderTests extends ESTestCase { CannedTokenStream ts = new CannedTokenStream(new Token("term1", 1, 2), new Token("term2", 3, 4), new Token("term3", 5, 6)); IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true); - IntervalsSource expected = Intervals.ordered(Intervals.term("term1"), Intervals.term("term2"), Intervals.term("term3")); + IntervalsSource expected = XIntervals.ordered(Intervals.term("term1"), Intervals.term("term2"), Intervals.term("term3")); assertEquals(expected, source); @@ -57,7 +57,7 @@ public class IntervalBuilderTests extends ESTestCase { CannedTokenStream ts = new CannedTokenStream(new Token("term1", 1, 2), new Token("term2", 3, 4), new Token("term3", 5, 6)); IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, false); - IntervalsSource expected = Intervals.unordered(Intervals.term("term1"), Intervals.term("term2"), Intervals.term("term3")); + IntervalsSource expected = XIntervals.unordered(Intervals.term("term1"), Intervals.term("term2"), Intervals.term("term3")); assertEquals(expected, source); @@ -101,7 +101,7 @@ public class IntervalBuilderTests extends ESTestCase { ); IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true); - IntervalsSource expected = Intervals.ordered( + IntervalsSource expected = XIntervals.ordered( Intervals.term("term1"), Intervals.or(Intervals.term("term2"), Intervals.term("term4")), Intervals.term("term3") @@ -122,7 +122,7 @@ public class IntervalBuilderTests extends ESTestCase { ); IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true); - IntervalsSource expected = Intervals.ordered( + IntervalsSource expected = XIntervals.ordered( Intervals.term("term1"), Intervals.extend(Intervals.or(Intervals.term("term2"), Intervals.term("term3"), Intervals.term("term4")), 1, 0), Intervals.term("term5") @@ -143,7 +143,7 @@ public class IntervalBuilderTests extends ESTestCase { ); IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true); - IntervalsSource expected = Intervals.ordered( + IntervalsSource expected = XIntervals.ordered( Intervals.term("term1"), Intervals.or(Intervals.term("term2"), Intervals.phrase("term3", "term4")), Intervals.term("term5") @@ -166,7 +166,7 @@ public class IntervalBuilderTests extends ESTestCase { ); IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true); - IntervalsSource expected = Intervals.ordered( + IntervalsSource expected = XIntervals.ordered( Intervals.term("term1"), Intervals.or( Intervals.extend(Intervals.term("term2"), 1, 0), @@ -190,7 +190,7 @@ public class IntervalBuilderTests extends ESTestCase { ); IntervalsSource source = BUILDER.analyzeText(new CachingTokenFilter(ts), -1, true); - IntervalsSource expected = Intervals.ordered( + IntervalsSource expected = XIntervals.ordered( Intervals.term("term1"), Intervals.or(Intervals.term("term2"), Intervals.phrase("term3", "term4")), Intervals.extend(Intervals.term("term5"), 1, 0) diff --git a/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java index aad8275f4749..f0084f4f24e9 100644 --- a/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/IntervalQueryBuilderTests.java @@ -203,7 +203,7 @@ public class IntervalQueryBuilderTests extends AbstractQueryTestCase Date: Thu, 10 Oct 2024 08:31:00 +1100 Subject: [PATCH 16/43] Mute org.elasticsearch.xpack.inference.InferenceRestIT test {p0=inference/40_semantic_text_query/Query a field that uses the default ELSER 2 endpoint} #114376 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 5225c0016d92..72fa78b5ec6e 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -363,6 +363,9 @@ tests: - class: org.elasticsearch.xpack.inference.InferenceRestIT method: test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint} issue: https://github.com/elastic/elasticsearch/issues/114412 +- class: org.elasticsearch.xpack.inference.InferenceRestIT + method: test {p0=inference/40_semantic_text_query/Query a field that uses the default ELSER 2 endpoint} + issue: https://github.com/elastic/elasticsearch/issues/114376 # Examples: # From 67683cb38c73bb366c2331981b0d23e630440350 Mon Sep 17 00:00:00 2001 From: Pat Whelan Date: Wed, 9 Oct 2024 17:54:26 -0400 Subject: [PATCH 17/43] [ML] Stream Anthropic Completion (#114321) Enable chat completion streaming responses for Anthropic's server sent events. Co-authored-by: Elastic Machine --- docs/changelog/114321.yaml | 5 + .../anthropic/AnthropicResponseHandler.java | 25 ++- .../AnthropicStreamingProcessor.java | 125 +++++++++++++ .../AnthropicCompletionRequestManager.java | 9 +- .../AnthropicChatCompletionRequest.java | 11 +- .../AnthropicChatCompletionRequestEntity.java | 10 +- .../services/anthropic/AnthropicService.java | 6 + .../AnthropicResponseHandlerTests.java | 2 +- .../AnthropicStreamingProcessorTests.java | 170 ++++++++++++++++++ ...ropicChatCompletionRequestEntityTests.java | 6 +- .../AnthropicChatCompletionRequestTests.java | 4 +- .../anthropic/AnthropicServiceTests.java | 63 +++++++ 12 files changed, 423 insertions(+), 13 deletions(-) create mode 100644 docs/changelog/114321.yaml create mode 100644 x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessor.java create mode 100644 x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessorTests.java diff --git a/docs/changelog/114321.yaml b/docs/changelog/114321.yaml new file mode 100644 index 000000000000..286a72cfee84 --- /dev/null +++ b/docs/changelog/114321.yaml @@ -0,0 +1,5 @@ +pr: 114321 +summary: Stream Anthropic Completion +area: Machine Learning +type: enhancement +issues: [] diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandler.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandler.java index aec47f19b264..373045f879af 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandler.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandler.java @@ -9,14 +9,20 @@ package org.elasticsearch.xpack.inference.external.anthropic; import org.apache.logging.log4j.Logger; import org.elasticsearch.common.Strings; +import org.elasticsearch.inference.InferenceServiceResults; +import org.elasticsearch.xpack.core.inference.results.StreamingChatCompletionResults; import org.elasticsearch.xpack.inference.external.http.HttpResult; import org.elasticsearch.xpack.inference.external.http.retry.BaseResponseHandler; import org.elasticsearch.xpack.inference.external.http.retry.ResponseParser; import org.elasticsearch.xpack.inference.external.http.retry.RetryException; import org.elasticsearch.xpack.inference.external.request.Request; import org.elasticsearch.xpack.inference.external.response.ErrorMessageResponseEntity; +import org.elasticsearch.xpack.inference.external.response.streaming.ServerSentEventParser; +import org.elasticsearch.xpack.inference.external.response.streaming.ServerSentEventProcessor; import org.elasticsearch.xpack.inference.logging.ThrottlerManager; +import java.util.concurrent.Flow; + import static org.elasticsearch.xpack.inference.external.http.HttpUtils.checkForEmptyBody; import static org.elasticsearch.xpack.inference.external.http.retry.ResponseHandlerUtils.getFirstHeaderOrUnknown; @@ -41,8 +47,11 @@ public class AnthropicResponseHandler extends BaseResponseHandler { static final String SERVER_BUSY = "Received an Anthropic server is temporarily overloaded status code"; - public AnthropicResponseHandler(String requestType, ResponseParser parseFunction) { + private final boolean canHandleStreamingResponses; + + public AnthropicResponseHandler(String requestType, ResponseParser parseFunction, boolean canHandleStreamingResponses) { super(requestType, parseFunction, ErrorMessageResponseEntity::fromResponse); + this.canHandleStreamingResponses = canHandleStreamingResponses; } @Override @@ -52,6 +61,20 @@ public class AnthropicResponseHandler extends BaseResponseHandler { checkForEmptyBody(throttlerManager, logger, request, result); } + @Override + public boolean canHandleStreamingResponses() { + return canHandleStreamingResponses; + } + + @Override + public InferenceServiceResults parseResult(Request request, Flow.Publisher flow) { + var sseProcessor = new ServerSentEventProcessor(new ServerSentEventParser()); + var anthropicProcessor = new AnthropicStreamingProcessor(); + sseProcessor.subscribe(anthropicProcessor); + flow.subscribe(sseProcessor); + return new StreamingChatCompletionResults(anthropicProcessor); + } + /** * Validates the status code throws an RetryException if not in the range [200, 300). * diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessor.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessor.java new file mode 100644 index 000000000000..8625f5d6123c --- /dev/null +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessor.java @@ -0,0 +1,125 @@ +/* + * 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.xpack.inference.external.anthropic; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.ElasticsearchStatusException; +import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.xcontent.XContentFactory; +import org.elasticsearch.xcontent.XContentParser; +import org.elasticsearch.xcontent.XContentParserConfiguration; +import org.elasticsearch.xcontent.XContentType; +import org.elasticsearch.xpack.core.inference.results.StreamingChatCompletionResults; +import org.elasticsearch.xpack.inference.common.DelegatingProcessor; +import org.elasticsearch.xpack.inference.external.response.streaming.ServerSentEvent; +import org.elasticsearch.xpack.inference.external.response.streaming.ServerSentEventField; + +import java.io.IOException; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.Optional; + +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import static org.elasticsearch.xpack.inference.external.response.XContentUtils.moveToFirstToken; +import static org.elasticsearch.xpack.inference.external.response.XContentUtils.positionParserAtTokenAfterField; + +public class AnthropicStreamingProcessor extends DelegatingProcessor, StreamingChatCompletionResults.Results> { + private static final Logger log = LogManager.getLogger(AnthropicStreamingProcessor.class); + private static final String FAILED_TO_FIND_FIELD_TEMPLATE = "Failed to find required field [%s] in Anthropic chat completions response"; + + @Override + protected void next(Deque item) throws Exception { + if (item.isEmpty()) { + upstream().request(1); + return; + } + + var results = new ArrayDeque(item.size()); + for (var event : item) { + if (event.name() == ServerSentEventField.DATA && event.hasValue()) { + try (var parser = parser(event.value())) { + var eventType = eventType(parser); + switch (eventType) { + case "error" -> { + onError(parseError(parser)); + return; + } + case "content_block_start" -> { + parseStartBlock(parser).ifPresent(results::offer); + } + case "content_block_delta" -> { + parseMessage(parser).ifPresent(results::offer); + } + case "message_start", "message_stop", "message_delta", "content_block_stop", "ping" -> { + log.debug("Skipping event type [{}] for line [{}].", eventType, item); + } + default -> { + // "handle unknown events gracefully" https://docs.anthropic.com/en/api/messages-streaming#other-events + // we'll ignore unknown events + log.debug("Unknown event type [{}] for line [{}].", eventType, item); + } + } + } catch (Exception e) { + log.warn("Failed to parse line {}", event); + throw e; + } + } + } + + if (results.isEmpty()) { + upstream().request(1); + } else { + downstream().onNext(new StreamingChatCompletionResults.Results(results)); + } + } + + private Throwable parseError(XContentParser parser) throws IOException { + positionParserAtTokenAfterField(parser, "error", FAILED_TO_FIND_FIELD_TEMPLATE); + var type = parseString(parser, "type"); + var message = parseString(parser, "message"); + var statusCode = switch (type) { + case "invalid_request_error" -> RestStatus.BAD_REQUEST; + case "authentication_error" -> RestStatus.UNAUTHORIZED; + case "permission_error" -> RestStatus.FORBIDDEN; + case "not_found_error" -> RestStatus.NOT_FOUND; + case "request_too_large" -> RestStatus.REQUEST_ENTITY_TOO_LARGE; + case "rate_limit_error" -> RestStatus.TOO_MANY_REQUESTS; + default -> RestStatus.INTERNAL_SERVER_ERROR; + }; + return new ElasticsearchStatusException(message, statusCode); + } + + private Optional parseStartBlock(XContentParser parser) throws IOException { + positionParserAtTokenAfterField(parser, "content_block", FAILED_TO_FIND_FIELD_TEMPLATE); + var text = parseString(parser, "text"); + return text.isBlank() ? Optional.empty() : Optional.of(new StreamingChatCompletionResults.Result(text)); + } + + private Optional parseMessage(XContentParser parser) throws IOException { + positionParserAtTokenAfterField(parser, "delta", FAILED_TO_FIND_FIELD_TEMPLATE); + var text = parseString(parser, "text"); + return text.isBlank() ? Optional.empty() : Optional.of(new StreamingChatCompletionResults.Result(text)); + } + + private static XContentParser parser(String line) throws IOException { + return XContentFactory.xContent(XContentType.JSON).createParser(XContentParserConfiguration.EMPTY, line); + } + + private static String eventType(XContentParser parser) throws IOException { + moveToFirstToken(parser); + ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser); + return parseString(parser, "type"); + } + + private static String parseString(XContentParser parser, String fieldName) throws IOException { + positionParserAtTokenAfterField(parser, fieldName, FAILED_TO_FIND_FIELD_TEMPLATE); + ensureExpectedToken(XContentParser.Token.VALUE_STRING, parser.currentToken(), parser); + return parser.text(); + } +} diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/sender/AnthropicCompletionRequestManager.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/sender/AnthropicCompletionRequestManager.java index 7c527bbd2ee9..5418b3dd9840 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/sender/AnthropicCompletionRequestManager.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/http/sender/AnthropicCompletionRequestManager.java @@ -19,7 +19,6 @@ import org.elasticsearch.xpack.inference.external.request.anthropic.AnthropicCha import org.elasticsearch.xpack.inference.external.response.anthropic.AnthropicChatCompletionResponseEntity; import org.elasticsearch.xpack.inference.services.anthropic.completion.AnthropicChatCompletionModel; -import java.util.List; import java.util.Objects; import java.util.function.Supplier; @@ -47,13 +46,15 @@ public class AnthropicCompletionRequestManager extends AnthropicRequestManager { Supplier hasRequestCompletedFunction, ActionListener listener ) { - List docsInput = DocumentsOnlyInput.of(inferenceInputs).getInputs(); - AnthropicChatCompletionRequest request = new AnthropicChatCompletionRequest(docsInput, model); + var docsOnly = DocumentsOnlyInput.of(inferenceInputs); + var docsInput = docsOnly.getInputs(); + var stream = docsOnly.stream(); + AnthropicChatCompletionRequest request = new AnthropicChatCompletionRequest(docsInput, model, stream); execute(new ExecutableInferenceRequest(requestSender, logger, request, HANDLER, hasRequestCompletedFunction, listener)); } private static ResponseHandler createCompletionHandler() { - return new AnthropicResponseHandler("anthropic completions", AnthropicChatCompletionResponseEntity::fromResponse); + return new AnthropicResponseHandler("anthropic completions", AnthropicChatCompletionResponseEntity::fromResponse, true); } } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequest.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequest.java index fa6bb31d0f40..801bf5d76d68 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequest.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequest.java @@ -29,11 +29,13 @@ public class AnthropicChatCompletionRequest implements Request { private final AnthropicAccount account; private final List input; private final AnthropicChatCompletionModel model; + private final boolean stream; - public AnthropicChatCompletionRequest(List input, AnthropicChatCompletionModel model) { + public AnthropicChatCompletionRequest(List input, AnthropicChatCompletionModel model, boolean stream) { this.account = AnthropicAccount.of(model); this.input = Objects.requireNonNull(input); this.model = Objects.requireNonNull(model); + this.stream = stream; } @Override @@ -41,7 +43,7 @@ public class AnthropicChatCompletionRequest implements Request { HttpPost httpPost = new HttpPost(account.uri()); ByteArrayEntity byteEntity = new ByteArrayEntity( - Strings.toString(new AnthropicChatCompletionRequestEntity(input, model.getServiceSettings(), model.getTaskSettings())) + Strings.toString(new AnthropicChatCompletionRequestEntity(input, model.getServiceSettings(), model.getTaskSettings(), stream)) .getBytes(StandardCharsets.UTF_8) ); httpPost.setEntity(byteEntity); @@ -75,4 +77,9 @@ public class AnthropicChatCompletionRequest implements Request { return model.getInferenceEntityId(); } + @Override + public boolean isStreaming() { + return stream; + } + } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntity.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntity.java index 4186ad0a722c..b872d9be6207 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntity.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntity.java @@ -28,19 +28,23 @@ public class AnthropicChatCompletionRequestEntity implements ToXContentObject { private static final String TEMPERATURE_FIELD = "temperature"; private static final String TOP_P_FIELD = "top_p"; private static final String TOP_K_FIELD = "top_k"; + private static final String STREAM = "stream"; private final List messages; private final AnthropicChatCompletionServiceSettings serviceSettings; private final AnthropicChatCompletionTaskSettings taskSettings; + private final boolean stream; public AnthropicChatCompletionRequestEntity( List messages, AnthropicChatCompletionServiceSettings serviceSettings, - AnthropicChatCompletionTaskSettings taskSettings + AnthropicChatCompletionTaskSettings taskSettings, + boolean stream ) { this.messages = Objects.requireNonNull(messages); this.serviceSettings = Objects.requireNonNull(serviceSettings); this.taskSettings = Objects.requireNonNull(taskSettings); + this.stream = stream; } @Override @@ -77,6 +81,10 @@ public class AnthropicChatCompletionRequestEntity implements ToXContentObject { builder.field(TOP_K_FIELD, taskSettings.topK()); } + if (stream) { + builder.field(STREAM, true); + } + builder.endObject(); return builder; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java index 07c45e7c6e71..3cf4c10f7c9e 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java @@ -33,6 +33,7 @@ import org.elasticsearch.xpack.inference.services.anthropic.completion.Anthropic import java.util.List; import java.util.Map; +import java.util.Set; import static org.elasticsearch.xpack.inference.services.ServiceUtils.createInvalidModelException; import static org.elasticsearch.xpack.inference.services.ServiceUtils.parsePersistedConfigErrorMsg; @@ -199,4 +200,9 @@ public class AnthropicService extends SenderService { public TransportVersion getMinimalSupportedVersion() { return TransportVersions.ML_ANTHROPIC_INTEGRATION_ADDED; } + + @Override + public Set supportedStreamingTasks() { + return COMPLETION_ONLY; + } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandlerTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandlerTests.java index 0b9390f293ff..ca950a5f920d 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandlerTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicResponseHandlerTests.java @@ -160,7 +160,7 @@ public class AnthropicResponseHandlerTests extends ESTestCase { var mockRequest = mock(Request.class); when(mockRequest.getInferenceEntityId()).thenReturn(inferenceEntityId); var httpResult = new HttpResult(httpResponse, new byte[] {}); - var handler = new AnthropicResponseHandler("", (request, result) -> null); + var handler = new AnthropicResponseHandler("", (request, result) -> null, false); handler.checkForFailureStatusCode(mockRequest, httpResult); } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessorTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessorTests.java new file mode 100644 index 000000000000..1667dac84d2d --- /dev/null +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/anthropic/AnthropicStreamingProcessorTests.java @@ -0,0 +1,170 @@ +/* + * 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.xpack.inference.external.anthropic; + +import org.elasticsearch.ElasticsearchStatusException; +import org.elasticsearch.common.xcontent.ChunkedToXContent; +import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.xpack.core.inference.results.StreamingChatCompletionResults; +import org.elasticsearch.xpack.inference.external.response.streaming.ServerSentEvent; +import org.elasticsearch.xpack.inference.external.response.streaming.ServerSentEventField; +import org.hamcrest.Matcher; +import org.hamcrest.Matchers; + +import java.util.ArrayDeque; +import java.util.Arrays; +import java.util.Deque; +import java.util.Map; +import java.util.concurrent.Flow; +import java.util.concurrent.atomic.AtomicReference; + +import static org.elasticsearch.xpack.inference.common.DelegatingProcessorTests.onNext; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.isA; +import static org.hamcrest.Matchers.notNullValue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +public class AnthropicStreamingProcessorTests extends ESTestCase { + + public void testParseSuccess() { + var item = events(""" + { + "type": "message_start", + "message": { + "id": "a cool id", + "type": "message", + "role": "assistant", + "content": [], + "model": "claude, probably", + "stop_reason": null, + "stop_sequence": null, + "usage": { + "input_tokens": 25, + "output_tokens": 1 + } + } + }""", """ + { + "type": "content_block_start", + "index": 0, + "content_block": { + "type": "text", + "text": "" + } + }""", """ + {"type": "ping"}""", """ + {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello"}}""", """ + {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": ", World"}}""", """ + {"type": "content_block_stop", "index": 0}""", """ + {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence":null}, "usage": {"output_tokens": 4}}""", """ + {"type": "message_stop"}"""); + + var response = onNext(new AnthropicStreamingProcessor(), item); + assertThat(response.results().size(), equalTo(2)); + assertThat(response.results(), containsResults("Hello", ", World")); + } + + public void testParseWithError() { + var item = events(""" + {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello"}}""", """ + {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": ", World"}}""", """ + {"type": "error", "error": {"type": "rate_limit_error", "message": "You're going too fast, ahhhh!"}}"""); + + var statusException = onError(item); + assertThat(statusException.status(), equalTo(RestStatus.TOO_MANY_REQUESTS)); + assertThat(statusException.getMessage(), equalTo("You're going too fast, ahhhh!")); + } + + public void testErrors() { + var errors = Map.of(""" + {"type": "error", "error": {"type": "invalid_request_error", "message": "blah"}}""", RestStatus.BAD_REQUEST, """ + {"type": "error", "error": {"type": "authentication_error", "message": "blah"}}""", RestStatus.UNAUTHORIZED, """ + {"type": "error", "error": {"type": "permission_error", "message": "blah"}}""", RestStatus.FORBIDDEN, """ + {"type": "error", "error": {"type": "not_found_error", "message": "blah"}}""", RestStatus.NOT_FOUND, """ + {"type": "error", "error": {"type": "request_too_large", "message": "blah"}}""", RestStatus.REQUEST_ENTITY_TOO_LARGE, """ + {"type": "error", "error": {"type": "rate_limit_error", "message": "blah"}}""", RestStatus.TOO_MANY_REQUESTS, """ + {"type": "error", "error": {"type": "overloaded_error", "message": "blah"}}""", RestStatus.INTERNAL_SERVER_ERROR, """ + {"type": "error", "error": {"type": "some_cool_new_error", "message": "blah"}}""", RestStatus.INTERNAL_SERVER_ERROR); + errors.forEach((json, expectedStatus) -> { assertThat(onError(events(json)).status(), equalTo(expectedStatus)); }); + } + + public void testEmptyResultsRequestsMoreData() throws Exception { + var emptyDeque = new ArrayDeque(); + + var processor = new AnthropicStreamingProcessor(); + + Flow.Subscriber downstream = mock(); + processor.subscribe(downstream); + + Flow.Subscription upstream = mock(); + processor.onSubscribe(upstream); + + processor.next(emptyDeque); + + verify(upstream, times(1)).request(1); + verify(downstream, times(0)).onNext(any()); + } + + public void testDroppedEventsRequestsMoreData() throws Exception { + var item = events(""" + {"type": "ping"}"""); + + var processor = new AnthropicStreamingProcessor(); + + Flow.Subscriber downstream = mock(); + processor.subscribe(downstream); + + Flow.Subscription upstream = mock(); + processor.onSubscribe(upstream); + + processor.next(item); + + verify(upstream, times(1)).request(1); + verify(downstream, times(0)).onNext(any()); + } + + private Deque events(String... data) { + var item = new ArrayDeque(); + Arrays.stream(data).map(datum -> new ServerSentEvent(ServerSentEventField.DATA, datum)).forEach(item::offer); + return item; + } + + @SuppressWarnings("unchecked") + private Matcher> containsResults(String... results) { + Matcher[] resultMatcher = Arrays.stream(results) + .map(StreamingChatCompletionResults.Result::new) + .map(Matchers::equalTo) + .toArray(Matcher[]::new); + return Matchers.contains(resultMatcher); + } + + private static ElasticsearchStatusException onError(Deque item) { + var processor = new AnthropicStreamingProcessor(); + var response = new AtomicReference(); + + Flow.Subscription upstream = mock(); + processor.onSubscribe(upstream); + + Flow.Subscriber downstream = mock(); + doAnswer(ans -> { + response.set(ans.getArgument(0)); + return null; + }).when(downstream).onError(any()); + processor.subscribe(downstream); + + processor.onNext(item); + assertThat("Error from processor was null", response.get(), notNullValue()); + assertThat(response.get(), isA(ElasticsearchStatusException.class)); + return (ElasticsearchStatusException) response.get(); + } +} diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntityTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntityTests.java index f293a59e47d1..eeeb8b44797f 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntityTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestEntityTests.java @@ -26,7 +26,8 @@ public class AnthropicChatCompletionRequestEntityTests extends ESTestCase { var entity = new AnthropicChatCompletionRequestEntity( List.of("abc"), new AnthropicChatCompletionServiceSettings("model", null), - new AnthropicChatCompletionTaskSettings(1, -1.0, 1.2, 3) + new AnthropicChatCompletionTaskSettings(1, -1.0, 1.2, 3), + false ); XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); @@ -42,7 +43,8 @@ public class AnthropicChatCompletionRequestEntityTests extends ESTestCase { var entity = new AnthropicChatCompletionRequestEntity( List.of("abc"), new AnthropicChatCompletionServiceSettings("model", null), - new AnthropicChatCompletionTaskSettings(1, null, 1.2, 3) + new AnthropicChatCompletionTaskSettings(1, null, 1.2, 3), + false ); XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestTests.java index 0a606c522c13..6d1564f18cc6 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/anthropic/AnthropicChatCompletionRequestTests.java @@ -95,12 +95,12 @@ public class AnthropicChatCompletionRequestTests extends ESTestCase { public static AnthropicChatCompletionRequest createRequest(String apiKey, String input, String model, int maxTokens) { var chatCompletionModel = AnthropicChatCompletionModelTests.createChatCompletionModel(apiKey, model, maxTokens); - return new AnthropicChatCompletionRequest(List.of(input), chatCompletionModel); + return new AnthropicChatCompletionRequest(List.of(input), chatCompletionModel, false); } public static AnthropicChatCompletionRequest createRequest(String url, String apiKey, String input, String model, int maxTokens) { var chatCompletionModel = AnthropicChatCompletionModelTests.createChatCompletionModel(url, apiKey, model, maxTokens); - return new AnthropicChatCompletionRequest(List.of(input), chatCompletionModel); + return new AnthropicChatCompletionRequest(List.of(input), chatCompletionModel, false); } private static String buildAnthropicUri() { diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java index c502425b22ac..48277112d930 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicServiceTests.java @@ -17,6 +17,7 @@ import org.elasticsearch.inference.InferenceServiceResults; import org.elasticsearch.inference.InputType; import org.elasticsearch.inference.Model; import org.elasticsearch.inference.TaskType; +import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; @@ -29,6 +30,7 @@ import org.elasticsearch.xpack.inference.external.http.sender.HttpRequestSenderT import org.elasticsearch.xpack.inference.external.http.sender.Sender; import org.elasticsearch.xpack.inference.external.request.anthropic.AnthropicRequestUtils; import org.elasticsearch.xpack.inference.logging.ThrottlerManager; +import org.elasticsearch.xpack.inference.services.InferenceEventsAssertion; import org.elasticsearch.xpack.inference.services.ServiceFields; import org.elasticsearch.xpack.inference.services.anthropic.completion.AnthropicChatCompletionModel; import org.elasticsearch.xpack.inference.services.anthropic.completion.AnthropicChatCompletionModelTests; @@ -530,6 +532,67 @@ public class AnthropicServiceTests extends ESTestCase { } } + public void testInfer_StreamRequest() throws Exception { + String responseJson = """ + data: {"type": "message_start", "message": {"model": "claude, probably"}} + data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}} + data: {"type": "ping"} + data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello"}} + data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": ", World"}} + data: {"type": "content_block_stop", "index": 0} + data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence":null}, "usage": {"output_tokens": 4}} + data: {"type": "message_stop"} + + """; + webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); + + var result = streamChatCompletion(); + + InferenceEventsAssertion.assertThat(result).hasFinishedStream().hasNoErrors().hasEvent(""" + {"completion":[{"delta":"Hello"},{"delta":", World"}]}"""); + } + + private InferenceServiceResults streamChatCompletion() throws IOException { + var senderFactory = HttpRequestSenderTests.createSenderFactory(threadPool, clientManager); + try (var service = new AnthropicService(senderFactory, createWithEmptySettings(threadPool))) { + var model = AnthropicChatCompletionModelTests.createChatCompletionModel( + getUrl(webServer), + "secret", + "model", + Integer.MAX_VALUE + ); + var listener = new PlainActionFuture(); + service.infer( + model, + null, + List.of("abc"), + true, + new HashMap<>(), + InputType.INGEST, + InferenceAction.Request.DEFAULT_TIMEOUT, + listener + ); + + return listener.actionGet(TIMEOUT); + } + } + + public void testInfer_StreamRequest_ErrorResponse() throws Exception { + String responseJson = """ + data: {"type": "error", "error": {"type": "request_too_large", "message": "blah"}} + + """; + webServer.enqueue(new MockResponse().setResponseCode(200).setBody(responseJson)); + + var result = streamChatCompletion(); + + InferenceEventsAssertion.assertThat(result) + .hasFinishedStream() + .hasNoEvents() + .hasErrorWithStatusCode(RestStatus.REQUEST_ENTITY_TOO_LARGE.getStatus()) + .hasErrorContaining("blah"); + } + private AnthropicService createServiceWithMockSender() { return new AnthropicService(mock(HttpRequestSender.Factory.class), createWithEmptySettings(threadPool)); } From db8a2d245df6dfb4a79fecca9cf1c0ed38929b87 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 9 Oct 2024 18:02:26 -0400 Subject: [PATCH 18/43] ESQL: Delay construction of warnings (#114368) Delay construction of `Warnings` until they are needed to save memory when evaluating many many many expressions. Most expressions won't use warnings at all and there isn't any need to make registering warnings super duper fast. So let's make the construction lazy to save a little memory. It's like 200 bytes per expression which isn't much, but it's possible to have thousands of expressions in a single query. Abusive, but possible. This also consolidates all `Warnings` usages to a single `Warnings` class. We had two. We don't need two. --- docs/changelog/114368.yaml | 5 + .../xpack/esql/heap_attack/HeapAttackIT.java | 3 - x-pack/plugin/esql/build.gradle | 2 +- .../compute/gen/AggregatorImplementer.java | 8 +- .../compute/gen/EvaluatorImplementer.java | 28 +++++- .../gen/GroupingAggregatorImplementer.java | 8 +- .../compute/gen/MvEvaluatorImplementer.java | 13 ++- .../org/elasticsearch/compute/gen/Types.java | 7 +- .../{aggregation => operator}/Warnings.java | 55 ++++++++--- .../compute/operator}/WarningsTests.java | 24 +++-- .../comparison/InBooleanEvaluator.java | 26 +++-- .../comparison/InBytesRefEvaluator.java | 26 +++-- .../comparison/InDoubleEvaluator.java | 26 +++-- .../operator/comparison/InIntEvaluator.java | 26 +++-- .../operator/comparison/InLongEvaluator.java | 26 +++-- .../operator/logical/NotEvaluator.java | 22 ++++- .../grouping/CategorizeEvaluator.java | 22 ++++- .../conditional/GreatestBooleanEvaluator.java | 22 ++++- .../GreatestBytesRefEvaluator.java | 22 ++++- .../conditional/GreatestDoubleEvaluator.java | 22 ++++- .../conditional/GreatestIntEvaluator.java | 22 ++++- .../conditional/GreatestLongEvaluator.java | 22 ++++- .../conditional/LeastBooleanEvaluator.java | 22 ++++- .../conditional/LeastBytesRefEvaluator.java | 22 ++++- .../conditional/LeastDoubleEvaluator.java | 22 ++++- .../scalar/conditional/LeastIntEvaluator.java | 22 ++++- .../conditional/LeastLongEvaluator.java | 22 ++++- .../scalar/convert/FromBase64Evaluator.java | 22 ++++- .../scalar/convert/ToBase64Evaluator.java | 26 +++-- .../date/DateDiffConstantEvaluator.java | 28 ++++-- .../scalar/date/DateDiffEvaluator.java | 30 ++++-- .../date/DateExtractConstantEvaluator.java | 22 ++++- .../scalar/date/DateExtractEvaluator.java | 28 ++++-- .../date/DateFormatConstantEvaluator.java | 22 ++++- .../scalar/date/DateFormatEvaluator.java | 24 ++++- .../date/DateParseConstantEvaluator.java | 26 +++-- .../scalar/date/DateParseEvaluator.java | 28 ++++-- .../scalar/date/DateTruncEvaluator.java | 22 ++++- .../function/scalar/date/NowEvaluator.java | 20 +++- .../scalar/ip/CIDRMatchEvaluator.java | 24 ++++- .../function/scalar/ip/IpPrefixEvaluator.java | 30 ++++-- .../scalar/math/AbsDoubleEvaluator.java | 22 ++++- .../function/scalar/math/AbsIntEvaluator.java | 22 ++++- .../scalar/math/AbsLongEvaluator.java | 22 ++++- .../function/scalar/math/AcosEvaluator.java | 26 +++-- .../function/scalar/math/AsinEvaluator.java | 26 +++-- .../function/scalar/math/Atan2Evaluator.java | 24 ++++- .../function/scalar/math/AtanEvaluator.java | 22 ++++- .../scalar/math/CastIntToDoubleEvaluator.java | 22 ++++- .../scalar/math/CastIntToLongEvaluator.java | 22 ++++- .../math/CastIntToUnsignedLongEvaluator.java | 22 ++++- .../math/CastLongToDoubleEvaluator.java | 22 ++++- .../math/CastLongToUnsignedLongEvaluator.java | 22 ++++- .../CastUnsignedLongToDoubleEvaluator.java | 22 ++++- .../scalar/math/CbrtDoubleEvaluator.java | 26 +++-- .../scalar/math/CbrtIntEvaluator.java | 26 +++-- .../scalar/math/CbrtLongEvaluator.java | 26 +++-- .../math/CbrtUnsignedLongEvaluator.java | 22 ++++- .../scalar/math/CeilDoubleEvaluator.java | 22 ++++- .../function/scalar/math/CosEvaluator.java | 22 ++++- .../function/scalar/math/CoshEvaluator.java | 26 +++-- .../scalar/math/ExpDoubleEvaluator.java | 22 ++++- .../function/scalar/math/ExpIntEvaluator.java | 22 ++++- .../scalar/math/ExpLongEvaluator.java | 22 ++++- .../scalar/math/ExpUnsignedLongEvaluator.java | 22 ++++- .../scalar/math/FloorDoubleEvaluator.java | 22 ++++- .../scalar/math/Log10DoubleEvaluator.java | 26 +++-- .../scalar/math/Log10IntEvaluator.java | 26 +++-- .../scalar/math/Log10LongEvaluator.java | 26 +++-- .../math/Log10UnsignedLongEvaluator.java | 26 +++-- .../scalar/math/LogConstantEvaluator.java | 26 +++-- .../function/scalar/math/LogEvaluator.java | 28 ++++-- .../function/scalar/math/PowEvaluator.java | 28 ++++-- .../scalar/math/RoundDoubleEvaluator.java | 24 ++++- .../math/RoundDoubleNoDecimalsEvaluator.java | 22 ++++- .../scalar/math/RoundIntEvaluator.java | 24 ++++- .../scalar/math/RoundLongEvaluator.java | 24 ++++- .../math/RoundUnsignedLongEvaluator.java | 24 ++++- .../scalar/math/SignumDoubleEvaluator.java | 22 ++++- .../scalar/math/SignumIntEvaluator.java | 22 ++++- .../scalar/math/SignumLongEvaluator.java | 22 ++++- .../math/SignumUnsignedLongEvaluator.java | 22 ++++- .../function/scalar/math/SinEvaluator.java | 22 ++++- .../function/scalar/math/SinhEvaluator.java | 26 +++-- .../scalar/math/SqrtDoubleEvaluator.java | 26 +++-- .../scalar/math/SqrtIntEvaluator.java | 26 +++-- .../scalar/math/SqrtLongEvaluator.java | 26 +++-- .../math/SqrtUnsignedLongEvaluator.java | 22 ++++- .../function/scalar/math/TanEvaluator.java | 22 ++++- .../function/scalar/math/TanhEvaluator.java | 22 ++++- .../multivalue/MvAppendBooleanEvaluator.java | 20 +++- .../multivalue/MvAppendBytesRefEvaluator.java | 20 +++- .../multivalue/MvAppendDoubleEvaluator.java | 20 +++- .../multivalue/MvAppendIntEvaluator.java | 20 +++- .../multivalue/MvAppendLongEvaluator.java | 20 +++- .../MvPSeriesWeightedSumDoubleEvaluator.java | 22 ++++- .../MvPercentileDoubleEvaluator.java | 24 ++++- .../MvPercentileIntegerEvaluator.java | 24 ++++- .../multivalue/MvPercentileLongEvaluator.java | 24 ++++- .../multivalue/MvSliceBooleanEvaluator.java | 26 +++-- .../multivalue/MvSliceBytesRefEvaluator.java | 26 +++-- .../multivalue/MvSliceDoubleEvaluator.java | 26 +++-- .../multivalue/MvSliceIntEvaluator.java | 26 +++-- .../multivalue/MvSliceLongEvaluator.java | 26 +++-- .../scalar/multivalue/MvSumIntEvaluator.java | 22 ++++- .../scalar/multivalue/MvSumLongEvaluator.java | 22 ++++- .../MvSumUnsignedLongEvaluator.java | 22 ++++- .../scalar/multivalue/MvZipEvaluator.java | 22 ++++- ...ianPointDocValuesAndConstantEvaluator.java | 22 ++++- ...esianPointDocValuesAndSourceEvaluator.java | 22 ++++- ...nsCartesianSourceAndConstantEvaluator.java | 22 ++++- ...ainsCartesianSourceAndSourceEvaluator.java | 22 ++++- ...GeoPointDocValuesAndConstantEvaluator.java | 22 ++++- ...nsGeoPointDocValuesAndSourceEvaluator.java | 22 ++++- ...ContainsGeoSourceAndConstantEvaluator.java | 22 ++++- ...alContainsGeoSourceAndSourceEvaluator.java | 22 ++++- ...ianPointDocValuesAndConstantEvaluator.java | 22 ++++- ...esianPointDocValuesAndSourceEvaluator.java | 22 ++++- ...ntCartesianSourceAndConstantEvaluator.java | 22 ++++- ...ointCartesianSourceAndSourceEvaluator.java | 22 ++++- ...GeoPointDocValuesAndConstantEvaluator.java | 22 ++++- ...ntGeoPointDocValuesAndSourceEvaluator.java | 22 ++++- ...DisjointGeoSourceAndConstantEvaluator.java | 22 ++++- ...alDisjointGeoSourceAndSourceEvaluator.java | 22 ++++- ...ianPointDocValuesAndConstantEvaluator.java | 22 ++++- ...esianPointDocValuesAndSourceEvaluator.java | 22 ++++- ...tsCartesianSourceAndConstantEvaluator.java | 22 ++++- ...ectsCartesianSourceAndSourceEvaluator.java | 22 ++++- ...GeoPointDocValuesAndConstantEvaluator.java | 22 ++++- ...tsGeoPointDocValuesAndSourceEvaluator.java | 22 ++++- ...tersectsGeoSourceAndConstantEvaluator.java | 22 ++++- ...IntersectsGeoSourceAndSourceEvaluator.java | 22 ++++- ...ianPointDocValuesAndConstantEvaluator.java | 22 ++++- ...esianPointDocValuesAndSourceEvaluator.java | 22 ++++- ...inCartesianSourceAndConstantEvaluator.java | 22 ++++- ...thinCartesianSourceAndSourceEvaluator.java | 22 ++++- ...GeoPointDocValuesAndConstantEvaluator.java | 22 ++++- ...inGeoPointDocValuesAndSourceEvaluator.java | 22 ++++- ...alWithinGeoSourceAndConstantEvaluator.java | 22 ++++- ...tialWithinGeoSourceAndSourceEvaluator.java | 22 ++++- ...ianPointDocValuesAndConstantEvaluator.java | 26 +++-- ...esianPointDocValuesAndSourceEvaluator.java | 24 ++++- ...ceCartesianSourceAndConstantEvaluator.java | 26 +++-- ...anceCartesianSourceAndSourceEvaluator.java | 28 ++++-- ...GeoPointDocValuesAndConstantEvaluator.java | 26 +++-- ...ceGeoPointDocValuesAndSourceEvaluator.java | 28 ++++-- ...DistanceGeoSourceAndConstantEvaluator.java | 26 +++-- ...StDistanceGeoSourceAndSourceEvaluator.java | 28 ++++-- .../scalar/string/AutomataMatchEvaluator.java | 22 ++++- .../scalar/string/ConcatEvaluator.java | 22 ++++- .../scalar/string/EndsWithEvaluator.java | 24 ++++- .../scalar/string/LTrimEvaluator.java | 22 ++++- .../function/scalar/string/LeftEvaluator.java | 24 ++++- .../scalar/string/LengthEvaluator.java | 22 ++++- .../scalar/string/LocateEvaluator.java | 26 +++-- .../scalar/string/LocateNoStartEvaluator.java | 24 ++++- .../scalar/string/RTrimEvaluator.java | 22 ++++- .../string/RepeatConstantEvaluator.java | 26 +++-- .../scalar/string/RepeatEvaluator.java | 28 ++++-- .../string/ReplaceConstantEvaluator.java | 28 ++++-- .../scalar/string/ReplaceEvaluator.java | 30 ++++-- .../scalar/string/ReverseEvaluator.java | 22 ++++- .../scalar/string/RightEvaluator.java | 24 ++++- .../scalar/string/SpaceEvaluator.java | 26 +++-- .../string/SplitSingleByteEvaluator.java | 22 ++++- .../scalar/string/SplitVariableEvaluator.java | 24 ++++- .../scalar/string/StartsWithEvaluator.java | 24 ++++- .../scalar/string/SubstringEvaluator.java | 26 +++-- .../string/SubstringNoLengthEvaluator.java | 24 ++++- .../scalar/string/ToLowerEvaluator.java | 22 ++++- .../scalar/string/ToUpperEvaluator.java | 22 ++++- .../function/scalar/string/TrimEvaluator.java | 22 ++++- .../arithmetic/AddDatetimesEvaluator.java | 26 +++-- .../arithmetic/AddDoublesEvaluator.java | 28 ++++-- .../operator/arithmetic/AddIntsEvaluator.java | 28 ++++-- .../arithmetic/AddLongsEvaluator.java | 28 ++++-- .../arithmetic/AddUnsignedLongsEvaluator.java | 28 ++++-- .../arithmetic/DivDoublesEvaluator.java | 28 ++++-- .../operator/arithmetic/DivIntsEvaluator.java | 28 ++++-- .../arithmetic/DivLongsEvaluator.java | 28 ++++-- .../arithmetic/DivUnsignedLongsEvaluator.java | 28 ++++-- .../arithmetic/ModDoublesEvaluator.java | 28 ++++-- .../operator/arithmetic/ModIntsEvaluator.java | 28 ++++-- .../arithmetic/ModLongsEvaluator.java | 28 ++++-- .../arithmetic/ModUnsignedLongsEvaluator.java | 28 ++++-- .../arithmetic/MulDoublesEvaluator.java | 28 ++++-- .../operator/arithmetic/MulIntsEvaluator.java | 28 ++++-- .../arithmetic/MulLongsEvaluator.java | 28 ++++-- .../arithmetic/MulUnsignedLongsEvaluator.java | 28 ++++-- .../arithmetic/NegDoublesEvaluator.java | 22 ++++- .../operator/arithmetic/NegIntsEvaluator.java | 26 +++-- .../arithmetic/NegLongsEvaluator.java | 26 +++-- .../arithmetic/SubDatetimesEvaluator.java | 26 +++-- .../arithmetic/SubDoublesEvaluator.java | 28 ++++-- .../operator/arithmetic/SubIntsEvaluator.java | 28 ++++-- .../arithmetic/SubLongsEvaluator.java | 28 ++++-- .../arithmetic/SubUnsignedLongsEvaluator.java | 28 ++++-- .../comparison/EqualsBoolsEvaluator.java | 24 ++++- .../comparison/EqualsDoublesEvaluator.java | 24 ++++- .../comparison/EqualsGeometriesEvaluator.java | 24 ++++- .../comparison/EqualsIntsEvaluator.java | 24 ++++- .../comparison/EqualsKeywordsEvaluator.java | 24 ++++- .../comparison/EqualsLongsEvaluator.java | 24 ++++- .../GreaterThanDoublesEvaluator.java | 24 ++++- .../comparison/GreaterThanIntsEvaluator.java | 24 ++++- .../GreaterThanKeywordsEvaluator.java | 24 ++++- .../comparison/GreaterThanLongsEvaluator.java | 24 ++++- .../GreaterThanOrEqualDoublesEvaluator.java | 24 ++++- .../GreaterThanOrEqualIntsEvaluator.java | 24 ++++- .../GreaterThanOrEqualKeywordsEvaluator.java | 24 ++++- .../GreaterThanOrEqualLongsEvaluator.java | 24 ++++- .../InsensitiveEqualsConstantEvaluator.java | 22 ++++- .../InsensitiveEqualsEvaluator.java | 24 ++++- .../comparison/LessThanDoublesEvaluator.java | 24 ++++- .../comparison/LessThanIntsEvaluator.java | 24 ++++- .../comparison/LessThanKeywordsEvaluator.java | 24 ++++- .../comparison/LessThanLongsEvaluator.java | 24 ++++- .../LessThanOrEqualDoublesEvaluator.java | 24 ++++- .../LessThanOrEqualIntsEvaluator.java | 24 ++++- .../LessThanOrEqualKeywordsEvaluator.java | 24 ++++- .../LessThanOrEqualLongsEvaluator.java | 24 ++++- .../comparison/NotEqualsBoolsEvaluator.java | 24 ++++- .../comparison/NotEqualsDoublesEvaluator.java | 24 ++++- .../NotEqualsGeometriesEvaluator.java | 24 ++++- .../comparison/NotEqualsIntsEvaluator.java | 24 ++++- .../NotEqualsKeywordsEvaluator.java | 24 ++++- .../comparison/NotEqualsLongsEvaluator.java | 24 ++++- .../esql/expression/function/Warnings.java | 96 ------------------- .../function/scalar/conditional/Case.java | 9 +- .../convert/AbstractConvertFunction.java | 9 +- ...valuator.java.st => X-InEvaluator.java.st} | 26 +++-- .../xpack/esql/package-info.java | 2 +- .../querydsl/query/SingleValueMatchQuery.java | 2 +- .../esql/querydsl/query/SingleValueQuery.java | 10 +- .../query/SingleValueMathQueryTests.java | 12 +-- 235 files changed, 4278 insertions(+), 1257 deletions(-) create mode 100644 docs/changelog/114368.yaml rename x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/{aggregation => operator}/Warnings.java (60%) rename x-pack/plugin/esql/{src/test/java/org/elasticsearch/xpack/esql/expression/function => compute/src/test/java/org/elasticsearch/compute/operator}/WarningsTests.java (53%) delete mode 100644 x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java rename x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/{InEvaluator.java.st => X-InEvaluator.java.st} (92%) diff --git a/docs/changelog/114368.yaml b/docs/changelog/114368.yaml new file mode 100644 index 000000000000..6c6e215a1bd4 --- /dev/null +++ b/docs/changelog/114368.yaml @@ -0,0 +1,5 @@ +pr: 114368 +summary: "ESQL: Delay construction of warnings" +area: EQL +type: enhancement +issues: [] diff --git a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java index 38b3dd4bd7e3..f50fe16c500d 100644 --- a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java +++ b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java @@ -409,9 +409,6 @@ public class HeapAttackIT extends ESRestTestCase { TimeValue elapsed = TimeValue.timeValueNanos(System.nanoTime() - startedTimeInNanos); logger.info("--> test {} triggering OOM after {}", getTestName(), elapsed); Request triggerOOM = new Request("POST", "/_trigger_out_of_memory"); - RequestConfig requestConfig = RequestConfig.custom() - .setSocketTimeout(Math.toIntExact(TimeValue.timeValueMinutes(2).millis())) - .build(); client().performRequest(triggerOOM); } }, TimeValue.timeValueMinutes(5), testThreadPool.executor(ThreadPool.Names.GENERIC)); diff --git a/x-pack/plugin/esql/build.gradle b/x-pack/plugin/esql/build.gradle index 0225664918b7..c8d704cd2b8b 100644 --- a/x-pack/plugin/esql/build.gradle +++ b/x-pack/plugin/esql/build.gradle @@ -317,7 +317,7 @@ tasks.named('stringTemplates').configure { } - File inInputFile = file("src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InEvaluator.java.st") + File inInputFile = file("src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/X-InEvaluator.java.st") template { it.properties = booleanProperties it.inputFile = inInputFile diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java index fe9576672cc2..4aee9ea517d8 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java @@ -45,7 +45,6 @@ import static org.elasticsearch.compute.gen.Types.BOOLEAN_VECTOR; import static org.elasticsearch.compute.gen.Types.BYTES_REF; import static org.elasticsearch.compute.gen.Types.BYTES_REF_BLOCK; import static org.elasticsearch.compute.gen.Types.BYTES_REF_VECTOR; -import static org.elasticsearch.compute.gen.Types.COMPUTE_WARNINGS; import static org.elasticsearch.compute.gen.Types.DOUBLE_BLOCK; import static org.elasticsearch.compute.gen.Types.DOUBLE_VECTOR; import static org.elasticsearch.compute.gen.Types.DRIVER_CONTEXT; @@ -60,6 +59,7 @@ import static org.elasticsearch.compute.gen.Types.LIST_INTEGER; import static org.elasticsearch.compute.gen.Types.LONG_BLOCK; import static org.elasticsearch.compute.gen.Types.LONG_VECTOR; import static org.elasticsearch.compute.gen.Types.PAGE; +import static org.elasticsearch.compute.gen.Types.WARNINGS; import static org.elasticsearch.compute.gen.Types.blockType; import static org.elasticsearch.compute.gen.Types.vectorType; @@ -224,7 +224,7 @@ public class AggregatorImplementer { ); if (warnExceptions.isEmpty() == false) { - builder.addField(COMPUTE_WARNINGS, "warnings", Modifier.PRIVATE, Modifier.FINAL); + builder.addField(WARNINGS, "warnings", Modifier.PRIVATE, Modifier.FINAL); } builder.addField(DRIVER_CONTEXT, "driverContext", Modifier.PRIVATE, Modifier.FINAL); @@ -256,7 +256,7 @@ public class AggregatorImplementer { MethodSpec.Builder builder = MethodSpec.methodBuilder("create"); builder.addModifiers(Modifier.PUBLIC, Modifier.STATIC).returns(implementation); if (warnExceptions.isEmpty() == false) { - builder.addParameter(COMPUTE_WARNINGS, "warnings"); + builder.addParameter(WARNINGS, "warnings"); } builder.addParameter(DRIVER_CONTEXT, "driverContext"); builder.addParameter(LIST_INTEGER, "channels"); @@ -312,7 +312,7 @@ public class AggregatorImplementer { private MethodSpec ctor() { MethodSpec.Builder builder = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC); if (warnExceptions.isEmpty() == false) { - builder.addParameter(COMPUTE_WARNINGS, "warnings"); + builder.addParameter(WARNINGS, "warnings"); } builder.addParameter(DRIVER_CONTEXT, "driverContext"); builder.addParameter(LIST_INTEGER, "channels"); diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorImplementer.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorImplementer.java index 629a45574ebb..5869eff23a9a 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorImplementer.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorImplementer.java @@ -97,10 +97,12 @@ public class EvaluatorImplementer { builder.addSuperinterface(EXPRESSION_EVALUATOR); builder.addType(factory()); - builder.addField(WARNINGS, "warnings", Modifier.PRIVATE, Modifier.FINAL); + builder.addField(SOURCE, "source", Modifier.PRIVATE, Modifier.FINAL); processFunction.args.stream().forEach(a -> a.declareField(builder)); builder.addField(DRIVER_CONTEXT, "driverContext", Modifier.PRIVATE, Modifier.FINAL); + builder.addField(WARNINGS, "warnings", Modifier.PRIVATE); + builder.addMethod(ctor()); builder.addMethod(eval()); @@ -116,17 +118,17 @@ public class EvaluatorImplementer { } builder.addMethod(toStringMethod()); builder.addMethod(close()); + builder.addMethod(warnings()); return builder.build(); } private MethodSpec ctor() { MethodSpec.Builder builder = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC); builder.addParameter(SOURCE, "source"); + builder.addStatement("this.source = source"); processFunction.args.stream().forEach(a -> a.implementCtor(builder)); - builder.addParameter(DRIVER_CONTEXT, "driverContext"); builder.addStatement("this.driverContext = driverContext"); - builder.addStatement("this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source)"); return builder.build(); } @@ -250,7 +252,7 @@ public class EvaluatorImplementer { + processFunction.warnExceptions.stream().map(m -> "$T").collect(Collectors.joining(" | ")) + " e)"; builder.nextControlFlow(catchPattern, processFunction.warnExceptions.stream().map(m -> TypeName.get(m)).toArray()); - builder.addStatement("warnings.registerException(e)"); + builder.addStatement("warnings().registerException(e)"); builder.addStatement("result.appendNull()"); builder.endControlFlow(); } @@ -276,7 +278,7 @@ public class EvaluatorImplementer { { builder.addStatement( // TODO: reflection on SingleValueQuery.MULTI_VALUE_WARNING? - "warnings.registerException(new $T(\"single-value function encountered multi-value\"))", + "warnings().registerException(new $T(\"single-value function encountered multi-value\"))", IllegalArgumentException.class ); } @@ -316,6 +318,22 @@ public class EvaluatorImplementer { return builder.build(); } + static MethodSpec warnings() { + MethodSpec.Builder builder = MethodSpec.methodBuilder("warnings"); + builder.addModifiers(Modifier.PRIVATE).returns(WARNINGS); + builder.beginControlFlow("if (warnings == null)"); + builder.addStatement(""" + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + )"""); + builder.endControlFlow(); + builder.addStatement("return warnings"); + return builder.build(); + } + private TypeSpec factory() { TypeSpec.Builder builder = TypeSpec.classBuilder("Factory"); builder.addSuperinterface(EXPRESSION_EVALUATOR_FACTORY); diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/GroupingAggregatorImplementer.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/GroupingAggregatorImplementer.java index 23240bbd50ea..9e8112e10f87 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/GroupingAggregatorImplementer.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/GroupingAggregatorImplementer.java @@ -40,7 +40,6 @@ import static org.elasticsearch.compute.gen.Methods.vectorAccessorName; import static org.elasticsearch.compute.gen.Types.BIG_ARRAYS; import static org.elasticsearch.compute.gen.Types.BLOCK_ARRAY; import static org.elasticsearch.compute.gen.Types.BYTES_REF; -import static org.elasticsearch.compute.gen.Types.COMPUTE_WARNINGS; import static org.elasticsearch.compute.gen.Types.DRIVER_CONTEXT; import static org.elasticsearch.compute.gen.Types.ELEMENT_TYPE; import static org.elasticsearch.compute.gen.Types.GROUPING_AGGREGATOR_FUNCTION; @@ -54,6 +53,7 @@ import static org.elasticsearch.compute.gen.Types.LONG_BLOCK; import static org.elasticsearch.compute.gen.Types.LONG_VECTOR; import static org.elasticsearch.compute.gen.Types.PAGE; import static org.elasticsearch.compute.gen.Types.SEEN_GROUP_IDS; +import static org.elasticsearch.compute.gen.Types.WARNINGS; /** * Implements "GroupingAggregationFunction" from a class containing static methods @@ -164,7 +164,7 @@ public class GroupingAggregatorImplementer { ); builder.addField(stateType, "state", Modifier.PRIVATE, Modifier.FINAL); if (warnExceptions.isEmpty() == false) { - builder.addField(COMPUTE_WARNINGS, "warnings", Modifier.PRIVATE, Modifier.FINAL); + builder.addField(WARNINGS, "warnings", Modifier.PRIVATE, Modifier.FINAL); } builder.addField(LIST_INTEGER, "channels", Modifier.PRIVATE, Modifier.FINAL); builder.addField(DRIVER_CONTEXT, "driverContext", Modifier.PRIVATE, Modifier.FINAL); @@ -196,7 +196,7 @@ public class GroupingAggregatorImplementer { MethodSpec.Builder builder = MethodSpec.methodBuilder("create"); builder.addModifiers(Modifier.PUBLIC, Modifier.STATIC).returns(implementation); if (warnExceptions.isEmpty() == false) { - builder.addParameter(COMPUTE_WARNINGS, "warnings"); + builder.addParameter(WARNINGS, "warnings"); } builder.addParameter(LIST_INTEGER, "channels"); builder.addParameter(DRIVER_CONTEXT, "driverContext"); @@ -258,7 +258,7 @@ public class GroupingAggregatorImplementer { private MethodSpec ctor() { MethodSpec.Builder builder = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC); if (warnExceptions.isEmpty() == false) { - builder.addParameter(COMPUTE_WARNINGS, "warnings"); + builder.addParameter(WARNINGS, "warnings"); } builder.addParameter(LIST_INTEGER, "channels"); builder.addParameter(stateType, "state"); diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/MvEvaluatorImplementer.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/MvEvaluatorImplementer.java index d6e062facdbf..30ca69b1651d 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/MvEvaluatorImplementer.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/MvEvaluatorImplementer.java @@ -134,8 +134,8 @@ public class MvEvaluatorImplementer { builder.superclass(ABSTRACT_MULTIVALUE_FUNCTION_EVALUATOR); } else { builder.superclass(ABSTRACT_NULLABLE_MULTIVALUE_FUNCTION_EVALUATOR); - - builder.addField(WARNINGS, "warnings", Modifier.PRIVATE, Modifier.FINAL); + builder.addField(SOURCE, "source", Modifier.PRIVATE, Modifier.FINAL); + builder.addField(WARNINGS, "warnings", Modifier.PRIVATE); } builder.addMethod(ctor()); @@ -156,6 +156,9 @@ public class MvEvaluatorImplementer { } builder.addType(factory()); + if (warnExceptions.isEmpty() == false) { + builder.addMethod(EvaluatorImplementer.warnings()); + } return builder.build(); } @@ -165,10 +168,10 @@ public class MvEvaluatorImplementer { builder.addParameter(SOURCE, "source"); } builder.addParameter(EXPRESSION_EVALUATOR, "field"); - builder.addStatement("super(driverContext, field)"); builder.addParameter(DRIVER_CONTEXT, "driverContext"); + builder.addStatement("super(driverContext, field)"); if (warnExceptions.isEmpty() == false) { - builder.addStatement("this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source)"); + builder.addStatement("this.source = source"); } return builder.build(); } @@ -241,7 +244,7 @@ public class MvEvaluatorImplementer { body.accept(builder); String catchPattern = "catch (" + warnExceptions.stream().map(m -> "$T").collect(Collectors.joining(" | ")) + " e)"; builder.nextControlFlow(catchPattern, warnExceptions.stream().map(TypeName::get).toArray()); - builder.addStatement("warnings.registerException(e)"); + builder.addStatement("warnings().registerException(e)"); builder.addStatement("builder.appendNull()"); builder.endControlFlow(); } else { diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/Types.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/Types.java index 096d0b86e6cf..8b01d957f3bd 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/Types.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/Types.java @@ -129,12 +129,7 @@ public class Types { "AbstractEvaluator" ); - static final ClassName WARNINGS = ClassName.get("org.elasticsearch.xpack.esql.expression.function", "Warnings"); - /** - * Warnings class used in compute module. - * It uses no external dependencies (Like Warnings and Source). - */ - static final ClassName COMPUTE_WARNINGS = ClassName.get("org.elasticsearch.compute.aggregation", "Warnings"); + static final ClassName WARNINGS = ClassName.get("org.elasticsearch.compute.operator", "Warnings"); static final ClassName SOURCE = ClassName.get("org.elasticsearch.xpack.esql.core.tree", "Source"); diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/Warnings.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/Warnings.java similarity index 60% rename from x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/Warnings.java rename to x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/Warnings.java index eb2255a4e349..ec697219563a 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/Warnings.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/Warnings.java @@ -5,9 +5,7 @@ * 2.0. */ -package org.elasticsearch.compute.aggregation; - -import org.elasticsearch.compute.operator.DriverContext; +package org.elasticsearch.compute.operator; import static org.elasticsearch.common.logging.HeaderWarning.addWarning; import static org.elasticsearch.common.logging.LoggerMessageFormat.format; @@ -18,12 +16,7 @@ import static org.elasticsearch.common.logging.LoggerMessageFormat.format; public class Warnings { static final int MAX_ADDED_WARNINGS = 20; - private final String location; - private final String first; - - private int addedWarnings; - - public static final Warnings NOOP_WARNINGS = new Warnings(-1, -2, "") { + public static final Warnings NOOP_WARNINGS = new Warnings(-1, -2, "", "") { @Override public void registerException(Exception exception) { // this space intentionally left blank @@ -39,9 +32,37 @@ public class Warnings { * @return A warnings collector object */ public static Warnings createWarnings(DriverContext.WarningsMode warningsMode, int lineNumber, int columnNumber, String sourceText) { + return createWarnings(warningsMode, lineNumber, columnNumber, sourceText, "treating result as null"); + } + + /** + * Create a new warnings object based on the given mode which warns that + * it treats the result as {@code false}. + * @param warningsMode The warnings collection strategy to use + * @param lineNumber The line number of the source text. Same as `source.getLineNumber()` + * @param columnNumber The column number of the source text. Same as `source.getColumnNumber()` + * @param sourceText The source text that caused the warning. Same as `source.text()` + * @return A warnings collector object + */ + public static Warnings createWarningsTreatedAsFalse( + DriverContext.WarningsMode warningsMode, + int lineNumber, + int columnNumber, + String sourceText + ) { + return createWarnings(warningsMode, lineNumber, columnNumber, sourceText, "treating result as false"); + } + + private static Warnings createWarnings( + DriverContext.WarningsMode warningsMode, + int lineNumber, + int columnNumber, + String sourceText, + String first + ) { switch (warningsMode) { case COLLECT -> { - return new Warnings(lineNumber, columnNumber, sourceText); + return new Warnings(lineNumber, columnNumber, sourceText, first); } case IGNORE -> { return NOOP_WARNINGS; @@ -50,13 +71,19 @@ public class Warnings { throw new IllegalStateException("Unreachable"); } - public Warnings(int lineNumber, int columnNumber, String sourceText) { - location = format("Line {}:{}: ", lineNumber, columnNumber); - first = format( + private final String location; + private final String first; + + private int addedWarnings; + + private Warnings(int lineNumber, int columnNumber, String sourceText, String first) { + this.location = format("Line {}:{}: ", lineNumber, columnNumber); + this.first = format( null, - "{}evaluation of [{}] failed, treating result as null. Only first {} failures recorded.", + "{}evaluation of [{}] failed, {}. Only first {} failures recorded.", location, sourceText, + first, MAX_ADDED_WARNINGS ); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/WarningsTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/WarningsTests.java similarity index 53% rename from x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/WarningsTests.java rename to x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/WarningsTests.java index 5c3e595e46d7..f62bbd509125 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/WarningsTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/WarningsTests.java @@ -5,33 +5,37 @@ * 2.0. */ -package org.elasticsearch.xpack.esql.expression.function; +package org.elasticsearch.compute.operator; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.xpack.esql.core.tree.Source; public class WarningsTests extends ESTestCase { - public void testRegister() { - Warnings warnings = new Warnings(new Source(1, 1, "foo")); + public void testRegisterCollect() { + Warnings warnings = Warnings.createWarnings(DriverContext.WarningsMode.COLLECT, 1, 1, "foo"); warnings.registerException(new IllegalArgumentException()); assertCriticalWarnings( - "Line 1:2: evaluation of [foo] failed, treating result as null. Only first 20 failures recorded.", - "Line 1:2: java.lang.IllegalArgumentException: null" + "Line 1:1: evaluation of [foo] failed, treating result as null. Only first 20 failures recorded.", + "Line 1:1: java.lang.IllegalArgumentException: null" ); } - public void testRegisterFilled() { - Warnings warnings = new Warnings(new Source(1, 1, "foo")); + public void testRegisterCollectFilled() { + Warnings warnings = Warnings.createWarnings(DriverContext.WarningsMode.COLLECT, 1, 1, "foo"); for (int i = 0; i < Warnings.MAX_ADDED_WARNINGS + 1000; i++) { warnings.registerException(new IllegalArgumentException(Integer.toString(i))); } String[] expected = new String[21]; - expected[0] = "Line 1:2: evaluation of [foo] failed, treating result as null. Only first 20 failures recorded."; + expected[0] = "Line 1:1: evaluation of [foo] failed, treating result as null. Only first 20 failures recorded."; for (int i = 0; i < Warnings.MAX_ADDED_WARNINGS; i++) { - expected[i + 1] = "Line 1:2: java.lang.IllegalArgumentException: " + i; + expected[i + 1] = "Line 1:1: java.lang.IllegalArgumentException: " + i; } assertCriticalWarnings(expected); } + + public void testRegisterIgnore() { + Warnings warnings = Warnings.createWarnings(DriverContext.WarningsMode.IGNORE, 1, 1, "foo"); + warnings.registerException(new IllegalArgumentException()); + } } diff --git a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBooleanEvaluator.java b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBooleanEvaluator.java index ad5a79f8f217..a49c191b90fa 100644 --- a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBooleanEvaluator.java @@ -13,20 +13,20 @@ import org.elasticsearch.compute.data.BooleanVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.util.Arrays; import java.util.BitSet; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link In}. - * This class is generated. Edit {@code InEvaluator.java.st} instead. + * This class is generated. Edit {@code X-InEvaluator.java.st} instead. */ public class InBooleanEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -34,16 +34,18 @@ public class InBooleanEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public InBooleanEvaluator( Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator[] rhs, DriverContext driverContext ) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -84,7 +86,7 @@ public class InBooleanEvaluator implements EvalOperator.ExpressionEvaluator { } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue; @@ -101,7 +103,7 @@ public class InBooleanEvaluator implements EvalOperator.ExpressionEvaluator { } if (rhsBlocks[i].getValueCount(p) > 1) { mvs.set(i); - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); continue; } if (hasTrue && hasFalse) { @@ -167,6 +169,18 @@ public class InBooleanEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(lhs, () -> Releasables.close(rhs)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; private final EvalOperator.ExpressionEvaluator.Factory lhs; diff --git a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBytesRefEvaluator.java b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBytesRefEvaluator.java index f47a6e9cc569..15703773ca15 100644 --- a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBytesRefEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InBytesRefEvaluator.java @@ -15,20 +15,20 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.util.Arrays; import java.util.BitSet; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link In}. - * This class is generated. Edit {@code InEvaluator.java.st} instead. + * This class is generated. Edit {@code X-InEvaluator.java.st} instead. */ public class InBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -36,16 +36,18 @@ public class InBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public InBytesRefEvaluator( Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator[] rhs, DriverContext driverContext ) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -90,7 +92,7 @@ public class InBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue; @@ -105,7 +107,7 @@ public class InBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { } if (rhsBlocks[i].getValueCount(p) > 1) { mvs.set(i); - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); continue; } int o = rhsBlocks[i].getFirstValueIndex(p); @@ -159,6 +161,18 @@ public class InBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(lhs, () -> Releasables.close(rhs)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; private final EvalOperator.ExpressionEvaluator.Factory lhs; diff --git a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InDoubleEvaluator.java index f03dbb4a15a4..ce03061ce272 100644 --- a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InDoubleEvaluator.java @@ -14,20 +14,20 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.util.Arrays; import java.util.BitSet; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link In}. - * This class is generated. Edit {@code InEvaluator.java.st} instead. + * This class is generated. Edit {@code X-InEvaluator.java.st} instead. */ public class InDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -35,16 +35,18 @@ public class InDoubleEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public InDoubleEvaluator( Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator[] rhs, DriverContext driverContext ) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -84,7 +86,7 @@ public class InDoubleEvaluator implements EvalOperator.ExpressionEvaluator { } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue; @@ -99,7 +101,7 @@ public class InDoubleEvaluator implements EvalOperator.ExpressionEvaluator { } if (rhsBlocks[i].getValueCount(p) > 1) { mvs.set(i); - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); continue; } int o = rhsBlocks[i].getFirstValueIndex(p); @@ -148,6 +150,18 @@ public class InDoubleEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(lhs, () -> Releasables.close(rhs)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; private final EvalOperator.ExpressionEvaluator.Factory lhs; diff --git a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InIntEvaluator.java b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InIntEvaluator.java index 73f4a02d8dcd..077ec4d47379 100644 --- a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InIntEvaluator.java @@ -14,20 +14,20 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.util.Arrays; import java.util.BitSet; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link In}. - * This class is generated. Edit {@code InEvaluator.java.st} instead. + * This class is generated. Edit {@code X-InEvaluator.java.st} instead. */ public class InIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -35,16 +35,18 @@ public class InIntEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public InIntEvaluator( Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator[] rhs, DriverContext driverContext ) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -84,7 +86,7 @@ public class InIntEvaluator implements EvalOperator.ExpressionEvaluator { } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue; @@ -99,7 +101,7 @@ public class InIntEvaluator implements EvalOperator.ExpressionEvaluator { } if (rhsBlocks[i].getValueCount(p) > 1) { mvs.set(i); - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); continue; } int o = rhsBlocks[i].getFirstValueIndex(p); @@ -148,6 +150,18 @@ public class InIntEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(lhs, () -> Releasables.close(rhs)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; private final EvalOperator.ExpressionEvaluator.Factory lhs; diff --git a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InLongEvaluator.java b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InLongEvaluator.java index 966ebe754141..e54a89865c41 100644 --- a/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated-src/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InLongEvaluator.java @@ -14,20 +14,20 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.util.Arrays; import java.util.BitSet; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link In}. - * This class is generated. Edit {@code InEvaluator.java.st} instead. + * This class is generated. Edit {@code X-InEvaluator.java.st} instead. */ public class InLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -35,16 +35,18 @@ public class InLongEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public InLongEvaluator( Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator[] rhs, DriverContext driverContext ) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -84,7 +86,7 @@ public class InLongEvaluator implements EvalOperator.ExpressionEvaluator { } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue; @@ -99,7 +101,7 @@ public class InLongEvaluator implements EvalOperator.ExpressionEvaluator { } if (rhsBlocks[i].getValueCount(p) > 1) { mvs.set(i); - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); continue; } int o = rhsBlocks[i].getFirstValueIndex(p); @@ -148,6 +150,18 @@ public class InLongEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(lhs, () -> Releasables.close(rhs)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; private final EvalOperator.ExpressionEvaluator.Factory lhs; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/evaluator/predicate/operator/logical/NotEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/evaluator/predicate/operator/logical/NotEvaluator.java index 76e09389c7ad..b25f81a79b7c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/evaluator/predicate/operator/logical/NotEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/evaluator/predicate/operator/logical/NotEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.BooleanVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Not}. * This class is generated. Do not edit it. */ public final class NotEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public NotEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class NotEvaluator implements EvalOperator.ExpressionEvaluator { } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class NotEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/grouping/CategorizeEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/grouping/CategorizeEvaluator.java index 93bc8ce3e2a1..c6349907f9b4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/grouping/CategorizeEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/grouping/CategorizeEvaluator.java @@ -17,9 +17,9 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import org.elasticsearch.xpack.ml.aggs.categorization.TokenListCategorizer; import org.elasticsearch.xpack.ml.job.categorization.CategorizationAnalyzer; @@ -28,7 +28,7 @@ import org.elasticsearch.xpack.ml.job.categorization.CategorizationAnalyzer; * This class is generated. Do not edit it. */ public final class CategorizeEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; @@ -38,14 +38,16 @@ public final class CategorizeEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public CategorizeEvaluator(Source source, EvalOperator.ExpressionEvaluator v, CategorizationAnalyzer analyzer, TokenListCategorizer.CloseableTokenListCategorizer categorizer, DriverContext driverContext) { + this.source = source; this.v = v; this.analyzer = analyzer; this.categorizer = categorizer; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class CategorizeEvaluator implements EvalOperator.ExpressionEvaluat } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -100,6 +102,18 @@ public final class CategorizeEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(v, analyzer, categorizer); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBooleanEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBooleanEvaluator.java index 4c8988bbf603..27345b384375 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBooleanEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.BooleanVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Greatest}. * This class is generated. Do not edit it. */ public final class GreatestBooleanEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public GreatestBooleanEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreatestBooleanEvaluator implements EvalOperator.ExpressionEv } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreatestBooleanEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBytesRefEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBytesRefEvaluator.java index 0879c62ecafa..c8b8c3ac501e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBytesRefEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestBytesRefEvaluator.java @@ -15,27 +15,29 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Greatest}. * This class is generated. Do not edit it. */ public final class GreatestBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public GreatestBytesRefEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class GreatestBytesRefEvaluator implements EvalOperator.ExpressionE } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -116,6 +118,18 @@ public final class GreatestBytesRefEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestDoubleEvaluator.java index 20121bd3727a..e62b0f9877cd 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestDoubleEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Greatest}. * This class is generated. Do not edit it. */ public final class GreatestDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public GreatestDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreatestDoubleEvaluator implements EvalOperator.ExpressionEva } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreatestDoubleEvaluator implements EvalOperator.ExpressionEva Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestIntEvaluator.java index 85268a83b159..8c05f00fb1e0 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestIntEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Greatest}. * This class is generated. Do not edit it. */ public final class GreatestIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public GreatestIntEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreatestIntEvaluator implements EvalOperator.ExpressionEvalua } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreatestIntEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestLongEvaluator.java index 98e45ea0fe7b..78237c8d389b 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/GreatestLongEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Greatest}. * This class is generated. Do not edit it. */ public final class GreatestLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public GreatestLongEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreatestLongEvaluator implements EvalOperator.ExpressionEvalu } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreatestLongEvaluator implements EvalOperator.ExpressionEvalu Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBooleanEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBooleanEvaluator.java index 2dce335fc442..82fc13cffbe7 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBooleanEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.BooleanVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Least}. * This class is generated. Do not edit it. */ public final class LeastBooleanEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public LeastBooleanEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LeastBooleanEvaluator implements EvalOperator.ExpressionEvalu } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LeastBooleanEvaluator implements EvalOperator.ExpressionEvalu Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBytesRefEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBytesRefEvaluator.java index c701da21de51..b37408e43414 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBytesRefEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastBytesRefEvaluator.java @@ -15,27 +15,29 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Least}. * This class is generated. Do not edit it. */ public final class LeastBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public LeastBytesRefEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class LeastBytesRefEvaluator implements EvalOperator.ExpressionEval } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -116,6 +118,18 @@ public final class LeastBytesRefEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastDoubleEvaluator.java index eb605876045f..bf501d53211e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastDoubleEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Least}. * This class is generated. Do not edit it. */ public final class LeastDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public LeastDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LeastDoubleEvaluator implements EvalOperator.ExpressionEvalua } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LeastDoubleEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastIntEvaluator.java index 3a69293b66cf..803f23d994bb 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastIntEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Least}. * This class is generated. Do not edit it. */ public final class LeastIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public LeastIntEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LeastIntEvaluator implements EvalOperator.ExpressionEvaluator } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LeastIntEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastLongEvaluator.java index 00494374236e..7408dd1165a0 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/LeastLongEvaluator.java @@ -14,27 +14,29 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Least}. * This class is generated. Do not edit it. */ public final class LeastLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator[] values; private final DriverContext driverContext; + private Warnings warnings; + public LeastLongEvaluator(Source source, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LeastLongEvaluator implements EvalOperator.ExpressionEvaluato } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LeastLongEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(() -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FromBase64Evaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FromBase64Evaluator.java index 6ae51ca82d9a..9ba95999f052 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FromBase64Evaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/FromBase64Evaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link FromBase64}. * This class is generated. Do not edit it. */ public final class FromBase64Evaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field; @@ -33,12 +33,14 @@ public final class FromBase64Evaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public FromBase64Evaluator(Source source, EvalOperator.ExpressionEvaluator field, BytesRefBuilder oScratch, DriverContext driverContext) { + this.source = source; this.field = field; this.oScratch = oScratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -62,7 +64,7 @@ public final class FromBase64Evaluator implements EvalOperator.ExpressionEvaluat } if (fieldBlock.getValueCount(p) != 1) { if (fieldBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -93,6 +95,18 @@ public final class FromBase64Evaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(field); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBase64Evaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBase64Evaluator.java index 3c102b655d23..2ed07e440a30 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBase64Evaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBase64Evaluator.java @@ -17,16 +17,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link ToBase64}. * This class is generated. Do not edit it. */ public final class ToBase64Evaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field; @@ -34,12 +34,14 @@ public final class ToBase64Evaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public ToBase64Evaluator(Source source, EvalOperator.ExpressionEvaluator field, BytesRefBuilder oScratch, DriverContext driverContext) { + this.source = source; this.field = field; this.oScratch = oScratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -63,7 +65,7 @@ public final class ToBase64Evaluator implements EvalOperator.ExpressionEvaluator } if (fieldBlock.getValueCount(p) != 1) { if (fieldBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -71,7 +73,7 @@ public final class ToBase64Evaluator implements EvalOperator.ExpressionEvaluator try { result.appendBytesRef(ToBase64.process(fieldBlock.getBytesRef(fieldBlock.getFirstValueIndex(p), fieldScratch), this.oScratch)); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -86,7 +88,7 @@ public final class ToBase64Evaluator implements EvalOperator.ExpressionEvaluator try { result.appendBytesRef(ToBase64.process(fieldVector.getBytesRef(p, fieldScratch), this.oScratch)); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -104,6 +106,18 @@ public final class ToBase64Evaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(field); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffConstantEvaluator.java index dfef24cb556e..0ad09ee55ca1 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffConstantEvaluator.java @@ -14,17 +14,17 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateDiff}. * This class is generated. Do not edit it. */ public final class DateDiffConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final DateDiff.Part datePartFieldUnit; @@ -34,14 +34,16 @@ public final class DateDiffConstantEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public DateDiffConstantEvaluator(Source source, DateDiff.Part datePartFieldUnit, EvalOperator.ExpressionEvaluator startTimestamp, EvalOperator.ExpressionEvaluator endTimestamp, DriverContext driverContext) { + this.source = source; this.datePartFieldUnit = datePartFieldUnit; this.startTimestamp = startTimestamp; this.endTimestamp = endTimestamp; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class DateDiffConstantEvaluator implements EvalOperator.ExpressionE } if (startTimestampBlock.getValueCount(p) != 1) { if (startTimestampBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -82,7 +84,7 @@ public final class DateDiffConstantEvaluator implements EvalOperator.ExpressionE } if (endTimestampBlock.getValueCount(p) != 1) { if (endTimestampBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -90,7 +92,7 @@ public final class DateDiffConstantEvaluator implements EvalOperator.ExpressionE try { result.appendInt(DateDiff.process(this.datePartFieldUnit, startTimestampBlock.getLong(startTimestampBlock.getFirstValueIndex(p)), endTimestampBlock.getLong(endTimestampBlock.getFirstValueIndex(p)))); } catch (IllegalArgumentException | InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -105,7 +107,7 @@ public final class DateDiffConstantEvaluator implements EvalOperator.ExpressionE try { result.appendInt(DateDiff.process(this.datePartFieldUnit, startTimestampVector.getLong(p), endTimestampVector.getLong(p))); } catch (IllegalArgumentException | InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -123,6 +125,18 @@ public final class DateDiffConstantEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(startTimestamp, endTimestamp); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffEvaluator.java index dbb13c2d422d..82fb55e97f1f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateDiffEvaluator.java @@ -17,17 +17,17 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateDiff}. * This class is generated. Do not edit it. */ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator unit; @@ -37,14 +37,16 @@ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public DateDiffEvaluator(Source source, EvalOperator.ExpressionEvaluator unit, EvalOperator.ExpressionEvaluator startTimestamp, EvalOperator.ExpressionEvaluator endTimestamp, DriverContext driverContext) { + this.source = source; this.unit = unit; this.startTimestamp = startTimestamp; this.endTimestamp = endTimestamp; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -81,7 +83,7 @@ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator } if (unitBlock.getValueCount(p) != 1) { if (unitBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -92,7 +94,7 @@ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator } if (startTimestampBlock.getValueCount(p) != 1) { if (startTimestampBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -103,7 +105,7 @@ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator } if (endTimestampBlock.getValueCount(p) != 1) { if (endTimestampBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -111,7 +113,7 @@ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(DateDiff.process(unitBlock.getBytesRef(unitBlock.getFirstValueIndex(p), unitScratch), startTimestampBlock.getLong(startTimestampBlock.getFirstValueIndex(p)), endTimestampBlock.getLong(endTimestampBlock.getFirstValueIndex(p)))); } catch (IllegalArgumentException | InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -127,7 +129,7 @@ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(DateDiff.process(unitVector.getBytesRef(p, unitScratch), startTimestampVector.getLong(p), endTimestampVector.getLong(p))); } catch (IllegalArgumentException | InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -145,6 +147,18 @@ public final class DateDiffEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(unit, startTimestamp, endTimestamp); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractConstantEvaluator.java index d72ffe77ac91..37e900245a87 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateExtract}. * This class is generated. Do not edit it. */ public final class DateExtractConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator value; @@ -34,13 +34,15 @@ public final class DateExtractConstantEvaluator implements EvalOperator.Expressi private final DriverContext driverContext; + private Warnings warnings; + public DateExtractConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator value, ChronoField chronoField, ZoneId zone, DriverContext driverContext) { + this.source = source; this.value = value; this.chronoField = chronoField; this.zone = zone; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -63,7 +65,7 @@ public final class DateExtractConstantEvaluator implements EvalOperator.Expressi } if (valueBlock.getValueCount(p) != 1) { if (valueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -93,6 +95,18 @@ public final class DateExtractConstantEvaluator implements EvalOperator.Expressi Releasables.closeExpectNoException(value); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractEvaluator.java index 8812eba05133..6d56fd1c0d6a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateExtractEvaluator.java @@ -17,16 +17,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateExtract}. * This class is generated. Do not edit it. */ public final class DateExtractEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator value; @@ -36,13 +36,15 @@ public final class DateExtractEvaluator implements EvalOperator.ExpressionEvalua private final DriverContext driverContext; + private Warnings warnings; + public DateExtractEvaluator(Source source, EvalOperator.ExpressionEvaluator value, EvalOperator.ExpressionEvaluator chronoField, ZoneId zone, DriverContext driverContext) { + this.source = source; this.value = value; this.chronoField = chronoField; this.zone = zone; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -72,7 +74,7 @@ public final class DateExtractEvaluator implements EvalOperator.ExpressionEvalua } if (valueBlock.getValueCount(p) != 1) { if (valueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -83,7 +85,7 @@ public final class DateExtractEvaluator implements EvalOperator.ExpressionEvalua } if (chronoFieldBlock.getValueCount(p) != 1) { if (chronoFieldBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class DateExtractEvaluator implements EvalOperator.ExpressionEvalua try { result.appendLong(DateExtract.process(valueBlock.getLong(valueBlock.getFirstValueIndex(p)), chronoFieldBlock.getBytesRef(chronoFieldBlock.getFirstValueIndex(p), chronoFieldScratch), this.zone)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -107,7 +109,7 @@ public final class DateExtractEvaluator implements EvalOperator.ExpressionEvalua try { result.appendLong(DateExtract.process(valueVector.getLong(p), chronoFieldVector.getBytesRef(p, chronoFieldScratch), this.zone)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -125,6 +127,18 @@ public final class DateExtractEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(value, chronoField); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatConstantEvaluator.java index 4731c888cef7..25afa6bec360 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatConstantEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateFormat}. * This class is generated. Do not edit it. */ public final class DateFormatConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -33,12 +33,14 @@ public final class DateFormatConstantEvaluator implements EvalOperator.Expressio private final DriverContext driverContext; + private Warnings warnings; + public DateFormatConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DateFormatter formatter, DriverContext driverContext) { + this.source = source; this.val = val; this.formatter = formatter; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class DateFormatConstantEvaluator implements EvalOperator.Expressio } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,6 +93,18 @@ public final class DateFormatConstantEvaluator implements EvalOperator.Expressio Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatEvaluator.java index 77633797de02..318ffa5af8f7 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateFormatEvaluator.java @@ -17,16 +17,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateFormat}. * This class is generated. Do not edit it. */ public final class DateFormatEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -36,13 +36,15 @@ public final class DateFormatEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public DateFormatEvaluator(Source source, EvalOperator.ExpressionEvaluator val, EvalOperator.ExpressionEvaluator formatter, Locale locale, DriverContext driverContext) { + this.source = source; this.val = val; this.formatter = formatter; this.locale = locale; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -72,7 +74,7 @@ public final class DateFormatEvaluator implements EvalOperator.ExpressionEvaluat } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -83,7 +85,7 @@ public final class DateFormatEvaluator implements EvalOperator.ExpressionEvaluat } if (formatterBlock.getValueCount(p) != 1) { if (formatterBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -115,6 +117,18 @@ public final class DateFormatEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(val, formatter); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseConstantEvaluator.java index 470ffab52920..0ddc73182789 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseConstantEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateParse}. * This class is generated. Do not edit it. */ public final class DateParseConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -33,12 +33,14 @@ public final class DateParseConstantEvaluator implements EvalOperator.Expression private final DriverContext driverContext; + private Warnings warnings; + public DateParseConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DateFormatter formatter, DriverContext driverContext) { + this.source = source; this.val = val; this.formatter = formatter; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -62,7 +64,7 @@ public final class DateParseConstantEvaluator implements EvalOperator.Expression } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -70,7 +72,7 @@ public final class DateParseConstantEvaluator implements EvalOperator.Expression try { result.appendLong(DateParse.process(valBlock.getBytesRef(valBlock.getFirstValueIndex(p), valScratch), this.formatter)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,7 +87,7 @@ public final class DateParseConstantEvaluator implements EvalOperator.Expression try { result.appendLong(DateParse.process(valVector.getBytesRef(p, valScratch), this.formatter)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -103,6 +105,18 @@ public final class DateParseConstantEvaluator implements EvalOperator.Expression Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseEvaluator.java index edfe6c39949c..3ea782931a0a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateParseEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateParse}. * This class is generated. Do not edit it. */ public final class DateParseEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -35,13 +35,15 @@ public final class DateParseEvaluator implements EvalOperator.ExpressionEvaluato private final DriverContext driverContext; + private Warnings warnings; + public DateParseEvaluator(Source source, EvalOperator.ExpressionEvaluator val, EvalOperator.ExpressionEvaluator formatter, ZoneId zoneId, DriverContext driverContext) { + this.source = source; this.val = val; this.formatter = formatter; this.zoneId = zoneId; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -72,7 +74,7 @@ public final class DateParseEvaluator implements EvalOperator.ExpressionEvaluato } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -83,7 +85,7 @@ public final class DateParseEvaluator implements EvalOperator.ExpressionEvaluato } if (formatterBlock.getValueCount(p) != 1) { if (formatterBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class DateParseEvaluator implements EvalOperator.ExpressionEvaluato try { result.appendLong(DateParse.process(valBlock.getBytesRef(valBlock.getFirstValueIndex(p), valScratch), formatterBlock.getBytesRef(formatterBlock.getFirstValueIndex(p), formatterScratch), this.zoneId)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -108,7 +110,7 @@ public final class DateParseEvaluator implements EvalOperator.ExpressionEvaluato try { result.appendLong(DateParse.process(valVector.getBytesRef(p, valScratch), formatterVector.getBytesRef(p, formatterScratch), this.zoneId)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -126,6 +128,18 @@ public final class DateParseEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(val, formatter); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncEvaluator.java index b8bc45296a60..ca6aad07c317 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/DateTruncEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link DateTrunc}. * This class is generated. Do not edit it. */ public final class DateTruncEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator fieldVal; @@ -31,12 +31,14 @@ public final class DateTruncEvaluator implements EvalOperator.ExpressionEvaluato private final DriverContext driverContext; + private Warnings warnings; + public DateTruncEvaluator(Source source, EvalOperator.ExpressionEvaluator fieldVal, Rounding.Prepared rounding, DriverContext driverContext) { + this.source = source; this.fieldVal = fieldVal; this.rounding = rounding; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -59,7 +61,7 @@ public final class DateTruncEvaluator implements EvalOperator.ExpressionEvaluato } if (fieldValBlock.getValueCount(p) != 1) { if (fieldValBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -89,6 +91,18 @@ public final class DateTruncEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(fieldVal); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowEvaluator.java index db1d5f8fe01c..3eca39f98034 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/date/NowEvaluator.java @@ -11,24 +11,26 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Now}. * This class is generated. Do not edit it. */ public final class NowEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final long now; private final DriverContext driverContext; + private Warnings warnings; + public NowEvaluator(Source source, long now, DriverContext driverContext) { + this.source = source; this.now = now; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -54,6 +56,18 @@ public final class NowEvaluator implements EvalOperator.ExpressionEvaluator { public void close() { } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchEvaluator.java index 8782e547c383..0120af54299e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/CIDRMatchEvaluator.java @@ -17,17 +17,17 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link CIDRMatch}. * This class is generated. Do not edit it. */ public final class CIDRMatchEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator ip; @@ -35,12 +35,14 @@ public final class CIDRMatchEvaluator implements EvalOperator.ExpressionEvaluato private final DriverContext driverContext; + private Warnings warnings; + public CIDRMatchEvaluator(Source source, EvalOperator.ExpressionEvaluator ip, EvalOperator.ExpressionEvaluator[] cidrs, DriverContext driverContext) { + this.source = source; this.ip = ip; this.cidrs = cidrs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -82,7 +84,7 @@ public final class CIDRMatchEvaluator implements EvalOperator.ExpressionEvaluato } if (ipBlock.getValueCount(p) != 1) { if (ipBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -94,7 +96,7 @@ public final class CIDRMatchEvaluator implements EvalOperator.ExpressionEvaluato } if (cidrsBlocks[i].getValueCount(p) != 1) { if (cidrsBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -141,6 +143,18 @@ public final class CIDRMatchEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(ip, () -> Releasables.close(cidrs)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixEvaluator.java index 0347fd2e1065..53a367aff7cd 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/ip/IpPrefixEvaluator.java @@ -17,16 +17,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link IpPrefix}. * This class is generated. Do not edit it. */ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator ip; @@ -38,16 +38,18 @@ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public IpPrefixEvaluator(Source source, EvalOperator.ExpressionEvaluator ip, EvalOperator.ExpressionEvaluator prefixLengthV4, EvalOperator.ExpressionEvaluator prefixLengthV6, BytesRef scratch, DriverContext driverContext) { + this.source = source; this.ip = ip; this.prefixLengthV4 = prefixLengthV4; this.prefixLengthV6 = prefixLengthV6; this.scratch = scratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -84,7 +86,7 @@ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator } if (ipBlock.getValueCount(p) != 1) { if (ipBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -95,7 +97,7 @@ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator } if (prefixLengthV4Block.getValueCount(p) != 1) { if (prefixLengthV4Block.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -106,7 +108,7 @@ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator } if (prefixLengthV6Block.getValueCount(p) != 1) { if (prefixLengthV6Block.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -114,7 +116,7 @@ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendBytesRef(IpPrefix.process(ipBlock.getBytesRef(ipBlock.getFirstValueIndex(p), ipScratch), prefixLengthV4Block.getInt(prefixLengthV4Block.getFirstValueIndex(p)), prefixLengthV6Block.getInt(prefixLengthV6Block.getFirstValueIndex(p)), this.scratch)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -130,7 +132,7 @@ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendBytesRef(IpPrefix.process(ipVector.getBytesRef(p, ipScratch), prefixLengthV4Vector.getInt(p), prefixLengthV6Vector.getInt(p), this.scratch)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -148,6 +150,18 @@ public final class IpPrefixEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(ip, prefixLengthV4, prefixLengthV6); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsDoubleEvaluator.java index 330ee39d4990..69697d81b8bc 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsDoubleEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Abs}. * This class is generated. Do not edit it. */ public final class AbsDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator fieldVal; private final DriverContext driverContext; + private Warnings warnings; + public AbsDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator fieldVal, DriverContext driverContext) { + this.source = source; this.fieldVal = fieldVal; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class AbsDoubleEvaluator implements EvalOperator.ExpressionEvaluato } if (fieldValBlock.getValueCount(p) != 1) { if (fieldValBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class AbsDoubleEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(fieldVal); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsIntEvaluator.java index c453fbd08267..44007fcb9c6f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsIntEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Abs}. * This class is generated. Do not edit it. */ public final class AbsIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator fieldVal; private final DriverContext driverContext; + private Warnings warnings; + public AbsIntEvaluator(Source source, EvalOperator.ExpressionEvaluator fieldVal, DriverContext driverContext) { + this.source = source; this.fieldVal = fieldVal; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class AbsIntEvaluator implements EvalOperator.ExpressionEvaluator { } if (fieldValBlock.getValueCount(p) != 1) { if (fieldValBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class AbsIntEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(fieldVal); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsLongEvaluator.java index 3e75e955b258..2bb17f9f2512 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AbsLongEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Abs}. * This class is generated. Do not edit it. */ public final class AbsLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator fieldVal; private final DriverContext driverContext; + private Warnings warnings; + public AbsLongEvaluator(Source source, EvalOperator.ExpressionEvaluator fieldVal, DriverContext driverContext) { + this.source = source; this.fieldVal = fieldVal; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class AbsLongEvaluator implements EvalOperator.ExpressionEvaluator } if (fieldValBlock.getValueCount(p) != 1) { if (fieldValBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class AbsLongEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(fieldVal); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AcosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AcosEvaluator.java index 840483e754b4..17d8c34a6373 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AcosEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AcosEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Acos}. * This class is generated. Do not edit it. */ public final class AcosEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public AcosEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class AcosEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class AcosEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Acos.process(valBlock.getDouble(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class AcosEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Acos.process(valVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class AcosEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AsinEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AsinEvaluator.java index ed78b6fa2973..267ba167572a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AsinEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AsinEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Asin}. * This class is generated. Do not edit it. */ public final class AsinEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public AsinEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class AsinEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class AsinEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Asin.process(valBlock.getDouble(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class AsinEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Asin.process(valVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class AsinEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2Evaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2Evaluator.java index 0c3bb4933336..2f1fdabc4097 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2Evaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Atan2Evaluator.java @@ -13,16 +13,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Atan2}. * This class is generated. Do not edit it. */ public final class Atan2Evaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator y; @@ -30,12 +30,14 @@ public final class Atan2Evaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public Atan2Evaluator(Source source, EvalOperator.ExpressionEvaluator y, EvalOperator.ExpressionEvaluator x, DriverContext driverContext) { + this.source = source; this.y = y; this.x = x; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -64,7 +66,7 @@ public final class Atan2Evaluator implements EvalOperator.ExpressionEvaluator { } if (yBlock.getValueCount(p) != 1) { if (yBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -75,7 +77,7 @@ public final class Atan2Evaluator implements EvalOperator.ExpressionEvaluator { } if (xBlock.getValueCount(p) != 1) { if (xBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -105,6 +107,18 @@ public final class Atan2Evaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(y, x); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AtanEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AtanEvaluator.java index 0902d138620a..2e4d4c80e6a9 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AtanEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/AtanEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Atan}. * This class is generated. Do not edit it. */ public final class AtanEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public AtanEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class AtanEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class AtanEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToDoubleEvaluator.java index 12e074f1d504..d99d6d918a21 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToDoubleEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cast}. * This class is generated. Do not edit it. */ public final class CastIntToDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public CastIntToDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CastIntToDoubleEvaluator implements EvalOperator.ExpressionEv } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class CastIntToDoubleEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToLongEvaluator.java index 29e28c305a16..585b0f392bee 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cast}. * This class is generated. Do not edit it. */ public final class CastIntToLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public CastIntToLongEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CastIntToLongEvaluator implements EvalOperator.ExpressionEval } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class CastIntToLongEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToUnsignedLongEvaluator.java index 61d19f02c4cb..ff5ffcb6710c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastIntToUnsignedLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cast}. * This class is generated. Do not edit it. */ public final class CastIntToUnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public CastIntToUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CastIntToUnsignedLongEvaluator implements EvalOperator.Expres } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class CastIntToUnsignedLongEvaluator implements EvalOperator.Expres Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToDoubleEvaluator.java index fdfc31b471d8..9d6851cde051 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToDoubleEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cast}. * This class is generated. Do not edit it. */ public final class CastLongToDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public CastLongToDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CastLongToDoubleEvaluator implements EvalOperator.ExpressionE } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class CastLongToDoubleEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToUnsignedLongEvaluator.java index 4198062c2ecf..b72ea03cef25 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastLongToUnsignedLongEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cast}. * This class is generated. Do not edit it. */ public final class CastLongToUnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public CastLongToUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class CastLongToUnsignedLongEvaluator implements EvalOperator.Expre } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class CastLongToUnsignedLongEvaluator implements EvalOperator.Expre Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastUnsignedLongToDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastUnsignedLongToDoubleEvaluator.java index 3ae66262f9b0..d7ab56113ebf 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastUnsignedLongToDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CastUnsignedLongToDoubleEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cast}. * This class is generated. Do not edit it. */ public final class CastUnsignedLongToDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public CastUnsignedLongToDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CastUnsignedLongToDoubleEvaluator implements EvalOperator.Exp } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class CastUnsignedLongToDoubleEvaluator implements EvalOperator.Exp Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtDoubleEvaluator.java index e34ea2a314b1..66727d2ba0db 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtDoubleEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cbrt}. * This class is generated. Do not edit it. */ public final class CbrtDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public CbrtDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class CbrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class CbrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Cbrt.process(valBlock.getDouble(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class CbrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Cbrt.process(valVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class CbrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtIntEvaluator.java index fb815f9f01e3..dd811c2ef7c5 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtIntEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cbrt}. * This class is generated. Do not edit it. */ public final class CbrtIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public CbrtIntEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CbrtIntEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -65,7 +67,7 @@ public final class CbrtIntEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Cbrt.process(valBlock.getInt(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,7 +81,7 @@ public final class CbrtIntEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Cbrt.process(valVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -97,6 +99,18 @@ public final class CbrtIntEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtLongEvaluator.java index 56a7af30bcfd..d931106c65b0 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cbrt}. * This class is generated. Do not edit it. */ public final class CbrtLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public CbrtLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CbrtLongEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -65,7 +67,7 @@ public final class CbrtLongEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Cbrt.process(valBlock.getLong(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,7 +81,7 @@ public final class CbrtLongEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Cbrt.process(valVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -97,6 +99,18 @@ public final class CbrtLongEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtUnsignedLongEvaluator.java index 843d8f0d58c3..13e5878ec524 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CbrtUnsignedLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cbrt}. * This class is generated. Do not edit it. */ public final class CbrtUnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public CbrtUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class CbrtUnsignedLongEvaluator implements EvalOperator.ExpressionE } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class CbrtUnsignedLongEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CeilDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CeilDoubleEvaluator.java index 6ee809c683f7..02617726145d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CeilDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CeilDoubleEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Ceil}. * This class is generated. Do not edit it. */ public final class CeilDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public CeilDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class CeilDoubleEvaluator implements EvalOperator.ExpressionEvaluat } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class CeilDoubleEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CosEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CosEvaluator.java index 7d2833dc025d..8718eb606c20 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CosEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CosEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cos}. * This class is generated. Do not edit it. */ public final class CosEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public CosEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class CosEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class CosEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CoshEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CoshEvaluator.java index 211d801b75fd..409432a83da0 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CoshEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/CoshEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Cosh}. * This class is generated. Do not edit it. */ public final class CoshEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public CoshEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class CoshEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class CoshEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Cosh.process(valBlock.getDouble(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class CoshEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Cosh.process(valVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class CoshEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpDoubleEvaluator.java index 37114256774d..4d7362b8bc8e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpDoubleEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Exp}. * This class is generated. Do not edit it. */ public final class ExpDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public ExpDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class ExpDoubleEvaluator implements EvalOperator.ExpressionEvaluato } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class ExpDoubleEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpIntEvaluator.java index 5559453f97f3..482d44b1087a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpIntEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Exp}. * This class is generated. Do not edit it. */ public final class ExpIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public ExpIntEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class ExpIntEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class ExpIntEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpLongEvaluator.java index 2642628088a2..bbd17fe57c18 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Exp}. * This class is generated. Do not edit it. */ public final class ExpLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public ExpLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class ExpLongEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class ExpLongEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpUnsignedLongEvaluator.java index 52506d5cd30e..9fd90dca32f2 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/ExpUnsignedLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Exp}. * This class is generated. Do not edit it. */ public final class ExpUnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public ExpUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class ExpUnsignedLongEvaluator implements EvalOperator.ExpressionEv } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class ExpUnsignedLongEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/FloorDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/FloorDoubleEvaluator.java index fb3bbb34bf72..df9e533b9430 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/FloorDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/FloorDoubleEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Floor}. * This class is generated. Do not edit it. */ public final class FloorDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public FloorDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class FloorDoubleEvaluator implements EvalOperator.ExpressionEvalua } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class FloorDoubleEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10DoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10DoubleEvaluator.java index 0a4d7a3ad6d2..75a1f57520b3 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10DoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10DoubleEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Log10}. * This class is generated. Do not edit it. */ public final class Log10DoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public Log10DoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class Log10DoubleEvaluator implements EvalOperator.ExpressionEvalua } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class Log10DoubleEvaluator implements EvalOperator.ExpressionEvalua try { result.appendDouble(Log10.process(valBlock.getDouble(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class Log10DoubleEvaluator implements EvalOperator.ExpressionEvalua try { result.appendDouble(Log10.process(valVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class Log10DoubleEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10IntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10IntEvaluator.java index 147e2052af99..d702185235cc 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10IntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10IntEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Log10}. * This class is generated. Do not edit it. */ public final class Log10IntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public Log10IntEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class Log10IntEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -65,7 +67,7 @@ public final class Log10IntEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Log10.process(valBlock.getInt(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,7 +81,7 @@ public final class Log10IntEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Log10.process(valVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -97,6 +99,18 @@ public final class Log10IntEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10LongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10LongEvaluator.java index 565f286dcc8c..c13c477e4f68 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10LongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10LongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Log10}. * This class is generated. Do not edit it. */ public final class Log10LongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public Log10LongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class Log10LongEvaluator implements EvalOperator.ExpressionEvaluato } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -65,7 +67,7 @@ public final class Log10LongEvaluator implements EvalOperator.ExpressionEvaluato try { result.appendDouble(Log10.process(valBlock.getLong(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,7 +81,7 @@ public final class Log10LongEvaluator implements EvalOperator.ExpressionEvaluato try { result.appendDouble(Log10.process(valVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -97,6 +99,18 @@ public final class Log10LongEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10UnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10UnsignedLongEvaluator.java index a900585fb6ef..8c955f499c9c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10UnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/Log10UnsignedLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Log10}. * This class is generated. Do not edit it. */ public final class Log10UnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public Log10UnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class Log10UnsignedLongEvaluator implements EvalOperator.Expression } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -65,7 +67,7 @@ public final class Log10UnsignedLongEvaluator implements EvalOperator.Expression try { result.appendDouble(Log10.processUnsignedLong(valBlock.getLong(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,7 +81,7 @@ public final class Log10UnsignedLongEvaluator implements EvalOperator.Expression try { result.appendDouble(Log10.processUnsignedLong(valVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -97,6 +99,18 @@ public final class Log10UnsignedLongEvaluator implements EvalOperator.Expression Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogConstantEvaluator.java index 3688e989a45d..c6b4009e6a77 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogConstantEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Log}. * This class is generated. Do not edit it. */ public final class LogConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator value; private final DriverContext driverContext; + private Warnings warnings; + public LogConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator value, DriverContext driverContext) { + this.source = source; this.value = value; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class LogConstantEvaluator implements EvalOperator.ExpressionEvalua } if (valueBlock.getValueCount(p) != 1) { if (valueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class LogConstantEvaluator implements EvalOperator.ExpressionEvalua try { result.appendDouble(Log.process(valueBlock.getDouble(valueBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class LogConstantEvaluator implements EvalOperator.ExpressionEvalua try { result.appendDouble(Log.process(valueVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class LogConstantEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(value); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogEvaluator.java index c2ccd4d64ec8..583cc06ba7db 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/LogEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Log}. * This class is generated. Do not edit it. */ public final class LogEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator base; @@ -31,12 +31,14 @@ public final class LogEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public LogEvaluator(Source source, EvalOperator.ExpressionEvaluator base, EvalOperator.ExpressionEvaluator value, DriverContext driverContext) { + this.source = source; this.base = base; this.value = value; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class LogEvaluator implements EvalOperator.ExpressionEvaluator { } if (baseBlock.getValueCount(p) != 1) { if (baseBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class LogEvaluator implements EvalOperator.ExpressionEvaluator { } if (valueBlock.getValueCount(p) != 1) { if (valueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class LogEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Log.process(baseBlock.getDouble(baseBlock.getFirstValueIndex(p)), valueBlock.getDouble(valueBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class LogEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Log.process(baseVector.getDouble(p), valueVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class LogEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(base, value); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowEvaluator.java index 7d85b12e5008..d1c9f9146392 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/PowEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Pow}. * This class is generated. Do not edit it. */ public final class PowEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator base; @@ -31,12 +31,14 @@ public final class PowEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public PowEvaluator(Source source, EvalOperator.ExpressionEvaluator base, EvalOperator.ExpressionEvaluator exponent, DriverContext driverContext) { + this.source = source; this.base = base; this.exponent = exponent; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class PowEvaluator implements EvalOperator.ExpressionEvaluator { } if (baseBlock.getValueCount(p) != 1) { if (baseBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class PowEvaluator implements EvalOperator.ExpressionEvaluator { } if (exponentBlock.getValueCount(p) != 1) { if (exponentBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class PowEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Pow.process(baseBlock.getDouble(baseBlock.getFirstValueIndex(p)), exponentBlock.getDouble(exponentBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class PowEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Pow.process(baseVector.getDouble(p), exponentVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class PowEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(base, exponent); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleEvaluator.java index 1fe09cdd7079..347549bb78cc 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Round}. * This class is generated. Do not edit it. */ public final class RoundDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -32,12 +32,14 @@ public final class RoundDoubleEvaluator implements EvalOperator.ExpressionEvalua private final DriverContext driverContext; + private Warnings warnings; + public RoundDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, EvalOperator.ExpressionEvaluator decimals, DriverContext driverContext) { + this.source = source; this.val = val; this.decimals = decimals; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class RoundDoubleEvaluator implements EvalOperator.ExpressionEvalua } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class RoundDoubleEvaluator implements EvalOperator.ExpressionEvalua } if (decimalsBlock.getValueCount(p) != 1) { if (decimalsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class RoundDoubleEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(val, decimals); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleNoDecimalsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleNoDecimalsEvaluator.java index c9b3c778139c..bfabc34721c6 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleNoDecimalsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundDoubleNoDecimalsEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Round}. * This class is generated. Do not edit it. */ public final class RoundDoubleNoDecimalsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public RoundDoubleNoDecimalsEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class RoundDoubleNoDecimalsEvaluator implements EvalOperator.Expres } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class RoundDoubleNoDecimalsEvaluator implements EvalOperator.Expres Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundIntEvaluator.java index 75886d8fb5ac..220dd7a547cc 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundIntEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Round}. * This class is generated. Do not edit it. */ public final class RoundIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -32,12 +32,14 @@ public final class RoundIntEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public RoundIntEvaluator(Source source, EvalOperator.ExpressionEvaluator val, EvalOperator.ExpressionEvaluator decimals, DriverContext driverContext) { + this.source = source; this.val = val; this.decimals = decimals; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class RoundIntEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class RoundIntEvaluator implements EvalOperator.ExpressionEvaluator } if (decimalsBlock.getValueCount(p) != 1) { if (decimalsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class RoundIntEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val, decimals); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundLongEvaluator.java index 3c37fab209a4..a2b7b51d42e0 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundLongEvaluator.java @@ -13,16 +13,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Round}. * This class is generated. Do not edit it. */ public final class RoundLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -30,12 +30,14 @@ public final class RoundLongEvaluator implements EvalOperator.ExpressionEvaluato private final DriverContext driverContext; + private Warnings warnings; + public RoundLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, EvalOperator.ExpressionEvaluator decimals, DriverContext driverContext) { + this.source = source; this.val = val; this.decimals = decimals; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -64,7 +66,7 @@ public final class RoundLongEvaluator implements EvalOperator.ExpressionEvaluato } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -75,7 +77,7 @@ public final class RoundLongEvaluator implements EvalOperator.ExpressionEvaluato } if (decimalsBlock.getValueCount(p) != 1) { if (decimalsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -105,6 +107,18 @@ public final class RoundLongEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(val, decimals); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundUnsignedLongEvaluator.java index 2826feeea29b..c9c6e3806cb0 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/RoundUnsignedLongEvaluator.java @@ -13,16 +13,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Round}. * This class is generated. Do not edit it. */ public final class RoundUnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -30,12 +30,14 @@ public final class RoundUnsignedLongEvaluator implements EvalOperator.Expression private final DriverContext driverContext; + private Warnings warnings; + public RoundUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, EvalOperator.ExpressionEvaluator decimals, DriverContext driverContext) { + this.source = source; this.val = val; this.decimals = decimals; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -64,7 +66,7 @@ public final class RoundUnsignedLongEvaluator implements EvalOperator.Expression } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -75,7 +77,7 @@ public final class RoundUnsignedLongEvaluator implements EvalOperator.Expression } if (decimalsBlock.getValueCount(p) != 1) { if (decimalsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -105,6 +107,18 @@ public final class RoundUnsignedLongEvaluator implements EvalOperator.Expression Releasables.closeExpectNoException(val, decimals); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumDoubleEvaluator.java index c1f184afc588..e80559397464 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumDoubleEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Signum}. * This class is generated. Do not edit it. */ public final class SignumDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SignumDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class SignumDoubleEvaluator implements EvalOperator.ExpressionEvalu } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class SignumDoubleEvaluator implements EvalOperator.ExpressionEvalu Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumIntEvaluator.java index 68b603cd98a0..410c818fcf92 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumIntEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Signum}. * This class is generated. Do not edit it. */ public final class SignumIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SignumIntEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class SignumIntEvaluator implements EvalOperator.ExpressionEvaluato } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class SignumIntEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumLongEvaluator.java index b66532789a57..b5406bab5ee3 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Signum}. * This class is generated. Do not edit it. */ public final class SignumLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SignumLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class SignumLongEvaluator implements EvalOperator.ExpressionEvaluat } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class SignumLongEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumUnsignedLongEvaluator.java index 2fa03ed2cf44..269ea507bfd0 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SignumUnsignedLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Signum}. * This class is generated. Do not edit it. */ public final class SignumUnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SignumUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class SignumUnsignedLongEvaluator implements EvalOperator.Expressio } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class SignumUnsignedLongEvaluator implements EvalOperator.Expressio Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinEvaluator.java index 23df0d539b63..b4a4a1b1a2a4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sin}. * This class is generated. Do not edit it. */ public final class SinEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SinEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class SinEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class SinEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinhEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinhEvaluator.java index 1aecf68eec11..ccce05ee8f7c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinhEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SinhEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sinh}. * This class is generated. Do not edit it. */ public final class SinhEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SinhEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class SinhEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class SinhEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Sinh.process(valBlock.getDouble(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class SinhEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendDouble(Sinh.process(valVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class SinhEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtDoubleEvaluator.java index cb1c5da5b0cf..db8cb7322206 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtDoubleEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sqrt}. * This class is generated. Do not edit it. */ public final class SqrtDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SqrtDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class SqrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class SqrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Sqrt.process(valBlock.getDouble(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class SqrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Sqrt.process(valVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class SqrtDoubleEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtIntEvaluator.java index 26fa9f39e705..fc791b22aae8 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtIntEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sqrt}. * This class is generated. Do not edit it. */ public final class SqrtIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SqrtIntEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class SqrtIntEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -65,7 +67,7 @@ public final class SqrtIntEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Sqrt.process(valBlock.getInt(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,7 +81,7 @@ public final class SqrtIntEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Sqrt.process(valVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -97,6 +99,18 @@ public final class SqrtIntEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtLongEvaluator.java index 7d306d76cd79..1e656dbfd7a3 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sqrt}. * This class is generated. Do not edit it. */ public final class SqrtLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SqrtLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class SqrtLongEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -65,7 +67,7 @@ public final class SqrtLongEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Sqrt.process(valBlock.getLong(valBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,7 +81,7 @@ public final class SqrtLongEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendDouble(Sqrt.process(valVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -97,6 +99,18 @@ public final class SqrtLongEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtUnsignedLongEvaluator.java index eba1d041e673..f5dc994c3ea8 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/SqrtUnsignedLongEvaluator.java @@ -15,26 +15,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sqrt}. * This class is generated. Do not edit it. */ public final class SqrtUnsignedLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public SqrtUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class SqrtUnsignedLongEvaluator implements EvalOperator.ExpressionE } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -87,6 +89,18 @@ public final class SqrtUnsignedLongEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanEvaluator.java index de602995cc32..1dcc611410a6 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Tan}. * This class is generated. Do not edit it. */ public final class TanEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public TanEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class TanEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class TanEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanhEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanhEvaluator.java index 80a1448820cc..860a4f5b0e60 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanhEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/math/TanhEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Tanh}. * This class is generated. Do not edit it. */ public final class TanhEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public TanhEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class TanhEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class TanhEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBooleanEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBooleanEvaluator.java index 83e49464fc43..d4fab518a0e5 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBooleanEvaluator.java @@ -11,16 +11,16 @@ import org.elasticsearch.compute.data.BooleanBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvAppend}. * This class is generated. Do not edit it. */ public final class MvAppendBooleanEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field1; @@ -28,12 +28,14 @@ public final class MvAppendBooleanEvaluator implements EvalOperator.ExpressionEv private final DriverContext driverContext; + private Warnings warnings; + public MvAppendBooleanEvaluator(Source source, EvalOperator.ExpressionEvaluator field1, EvalOperator.ExpressionEvaluator field2, DriverContext driverContext) { + this.source = source; this.field1 = field1; this.field2 = field2; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -75,6 +77,18 @@ public final class MvAppendBooleanEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(field1, field2); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBytesRefEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBytesRefEvaluator.java index 6baea4de982f..959449310ce9 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBytesRefEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendBytesRefEvaluator.java @@ -11,16 +11,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvAppend}. * This class is generated. Do not edit it. */ public final class MvAppendBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field1; @@ -28,12 +28,14 @@ public final class MvAppendBytesRefEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public MvAppendBytesRefEvaluator(Source source, EvalOperator.ExpressionEvaluator field1, EvalOperator.ExpressionEvaluator field2, DriverContext driverContext) { + this.source = source; this.field1 = field1; this.field2 = field2; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -76,6 +78,18 @@ public final class MvAppendBytesRefEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(field1, field2); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendDoubleEvaluator.java index f714fcefac8c..d2fb9ce2926d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendDoubleEvaluator.java @@ -11,16 +11,16 @@ import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvAppend}. * This class is generated. Do not edit it. */ public final class MvAppendDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field1; @@ -28,12 +28,14 @@ public final class MvAppendDoubleEvaluator implements EvalOperator.ExpressionEva private final DriverContext driverContext; + private Warnings warnings; + public MvAppendDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator field1, EvalOperator.ExpressionEvaluator field2, DriverContext driverContext) { + this.source = source; this.field1 = field1; this.field2 = field2; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -75,6 +77,18 @@ public final class MvAppendDoubleEvaluator implements EvalOperator.ExpressionEva Releasables.closeExpectNoException(field1, field2); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendIntEvaluator.java index 1fbbdf81323b..dd5a491281c4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendIntEvaluator.java @@ -11,16 +11,16 @@ import org.elasticsearch.compute.data.IntBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvAppend}. * This class is generated. Do not edit it. */ public final class MvAppendIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field1; @@ -28,12 +28,14 @@ public final class MvAppendIntEvaluator implements EvalOperator.ExpressionEvalua private final DriverContext driverContext; + private Warnings warnings; + public MvAppendIntEvaluator(Source source, EvalOperator.ExpressionEvaluator field1, EvalOperator.ExpressionEvaluator field2, DriverContext driverContext) { + this.source = source; this.field1 = field1; this.field2 = field2; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -75,6 +77,18 @@ public final class MvAppendIntEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(field1, field2); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendLongEvaluator.java index 14f27ae88964..6f6050e7f245 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvAppendLongEvaluator.java @@ -11,16 +11,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvAppend}. * This class is generated. Do not edit it. */ public final class MvAppendLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field1; @@ -28,12 +28,14 @@ public final class MvAppendLongEvaluator implements EvalOperator.ExpressionEvalu private final DriverContext driverContext; + private Warnings warnings; + public MvAppendLongEvaluator(Source source, EvalOperator.ExpressionEvaluator field1, EvalOperator.ExpressionEvaluator field2, DriverContext driverContext) { + this.source = source; this.field1 = field1; this.field2 = field2; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -75,6 +77,18 @@ public final class MvAppendLongEvaluator implements EvalOperator.ExpressionEvalu Releasables.closeExpectNoException(field1, field2); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumDoubleEvaluator.java index 5f6bc8361c1b..7ff79b0a0708 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPSeriesWeightedSumDoubleEvaluator.java @@ -13,17 +13,17 @@ import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.search.aggregations.metrics.CompensatedSum; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvPSeriesWeightedSum}. * This class is generated. Do not edit it. */ public final class MvPSeriesWeightedSumDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator block; @@ -33,13 +33,15 @@ public final class MvPSeriesWeightedSumDoubleEvaluator implements EvalOperator.E private final DriverContext driverContext; + private Warnings warnings; + public MvPSeriesWeightedSumDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator block, CompensatedSum sum, double p, DriverContext driverContext) { + this.source = source; this.block = block; this.sum = sum; this.p = p; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -63,7 +65,7 @@ public final class MvPSeriesWeightedSumDoubleEvaluator implements EvalOperator.E try { MvPSeriesWeightedSum.process(result, p, blockBlock, this.sum, this.p); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -81,6 +83,18 @@ public final class MvPSeriesWeightedSumDoubleEvaluator implements EvalOperator.E Releasables.closeExpectNoException(block); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileDoubleEvaluator.java index dd370e90b2c8..7f7fdd42a237 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileDoubleEvaluator.java @@ -13,16 +13,16 @@ import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvPercentile}. * This class is generated. Do not edit it. */ public final class MvPercentileDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator values; @@ -32,14 +32,16 @@ public final class MvPercentileDoubleEvaluator implements EvalOperator.Expressio private final DriverContext driverContext; + private Warnings warnings; + public MvPercentileDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator values, EvalOperator.ExpressionEvaluator percentile, MvPercentile.DoubleSortingScratch scratch, DriverContext driverContext) { + this.source = source; this.values = values; this.percentile = percentile; this.scratch = scratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -64,7 +66,7 @@ public final class MvPercentileDoubleEvaluator implements EvalOperator.Expressio } if (percentileBlock.getValueCount(p) != 1) { if (percentileBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class MvPercentileDoubleEvaluator implements EvalOperator.Expressio try { MvPercentile.process(result, p, valuesBlock, percentileBlock.getDouble(percentileBlock.getFirstValueIndex(p)), this.scratch); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -94,6 +96,18 @@ public final class MvPercentileDoubleEvaluator implements EvalOperator.Expressio Releasables.closeExpectNoException(values, percentile); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileIntegerEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileIntegerEvaluator.java index 93dda414c7b3..ed55fe6f556a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileIntegerEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileIntegerEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.IntBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvPercentile}. * This class is generated. Do not edit it. */ public final class MvPercentileIntegerEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator values; @@ -33,14 +33,16 @@ public final class MvPercentileIntegerEvaluator implements EvalOperator.Expressi private final DriverContext driverContext; + private Warnings warnings; + public MvPercentileIntegerEvaluator(Source source, EvalOperator.ExpressionEvaluator values, EvalOperator.ExpressionEvaluator percentile, MvPercentile.IntSortingScratch scratch, DriverContext driverContext) { + this.source = source; this.values = values; this.percentile = percentile; this.scratch = scratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class MvPercentileIntegerEvaluator implements EvalOperator.Expressi } if (percentileBlock.getValueCount(p) != 1) { if (percentileBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class MvPercentileIntegerEvaluator implements EvalOperator.Expressi try { MvPercentile.process(result, p, valuesBlock, percentileBlock.getDouble(percentileBlock.getFirstValueIndex(p)), this.scratch); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -95,6 +97,18 @@ public final class MvPercentileIntegerEvaluator implements EvalOperator.Expressi Releasables.closeExpectNoException(values, percentile); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileLongEvaluator.java index 10d0b7c3283b..f57de7c35d82 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvPercentileLongEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvPercentile}. * This class is generated. Do not edit it. */ public final class MvPercentileLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator values; @@ -33,14 +33,16 @@ public final class MvPercentileLongEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public MvPercentileLongEvaluator(Source source, EvalOperator.ExpressionEvaluator values, EvalOperator.ExpressionEvaluator percentile, MvPercentile.LongSortingScratch scratch, DriverContext driverContext) { + this.source = source; this.values = values; this.percentile = percentile; this.scratch = scratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class MvPercentileLongEvaluator implements EvalOperator.ExpressionE } if (percentileBlock.getValueCount(p) != 1) { if (percentileBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class MvPercentileLongEvaluator implements EvalOperator.ExpressionE try { MvPercentile.process(result, p, valuesBlock, percentileBlock.getDouble(percentileBlock.getFirstValueIndex(p)), this.scratch); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -95,6 +97,18 @@ public final class MvPercentileLongEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(values, percentile); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBooleanEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBooleanEvaluator.java index 294cdb4373c8..ae04f0916c47 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBooleanEvaluator.java @@ -13,17 +13,17 @@ import org.elasticsearch.compute.data.IntBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSlice}. * This class is generated. Do not edit it. */ public final class MvSliceBooleanEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field; @@ -33,14 +33,16 @@ public final class MvSliceBooleanEvaluator implements EvalOperator.ExpressionEva private final DriverContext driverContext; + private Warnings warnings; + public MvSliceBooleanEvaluator(Source source, EvalOperator.ExpressionEvaluator field, EvalOperator.ExpressionEvaluator start, EvalOperator.ExpressionEvaluator end, DriverContext driverContext) { + this.source = source; this.field = field; this.start = start; this.end = end; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -68,7 +70,7 @@ public final class MvSliceBooleanEvaluator implements EvalOperator.ExpressionEva } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -79,7 +81,7 @@ public final class MvSliceBooleanEvaluator implements EvalOperator.ExpressionEva } if (endBlock.getValueCount(p) != 1) { if (endBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class MvSliceBooleanEvaluator implements EvalOperator.ExpressionEva try { MvSlice.process(result, p, fieldBlock, startBlock.getInt(startBlock.getFirstValueIndex(p)), endBlock.getInt(endBlock.getFirstValueIndex(p))); } catch (InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -109,6 +111,18 @@ public final class MvSliceBooleanEvaluator implements EvalOperator.ExpressionEva Releasables.closeExpectNoException(field, start, end); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBytesRefEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBytesRefEvaluator.java index ce17962a5939..a366b4ae765e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBytesRefEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceBytesRefEvaluator.java @@ -13,17 +13,17 @@ import org.elasticsearch.compute.data.IntBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSlice}. * This class is generated. Do not edit it. */ public final class MvSliceBytesRefEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field; @@ -33,14 +33,16 @@ public final class MvSliceBytesRefEvaluator implements EvalOperator.ExpressionEv private final DriverContext driverContext; + private Warnings warnings; + public MvSliceBytesRefEvaluator(Source source, EvalOperator.ExpressionEvaluator field, EvalOperator.ExpressionEvaluator start, EvalOperator.ExpressionEvaluator end, DriverContext driverContext) { + this.source = source; this.field = field; this.start = start; this.end = end; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -68,7 +70,7 @@ public final class MvSliceBytesRefEvaluator implements EvalOperator.ExpressionEv } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -79,7 +81,7 @@ public final class MvSliceBytesRefEvaluator implements EvalOperator.ExpressionEv } if (endBlock.getValueCount(p) != 1) { if (endBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class MvSliceBytesRefEvaluator implements EvalOperator.ExpressionEv try { MvSlice.process(result, p, fieldBlock, startBlock.getInt(startBlock.getFirstValueIndex(p)), endBlock.getInt(endBlock.getFirstValueIndex(p))); } catch (InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -109,6 +111,18 @@ public final class MvSliceBytesRefEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(field, start, end); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceDoubleEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceDoubleEvaluator.java index 30cd51f2b23c..1607bcf07870 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceDoubleEvaluator.java @@ -13,17 +13,17 @@ import org.elasticsearch.compute.data.IntBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSlice}. * This class is generated. Do not edit it. */ public final class MvSliceDoubleEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field; @@ -33,14 +33,16 @@ public final class MvSliceDoubleEvaluator implements EvalOperator.ExpressionEval private final DriverContext driverContext; + private Warnings warnings; + public MvSliceDoubleEvaluator(Source source, EvalOperator.ExpressionEvaluator field, EvalOperator.ExpressionEvaluator start, EvalOperator.ExpressionEvaluator end, DriverContext driverContext) { + this.source = source; this.field = field; this.start = start; this.end = end; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -68,7 +70,7 @@ public final class MvSliceDoubleEvaluator implements EvalOperator.ExpressionEval } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -79,7 +81,7 @@ public final class MvSliceDoubleEvaluator implements EvalOperator.ExpressionEval } if (endBlock.getValueCount(p) != 1) { if (endBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class MvSliceDoubleEvaluator implements EvalOperator.ExpressionEval try { MvSlice.process(result, p, fieldBlock, startBlock.getInt(startBlock.getFirstValueIndex(p)), endBlock.getInt(endBlock.getFirstValueIndex(p))); } catch (InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -109,6 +111,18 @@ public final class MvSliceDoubleEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(field, start, end); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceIntEvaluator.java index cf8e9babc88b..69bcc2f8998f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceIntEvaluator.java @@ -12,17 +12,17 @@ import org.elasticsearch.compute.data.IntBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSlice}. * This class is generated. Do not edit it. */ public final class MvSliceIntEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field; @@ -32,14 +32,16 @@ public final class MvSliceIntEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public MvSliceIntEvaluator(Source source, EvalOperator.ExpressionEvaluator field, EvalOperator.ExpressionEvaluator start, EvalOperator.ExpressionEvaluator end, DriverContext driverContext) { + this.source = source; this.field = field; this.start = start; this.end = end; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class MvSliceIntEvaluator implements EvalOperator.ExpressionEvaluat } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -78,7 +80,7 @@ public final class MvSliceIntEvaluator implements EvalOperator.ExpressionEvaluat } if (endBlock.getValueCount(p) != 1) { if (endBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -90,7 +92,7 @@ public final class MvSliceIntEvaluator implements EvalOperator.ExpressionEvaluat try { MvSlice.process(result, p, fieldBlock, startBlock.getInt(startBlock.getFirstValueIndex(p)), endBlock.getInt(endBlock.getFirstValueIndex(p))); } catch (InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -108,6 +110,18 @@ public final class MvSliceIntEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(field, start, end); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceLongEvaluator.java index e7e2b7f643db..ad5a55a50621 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSliceLongEvaluator.java @@ -13,17 +13,17 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.InvalidArgumentException; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSlice}. * This class is generated. Do not edit it. */ public final class MvSliceLongEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator field; @@ -33,14 +33,16 @@ public final class MvSliceLongEvaluator implements EvalOperator.ExpressionEvalua private final DriverContext driverContext; + private Warnings warnings; + public MvSliceLongEvaluator(Source source, EvalOperator.ExpressionEvaluator field, EvalOperator.ExpressionEvaluator start, EvalOperator.ExpressionEvaluator end, DriverContext driverContext) { + this.source = source; this.field = field; this.start = start; this.end = end; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -68,7 +70,7 @@ public final class MvSliceLongEvaluator implements EvalOperator.ExpressionEvalua } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -79,7 +81,7 @@ public final class MvSliceLongEvaluator implements EvalOperator.ExpressionEvalua } if (endBlock.getValueCount(p) != 1) { if (endBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class MvSliceLongEvaluator implements EvalOperator.ExpressionEvalua try { MvSlice.process(result, p, fieldBlock, startBlock.getInt(startBlock.getFirstValueIndex(p)), endBlock.getInt(endBlock.getFirstValueIndex(p))); } catch (InvalidArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -109,6 +111,18 @@ public final class MvSliceLongEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(field, start, end); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumIntEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumIntEvaluator.java index a61b8f71a04a..8f27c4f472ba 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumIntEvaluator.java @@ -11,20 +11,22 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.IntBlock; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSum}. * This class is generated. Do not edit it. */ public final class MvSumIntEvaluator extends AbstractMultivalueFunction.AbstractNullableEvaluator { - private final Warnings warnings; + private final Source source; + + private Warnings warnings; public MvSumIntEvaluator(Source source, EvalOperator.ExpressionEvaluator field, DriverContext driverContext) { super(driverContext, field); - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); + this.source = source; } @Override @@ -57,7 +59,7 @@ public final class MvSumIntEvaluator extends AbstractMultivalueFunction.Abstract int result = value; builder.appendInt(result); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); builder.appendNull(); } } @@ -65,6 +67,18 @@ public final class MvSumIntEvaluator extends AbstractMultivalueFunction.Abstract } } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + public static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumLongEvaluator.java index 6d37a1e7780e..8e4d183279e7 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumLongEvaluator.java @@ -11,20 +11,22 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSum}. * This class is generated. Do not edit it. */ public final class MvSumLongEvaluator extends AbstractMultivalueFunction.AbstractNullableEvaluator { - private final Warnings warnings; + private final Source source; + + private Warnings warnings; public MvSumLongEvaluator(Source source, EvalOperator.ExpressionEvaluator field, DriverContext driverContext) { super(driverContext, field); - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); + this.source = source; } @Override @@ -57,7 +59,7 @@ public final class MvSumLongEvaluator extends AbstractMultivalueFunction.Abstrac long result = value; builder.appendLong(result); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); builder.appendNull(); } } @@ -65,6 +67,18 @@ public final class MvSumLongEvaluator extends AbstractMultivalueFunction.Abstrac } } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + public static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumUnsignedLongEvaluator.java index 9db3b2a2afde..e17b5934271d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvSumUnsignedLongEvaluator.java @@ -11,20 +11,22 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvSum}. * This class is generated. Do not edit it. */ public final class MvSumUnsignedLongEvaluator extends AbstractMultivalueFunction.AbstractNullableEvaluator { - private final Warnings warnings; + private final Source source; + + private Warnings warnings; public MvSumUnsignedLongEvaluator(Source source, EvalOperator.ExpressionEvaluator field, DriverContext driverContext) { super(driverContext, field); - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); + this.source = source; } @Override @@ -57,7 +59,7 @@ public final class MvSumUnsignedLongEvaluator extends AbstractMultivalueFunction long result = value; builder.appendLong(result); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); builder.appendNull(); } } @@ -65,6 +67,18 @@ public final class MvSumUnsignedLongEvaluator extends AbstractMultivalueFunction } } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + public static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipEvaluator.java index e307400f9869..9f204abbe0b4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvZipEvaluator.java @@ -13,16 +13,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link MvZip}. * This class is generated. Do not edit it. */ public final class MvZipEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftField; @@ -32,14 +32,16 @@ public final class MvZipEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public MvZipEvaluator(Source source, EvalOperator.ExpressionEvaluator leftField, EvalOperator.ExpressionEvaluator rightField, EvalOperator.ExpressionEvaluator delim, DriverContext driverContext) { + this.source = source; this.leftField = leftField; this.rightField = rightField; this.delim = delim; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class MvZipEvaluator implements EvalOperator.ExpressionEvaluator { } if (delimBlock.getValueCount(p) != 1) { if (delimBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -96,6 +98,18 @@ public final class MvZipEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(leftField, rightField, delim); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndConstantEvaluator.java index fbe0b57f775e..6d22335fb91e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsCartesianPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialContainsCartesianPointDocValuesAndConstantEvaluator im private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsCartesianPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D[] right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialContainsCartesianPointDocValuesAndConstantEvaluator im try { SpatialContains.processCartesianPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialContainsCartesianPointDocValuesAndConstantEvaluator im Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndSourceEvaluator.java index 074415f0eb4d..593bfdec0132 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsCartesianPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialContainsCartesianPointDocValuesAndSourceEvaluator impl private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsCartesianPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialContainsCartesianPointDocValuesAndSourceEvaluator impl try { SpatialContains.processCartesianPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialContainsCartesianPointDocValuesAndSourceEvaluator impl Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndConstantEvaluator.java index e20df8977b97..79639505283a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsCartesianSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialContainsCartesianSourceAndConstantEvaluator implements private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsCartesianSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D[] right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialContainsCartesianSourceAndConstantEvaluator implements try { SpatialContains.processCartesianSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialContainsCartesianSourceAndConstantEvaluator implements Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndSourceEvaluator.java index a3022e3ac320..3d91a4323ba4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsCartesianSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsCartesianSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialContainsCartesianSourceAndSourceEvaluator implements E private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsCartesianSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialContainsCartesianSourceAndSourceEvaluator implements E try { SpatialContains.processCartesianSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialContainsCartesianSourceAndSourceEvaluator implements E Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndConstantEvaluator.java index c5ca55384057..0a4c1e5c69bf 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsGeoPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialContainsGeoPointDocValuesAndConstantEvaluator implemen private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsGeoPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D[] right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialContainsGeoPointDocValuesAndConstantEvaluator implemen try { SpatialContains.processGeoPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialContainsGeoPointDocValuesAndConstantEvaluator implemen Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndSourceEvaluator.java index 593818c57730..523546ffa5a3 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsGeoPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialContainsGeoPointDocValuesAndSourceEvaluator implements private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsGeoPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialContainsGeoPointDocValuesAndSourceEvaluator implements try { SpatialContains.processGeoPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialContainsGeoPointDocValuesAndSourceEvaluator implements Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndConstantEvaluator.java index 1b7d5243468e..328565fd089c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsGeoSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialContainsGeoSourceAndConstantEvaluator implements EvalO private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsGeoSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D[] right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialContainsGeoSourceAndConstantEvaluator implements EvalO try { SpatialContains.processGeoSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialContainsGeoSourceAndConstantEvaluator implements EvalO Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndSourceEvaluator.java index 8cd5d5bc07dc..da46839694c4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialContainsGeoSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialContains}. * This class is generated. Do not edit it. */ public final class SpatialContainsGeoSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialContainsGeoSourceAndSourceEvaluator implements EvalOpe private final DriverContext driverContext; + private Warnings warnings; + public SpatialContainsGeoSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialContainsGeoSourceAndSourceEvaluator implements EvalOpe try { SpatialContains.processGeoSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialContainsGeoSourceAndSourceEvaluator implements EvalOpe Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndConstantEvaluator.java index f4bcc51a6add..5560d1d90b6a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointCartesianPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialDisjointCartesianPointDocValuesAndConstantEvaluator im private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointCartesianPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialDisjointCartesianPointDocValuesAndConstantEvaluator im try { SpatialDisjoint.processCartesianPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialDisjointCartesianPointDocValuesAndConstantEvaluator im Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndSourceEvaluator.java index e7e1945e5f3f..4f6197a3cde4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointCartesianPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialDisjointCartesianPointDocValuesAndSourceEvaluator impl private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointCartesianPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialDisjointCartesianPointDocValuesAndSourceEvaluator impl try { SpatialDisjoint.processCartesianPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialDisjointCartesianPointDocValuesAndSourceEvaluator impl Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndConstantEvaluator.java index 009eb5e50e3b..45b9a1f2251e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointCartesianSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialDisjointCartesianSourceAndConstantEvaluator implements private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointCartesianSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialDisjointCartesianSourceAndConstantEvaluator implements try { SpatialDisjoint.processCartesianSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialDisjointCartesianSourceAndConstantEvaluator implements Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndSourceEvaluator.java index 990354d3882c..0a18ad86cf8b 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointCartesianSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointCartesianSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialDisjointCartesianSourceAndSourceEvaluator implements E private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointCartesianSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialDisjointCartesianSourceAndSourceEvaluator implements E try { SpatialDisjoint.processCartesianSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialDisjointCartesianSourceAndSourceEvaluator implements E Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndConstantEvaluator.java index 3b8f5b93fd24..f379e6502e9f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointGeoPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialDisjointGeoPointDocValuesAndConstantEvaluator implemen private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointGeoPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialDisjointGeoPointDocValuesAndConstantEvaluator implemen try { SpatialDisjoint.processGeoPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialDisjointGeoPointDocValuesAndConstantEvaluator implemen Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndSourceEvaluator.java index d243c8ebb9f0..0411ca8e61df 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointGeoPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialDisjointGeoPointDocValuesAndSourceEvaluator implements private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointGeoPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialDisjointGeoPointDocValuesAndSourceEvaluator implements try { SpatialDisjoint.processGeoPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialDisjointGeoPointDocValuesAndSourceEvaluator implements Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndConstantEvaluator.java index 84a0930c67a5..f24c8991e0ba 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointGeoSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialDisjointGeoSourceAndConstantEvaluator implements EvalO private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointGeoSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialDisjointGeoSourceAndConstantEvaluator implements EvalO try { SpatialDisjoint.processGeoSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialDisjointGeoSourceAndConstantEvaluator implements EvalO Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndSourceEvaluator.java index 461742e430e3..ae9c3d2c4d32 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialDisjointGeoSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialDisjoint}. * This class is generated. Do not edit it. */ public final class SpatialDisjointGeoSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialDisjointGeoSourceAndSourceEvaluator implements EvalOpe private final DriverContext driverContext; + private Warnings warnings; + public SpatialDisjointGeoSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialDisjointGeoSourceAndSourceEvaluator implements EvalOpe try { SpatialDisjoint.processGeoSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialDisjointGeoSourceAndSourceEvaluator implements EvalOpe Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator.java index 957a7c805a30..c9d1493c4e10 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator try { SpatialIntersects.processCartesianPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialIntersectsCartesianPointDocValuesAndConstantEvaluator Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator.java index 0188d796e4d2..330e06a00f48 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator im private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator im try { SpatialIntersects.processCartesianPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialIntersectsCartesianPointDocValuesAndSourceEvaluator im Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndConstantEvaluator.java index 9fe1ca365f26..6b5167d136cf 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsCartesianSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialIntersectsCartesianSourceAndConstantEvaluator implemen private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsCartesianSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialIntersectsCartesianSourceAndConstantEvaluator implemen try { SpatialIntersects.processCartesianSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialIntersectsCartesianSourceAndConstantEvaluator implemen Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndSourceEvaluator.java index d3301d829d8e..c96e912b6492 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsCartesianSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsCartesianSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialIntersectsCartesianSourceAndSourceEvaluator implements private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsCartesianSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialIntersectsCartesianSourceAndSourceEvaluator implements try { SpatialIntersects.processCartesianSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialIntersectsCartesianSourceAndSourceEvaluator implements Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndConstantEvaluator.java index c11cd69d916c..9cdd7e345f8c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsGeoPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialIntersectsGeoPointDocValuesAndConstantEvaluator implem private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsGeoPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialIntersectsGeoPointDocValuesAndConstantEvaluator implem try { SpatialIntersects.processGeoPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialIntersectsGeoPointDocValuesAndConstantEvaluator implem Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndSourceEvaluator.java index 12337bf888e5..50497429eac4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsGeoPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialIntersectsGeoPointDocValuesAndSourceEvaluator implemen private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsGeoPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialIntersectsGeoPointDocValuesAndSourceEvaluator implemen try { SpatialIntersects.processGeoPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialIntersectsGeoPointDocValuesAndSourceEvaluator implemen Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndConstantEvaluator.java index f75c1c698792..92d2bd55021b 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsGeoSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialIntersectsGeoSourceAndConstantEvaluator implements Eva private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsGeoSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialIntersectsGeoSourceAndConstantEvaluator implements Eva try { SpatialIntersects.processGeoSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialIntersectsGeoSourceAndConstantEvaluator implements Eva Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndSourceEvaluator.java index a8a3f02ddbd9..06033360dd6c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialIntersectsGeoSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialIntersects}. * This class is generated. Do not edit it. */ public final class SpatialIntersectsGeoSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialIntersectsGeoSourceAndSourceEvaluator implements EvalO private final DriverContext driverContext; + private Warnings warnings; + public SpatialIntersectsGeoSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialIntersectsGeoSourceAndSourceEvaluator implements EvalO try { SpatialIntersects.processGeoSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialIntersectsGeoSourceAndSourceEvaluator implements EvalO Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndConstantEvaluator.java index b4780c8829b2..55e86b398a9a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinCartesianPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialWithinCartesianPointDocValuesAndConstantEvaluator impl private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinCartesianPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialWithinCartesianPointDocValuesAndConstantEvaluator impl try { SpatialWithin.processCartesianPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialWithinCartesianPointDocValuesAndConstantEvaluator impl Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndSourceEvaluator.java index 006ff30af5e1..0d9e7d8c460a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinCartesianPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialWithinCartesianPointDocValuesAndSourceEvaluator implem private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinCartesianPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialWithinCartesianPointDocValuesAndSourceEvaluator implem try { SpatialWithin.processCartesianPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialWithinCartesianPointDocValuesAndSourceEvaluator implem Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndConstantEvaluator.java index d835170c8604..011ba3df96da 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinCartesianSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialWithinCartesianSourceAndConstantEvaluator implements E private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinCartesianSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialWithinCartesianSourceAndConstantEvaluator implements E try { SpatialWithin.processCartesianSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialWithinCartesianSourceAndConstantEvaluator implements E Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndSourceEvaluator.java index 5e46c1afd9e4..e07f5203a45c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinCartesianSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinCartesianSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialWithinCartesianSourceAndSourceEvaluator implements Eva private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinCartesianSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialWithinCartesianSourceAndSourceEvaluator implements Eva try { SpatialWithin.processCartesianSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialWithinCartesianSourceAndSourceEvaluator implements Eva Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndConstantEvaluator.java index b9676f2a5a36..82285639768d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinGeoPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialWithinGeoPointDocValuesAndConstantEvaluator implements private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinGeoPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialWithinGeoPointDocValuesAndConstantEvaluator implements try { SpatialWithin.processGeoPointDocValuesAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialWithinGeoPointDocValuesAndConstantEvaluator implements Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndSourceEvaluator.java index 4d56cd8ecdde..33bd70b76ae9 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoPointDocValuesAndSourceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinGeoPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,13 +32,15 @@ public final class SpatialWithinGeoPointDocValuesAndSourceEvaluator implements E private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinGeoPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -67,7 +69,7 @@ public final class SpatialWithinGeoPointDocValuesAndSourceEvaluator implements E try { SpatialWithin.processGeoPointDocValuesAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -85,6 +87,18 @@ public final class SpatialWithinGeoPointDocValuesAndSourceEvaluator implements E Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndConstantEvaluator.java index a0535c9e8db7..9335e0d93e0a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndConstantEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinGeoSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -32,12 +32,14 @@ public final class SpatialWithinGeoSourceAndConstantEvaluator implements EvalOpe private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinGeoSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator left, Component2D right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpatialWithinGeoSourceAndConstantEvaluator implements EvalOpe try { SpatialWithin.processGeoSourceAndConstant(result, p, leftBlock, this.right); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -79,6 +81,18 @@ public final class SpatialWithinGeoSourceAndConstantEvaluator implements EvalOpe Releasables.closeExpectNoException(left); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndSourceEvaluator.java index 9305b31e5582..665f4c94722d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/SpatialWithinGeoSourceAndSourceEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link SpatialWithin}. * This class is generated. Do not edit it. */ public final class SpatialWithinGeoSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator left; @@ -31,13 +31,15 @@ public final class SpatialWithinGeoSourceAndSourceEvaluator implements EvalOpera private final DriverContext driverContext; + private Warnings warnings; + public SpatialWithinGeoSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator left, EvalOperator.ExpressionEvaluator right, DriverContext driverContext) { + this.source = source; this.left = left; this.right = right; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class SpatialWithinGeoSourceAndSourceEvaluator implements EvalOpera try { SpatialWithin.processGeoSourceAndSource(result, p, leftBlock, rightBlock); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -84,6 +86,18 @@ public final class SpatialWithinGeoSourceAndSourceEvaluator implements EvalOpera Releasables.closeExpectNoException(left, right); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndConstantEvaluator.java index 01d70b2a5336..a3fc2fadbf22 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndConstantEvaluator.java @@ -14,17 +14,17 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.geometry.Point; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceCartesianPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -32,12 +32,14 @@ public final class StDistanceCartesianPointDocValuesAndConstantEvaluator impleme private final DriverContext driverContext; + private Warnings warnings; + public StDistanceCartesianPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, Point rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -60,7 +62,7 @@ public final class StDistanceCartesianPointDocValuesAndConstantEvaluator impleme } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -68,7 +70,7 @@ public final class StDistanceCartesianPointDocValuesAndConstantEvaluator impleme try { result.appendDouble(StDistance.processCartesianPointDocValuesAndConstant(leftValueBlock.getLong(leftValueBlock.getFirstValueIndex(p)), this.rightValue)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -82,7 +84,7 @@ public final class StDistanceCartesianPointDocValuesAndConstantEvaluator impleme try { result.appendDouble(StDistance.processCartesianPointDocValuesAndConstant(leftValueVector.getLong(p), this.rightValue)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -100,6 +102,18 @@ public final class StDistanceCartesianPointDocValuesAndConstantEvaluator impleme Releasables.closeExpectNoException(leftValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndSourceEvaluator.java index 13523eebdb2a..1da164436a2c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianPointDocValuesAndSourceEvaluator.java @@ -18,16 +18,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceCartesianPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -35,13 +35,15 @@ public final class StDistanceCartesianPointDocValuesAndSourceEvaluator implement private final DriverContext driverContext; + private Warnings warnings; + public StDistanceCartesianPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, EvalOperator.ExpressionEvaluator rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -72,7 +74,7 @@ public final class StDistanceCartesianPointDocValuesAndSourceEvaluator implement } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -83,7 +85,7 @@ public final class StDistanceCartesianPointDocValuesAndSourceEvaluator implement } if (rightValueBlock.getValueCount(p) != 1) { if (rightValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -115,6 +117,18 @@ public final class StDistanceCartesianPointDocValuesAndSourceEvaluator implement Releasables.closeExpectNoException(leftValue, rightValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndConstantEvaluator.java index b4f3dbc3df32..61329ad7606d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndConstantEvaluator.java @@ -16,17 +16,17 @@ import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.geometry.Point; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceCartesianSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -34,12 +34,14 @@ public final class StDistanceCartesianSourceAndConstantEvaluator implements Eval private final DriverContext driverContext; + private Warnings warnings; + public StDistanceCartesianSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, Point rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -63,7 +65,7 @@ public final class StDistanceCartesianSourceAndConstantEvaluator implements Eval } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -71,7 +73,7 @@ public final class StDistanceCartesianSourceAndConstantEvaluator implements Eval try { result.appendDouble(StDistance.processCartesianSourceAndConstant(leftValueBlock.getBytesRef(leftValueBlock.getFirstValueIndex(p), leftValueScratch), this.rightValue)); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -86,7 +88,7 @@ public final class StDistanceCartesianSourceAndConstantEvaluator implements Eval try { result.appendDouble(StDistance.processCartesianSourceAndConstant(leftValueVector.getBytesRef(p, leftValueScratch), this.rightValue)); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -104,6 +106,18 @@ public final class StDistanceCartesianSourceAndConstantEvaluator implements Eval Releasables.closeExpectNoException(leftValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndSourceEvaluator.java index 537275d14d3a..c18c9a56fa77 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceCartesianSourceAndSourceEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceCartesianSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -33,13 +33,15 @@ public final class StDistanceCartesianSourceAndSourceEvaluator implements EvalOp private final DriverContext driverContext; + private Warnings warnings; + public StDistanceCartesianSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, EvalOperator.ExpressionEvaluator rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class StDistanceCartesianSourceAndSourceEvaluator implements EvalOp } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -82,7 +84,7 @@ public final class StDistanceCartesianSourceAndSourceEvaluator implements EvalOp } if (rightValueBlock.getValueCount(p) != 1) { if (rightValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -90,7 +92,7 @@ public final class StDistanceCartesianSourceAndSourceEvaluator implements EvalOp try { result.appendDouble(StDistance.processCartesianSourceAndSource(leftValueBlock.getBytesRef(leftValueBlock.getFirstValueIndex(p), leftValueScratch), rightValueBlock.getBytesRef(rightValueBlock.getFirstValueIndex(p), rightValueScratch))); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -107,7 +109,7 @@ public final class StDistanceCartesianSourceAndSourceEvaluator implements EvalOp try { result.appendDouble(StDistance.processCartesianSourceAndSource(leftValueVector.getBytesRef(p, leftValueScratch), rightValueVector.getBytesRef(p, rightValueScratch))); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -125,6 +127,18 @@ public final class StDistanceCartesianSourceAndSourceEvaluator implements EvalOp Releasables.closeExpectNoException(leftValue, rightValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndConstantEvaluator.java index b0980697e937..2ac1ff6aeb0d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndConstantEvaluator.java @@ -14,17 +14,17 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.geometry.Point; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceGeoPointDocValuesAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -32,12 +32,14 @@ public final class StDistanceGeoPointDocValuesAndConstantEvaluator implements Ev private final DriverContext driverContext; + private Warnings warnings; + public StDistanceGeoPointDocValuesAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, Point rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -60,7 +62,7 @@ public final class StDistanceGeoPointDocValuesAndConstantEvaluator implements Ev } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -68,7 +70,7 @@ public final class StDistanceGeoPointDocValuesAndConstantEvaluator implements Ev try { result.appendDouble(StDistance.processGeoPointDocValuesAndConstant(leftValueBlock.getLong(leftValueBlock.getFirstValueIndex(p)), this.rightValue)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -82,7 +84,7 @@ public final class StDistanceGeoPointDocValuesAndConstantEvaluator implements Ev try { result.appendDouble(StDistance.processGeoPointDocValuesAndConstant(leftValueVector.getLong(p), this.rightValue)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -100,6 +102,18 @@ public final class StDistanceGeoPointDocValuesAndConstantEvaluator implements Ev Releasables.closeExpectNoException(leftValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndSourceEvaluator.java index 0bd1c4b6f5bd..6758d888cc7d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoPointDocValuesAndSourceEvaluator.java @@ -17,16 +17,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceGeoPointDocValuesAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -34,13 +34,15 @@ public final class StDistanceGeoPointDocValuesAndSourceEvaluator implements Eval private final DriverContext driverContext; + private Warnings warnings; + public StDistanceGeoPointDocValuesAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, EvalOperator.ExpressionEvaluator rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class StDistanceGeoPointDocValuesAndSourceEvaluator implements Eval } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -82,7 +84,7 @@ public final class StDistanceGeoPointDocValuesAndSourceEvaluator implements Eval } if (rightValueBlock.getValueCount(p) != 1) { if (rightValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -90,7 +92,7 @@ public final class StDistanceGeoPointDocValuesAndSourceEvaluator implements Eval try { result.appendDouble(StDistance.processGeoPointDocValuesAndSource(leftValueBlock.getLong(leftValueBlock.getFirstValueIndex(p)), rightValueBlock.getBytesRef(rightValueBlock.getFirstValueIndex(p), rightValueScratch))); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -106,7 +108,7 @@ public final class StDistanceGeoPointDocValuesAndSourceEvaluator implements Eval try { result.appendDouble(StDistance.processGeoPointDocValuesAndSource(leftValueVector.getLong(p), rightValueVector.getBytesRef(p, rightValueScratch))); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -124,6 +126,18 @@ public final class StDistanceGeoPointDocValuesAndSourceEvaluator implements Eval Releasables.closeExpectNoException(leftValue, rightValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndConstantEvaluator.java index 70bcc64e5883..201c29cb0427 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndConstantEvaluator.java @@ -16,17 +16,17 @@ import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.geometry.Point; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceGeoSourceAndConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -34,12 +34,14 @@ public final class StDistanceGeoSourceAndConstantEvaluator implements EvalOperat private final DriverContext driverContext; + private Warnings warnings; + public StDistanceGeoSourceAndConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, Point rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -63,7 +65,7 @@ public final class StDistanceGeoSourceAndConstantEvaluator implements EvalOperat } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -71,7 +73,7 @@ public final class StDistanceGeoSourceAndConstantEvaluator implements EvalOperat try { result.appendDouble(StDistance.processGeoSourceAndConstant(leftValueBlock.getBytesRef(leftValueBlock.getFirstValueIndex(p), leftValueScratch), this.rightValue)); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -86,7 +88,7 @@ public final class StDistanceGeoSourceAndConstantEvaluator implements EvalOperat try { result.appendDouble(StDistance.processGeoSourceAndConstant(leftValueVector.getBytesRef(p, leftValueScratch), this.rightValue)); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -104,6 +106,18 @@ public final class StDistanceGeoSourceAndConstantEvaluator implements EvalOperat Releasables.closeExpectNoException(leftValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndSourceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndSourceEvaluator.java index 915c456a63f7..9cbe30e22c3e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndSourceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/spatial/StDistanceGeoSourceAndSourceEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StDistance}. * This class is generated. Do not edit it. */ public final class StDistanceGeoSourceAndSourceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator leftValue; @@ -33,13 +33,15 @@ public final class StDistanceGeoSourceAndSourceEvaluator implements EvalOperator private final DriverContext driverContext; + private Warnings warnings; + public StDistanceGeoSourceAndSourceEvaluator(Source source, EvalOperator.ExpressionEvaluator leftValue, EvalOperator.ExpressionEvaluator rightValue, DriverContext driverContext) { + this.source = source; this.leftValue = leftValue; this.rightValue = rightValue; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class StDistanceGeoSourceAndSourceEvaluator implements EvalOperator } if (leftValueBlock.getValueCount(p) != 1) { if (leftValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -82,7 +84,7 @@ public final class StDistanceGeoSourceAndSourceEvaluator implements EvalOperator } if (rightValueBlock.getValueCount(p) != 1) { if (rightValueBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -90,7 +92,7 @@ public final class StDistanceGeoSourceAndSourceEvaluator implements EvalOperator try { result.appendDouble(StDistance.processGeoSourceAndSource(leftValueBlock.getBytesRef(leftValueBlock.getFirstValueIndex(p), leftValueScratch), rightValueBlock.getBytesRef(rightValueBlock.getFirstValueIndex(p), rightValueScratch))); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -107,7 +109,7 @@ public final class StDistanceGeoSourceAndSourceEvaluator implements EvalOperator try { result.appendDouble(StDistance.processGeoSourceAndSource(leftValueVector.getBytesRef(p, leftValueScratch), rightValueVector.getBytesRef(p, rightValueScratch))); } catch (IllegalArgumentException | IOException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -125,6 +127,18 @@ public final class StDistanceGeoSourceAndSourceEvaluator implements EvalOperator Releasables.closeExpectNoException(leftValue, rightValue); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/AutomataMatchEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/AutomataMatchEvaluator.java index 96726b310a65..1352e5650bbf 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/AutomataMatchEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/AutomataMatchEvaluator.java @@ -17,16 +17,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link AutomataMatch}. * This class is generated. Do not edit it. */ public final class AutomataMatchEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator input; @@ -36,13 +36,15 @@ public final class AutomataMatchEvaluator implements EvalOperator.ExpressionEval private final DriverContext driverContext; + private Warnings warnings; + public AutomataMatchEvaluator(Source source, EvalOperator.ExpressionEvaluator input, ByteRunAutomaton automaton, String pattern, DriverContext driverContext) { + this.source = source; this.input = input; this.automaton = automaton; this.pattern = pattern; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class AutomataMatchEvaluator implements EvalOperator.ExpressionEval } if (inputBlock.getValueCount(p) != 1) { if (inputBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -97,6 +99,18 @@ public final class AutomataMatchEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(input); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatEvaluator.java index 955e05ae7445..e0cff017c14f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ConcatEvaluator.java @@ -17,17 +17,17 @@ import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.BreakingBytesRefBuilder; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Concat}. * This class is generated. Do not edit it. */ public final class ConcatEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final BreakingBytesRefBuilder scratch; @@ -35,12 +35,14 @@ public final class ConcatEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public ConcatEvaluator(Source source, BreakingBytesRefBuilder scratch, EvalOperator.ExpressionEvaluator[] values, DriverContext driverContext) { + this.source = source; this.scratch = scratch; this.values = values; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -76,7 +78,7 @@ public final class ConcatEvaluator implements EvalOperator.ExpressionEvaluator { } if (valuesBlocks[i].getValueCount(p) != 1) { if (valuesBlocks[i].getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -121,6 +123,18 @@ public final class ConcatEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(scratch, () -> Releasables.close(values)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithEvaluator.java index e075cdcff882..d3d6e02bd9d7 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/EndsWithEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link EndsWith}. * This class is generated. Do not edit it. */ public final class EndsWithEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -33,12 +33,14 @@ public final class EndsWithEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public EndsWithEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator suffix, DriverContext driverContext) { + this.source = source; this.str = str; this.suffix = suffix; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class EndsWithEvaluator implements EvalOperator.ExpressionEvaluator } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class EndsWithEvaluator implements EvalOperator.ExpressionEvaluator } if (suffixBlock.getValueCount(p) != 1) { if (suffixBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -113,6 +115,18 @@ public final class EndsWithEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(str, suffix); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LTrimEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LTrimEvaluator.java index 05c7c425ed9a..7925787425d6 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LTrimEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LTrimEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LTrim}. * This class is generated. Do not edit it. */ public final class LTrimEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public LTrimEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class LTrimEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -88,6 +90,18 @@ public final class LTrimEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftEvaluator.java index d932f4f1ea9b..9adcfbbdd9f3 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LeftEvaluator.java @@ -18,16 +18,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Left}. * This class is generated. Do not edit it. */ public final class LeftEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final BytesRef out; @@ -39,15 +39,17 @@ public final class LeftEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public LeftEvaluator(Source source, BytesRef out, UnicodeUtil.UTF8CodePoint cp, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator length, DriverContext driverContext) { + this.source = source; this.out = out; this.cp = cp; this.str = str; this.length = length; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -77,7 +79,7 @@ public final class LeftEvaluator implements EvalOperator.ExpressionEvaluator { } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -88,7 +90,7 @@ public final class LeftEvaluator implements EvalOperator.ExpressionEvaluator { } if (lengthBlock.getValueCount(p) != 1) { if (lengthBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -119,6 +121,18 @@ public final class LeftEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(str, length); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LengthEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LengthEvaluator.java index 5d71fa5a4d70..799f42241406 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LengthEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LengthEvaluator.java @@ -16,26 +16,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Length}. * This class is generated. Do not edit it. */ public final class LengthEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public LengthEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -59,7 +61,7 @@ public final class LengthEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -90,6 +92,18 @@ public final class LengthEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateEvaluator.java index 17430f8fc572..3ca7db9e5685 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Locate}. * This class is generated. Do not edit it. */ public final class LocateEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -35,14 +35,16 @@ public final class LocateEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public LocateEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator substr, EvalOperator.ExpressionEvaluator start, DriverContext driverContext) { + this.source = source; this.str = str; this.substr = substr; this.start = start; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -80,7 +82,7 @@ public final class LocateEvaluator implements EvalOperator.ExpressionEvaluator { } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class LocateEvaluator implements EvalOperator.ExpressionEvaluator { } if (substrBlock.getValueCount(p) != 1) { if (substrBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -102,7 +104,7 @@ public final class LocateEvaluator implements EvalOperator.ExpressionEvaluator { } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -135,6 +137,18 @@ public final class LocateEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(str, substr, start); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateNoStartEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateNoStartEvaluator.java index 9f206426a348..378252a4bbea 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateNoStartEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/LocateNoStartEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Locate}. * This class is generated. Do not edit it. */ public final class LocateNoStartEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -33,12 +33,14 @@ public final class LocateNoStartEvaluator implements EvalOperator.ExpressionEval private final DriverContext driverContext; + private Warnings warnings; + public LocateNoStartEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator substr, DriverContext driverContext) { + this.source = source; this.str = str; this.substr = substr; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class LocateNoStartEvaluator implements EvalOperator.ExpressionEval } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class LocateNoStartEvaluator implements EvalOperator.ExpressionEval } if (substrBlock.getValueCount(p) != 1) { if (substrBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class LocateNoStartEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(str, substr); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RTrimEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RTrimEvaluator.java index a6dcdb25f2df..6fdeeddd3ab9 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RTrimEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RTrimEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link RTrim}. * This class is generated. Do not edit it. */ public final class RTrimEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public RTrimEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class RTrimEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -88,6 +90,18 @@ public final class RTrimEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatConstantEvaluator.java index 3ba3f40a8ed5..e679842ed47a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatConstantEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.BreakingBytesRefBuilder; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Repeat}. * This class is generated. Do not edit it. */ public final class RepeatConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final BreakingBytesRefBuilder scratch; @@ -35,13 +35,15 @@ public final class RepeatConstantEvaluator implements EvalOperator.ExpressionEva private final DriverContext driverContext; + private Warnings warnings; + public RepeatConstantEvaluator(Source source, BreakingBytesRefBuilder scratch, EvalOperator.ExpressionEvaluator str, int number, DriverContext driverContext) { + this.source = source; this.scratch = scratch; this.str = str; this.number = number; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class RepeatConstantEvaluator implements EvalOperator.ExpressionEva } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -73,7 +75,7 @@ public final class RepeatConstantEvaluator implements EvalOperator.ExpressionEva try { result.appendBytesRef(Repeat.processConstantNumber(this.scratch, strBlock.getBytesRef(strBlock.getFirstValueIndex(p), strScratch), this.number)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -88,7 +90,7 @@ public final class RepeatConstantEvaluator implements EvalOperator.ExpressionEva try { result.appendBytesRef(Repeat.processConstantNumber(this.scratch, strVector.getBytesRef(p, strScratch), this.number)); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -106,6 +108,18 @@ public final class RepeatConstantEvaluator implements EvalOperator.ExpressionEva Releasables.closeExpectNoException(scratch, str); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatEvaluator.java index 313c99ad7c45..58e0aeb6af31 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RepeatEvaluator.java @@ -18,16 +18,16 @@ import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.BreakingBytesRefBuilder; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Repeat}. * This class is generated. Do not edit it. */ public final class RepeatEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final BreakingBytesRefBuilder scratch; @@ -37,14 +37,16 @@ public final class RepeatEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public RepeatEvaluator(Source source, BreakingBytesRefBuilder scratch, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator number, DriverContext driverContext) { + this.source = source; this.scratch = scratch; this.str = str; this.number = number; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -74,7 +76,7 @@ public final class RepeatEvaluator implements EvalOperator.ExpressionEvaluator { } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,7 +87,7 @@ public final class RepeatEvaluator implements EvalOperator.ExpressionEvaluator { } if (numberBlock.getValueCount(p) != 1) { if (numberBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -93,7 +95,7 @@ public final class RepeatEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendBytesRef(Repeat.process(this.scratch, strBlock.getBytesRef(strBlock.getFirstValueIndex(p), strScratch), numberBlock.getInt(numberBlock.getFirstValueIndex(p)))); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -108,7 +110,7 @@ public final class RepeatEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendBytesRef(Repeat.process(this.scratch, strVector.getBytesRef(p, strScratch), numberVector.getInt(p))); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -126,6 +128,18 @@ public final class RepeatEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(scratch, str, number); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceConstantEvaluator.java index 63623b8428fa..02a495285e6c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceConstantEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Replace}. * This class is generated. Do not edit it. */ public final class ReplaceConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -35,13 +35,15 @@ public final class ReplaceConstantEvaluator implements EvalOperator.ExpressionEv private final DriverContext driverContext; + private Warnings warnings; + public ReplaceConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator str, Pattern regex, EvalOperator.ExpressionEvaluator newStr, DriverContext driverContext) { + this.source = source; this.str = str; this.regex = regex; this.newStr = newStr; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -72,7 +74,7 @@ public final class ReplaceConstantEvaluator implements EvalOperator.ExpressionEv } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -83,7 +85,7 @@ public final class ReplaceConstantEvaluator implements EvalOperator.ExpressionEv } if (newStrBlock.getValueCount(p) != 1) { if (newStrBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class ReplaceConstantEvaluator implements EvalOperator.ExpressionEv try { result.appendBytesRef(Replace.process(strBlock.getBytesRef(strBlock.getFirstValueIndex(p), strScratch), this.regex, newStrBlock.getBytesRef(newStrBlock.getFirstValueIndex(p), newStrScratch))); } catch (PatternSyntaxException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -108,7 +110,7 @@ public final class ReplaceConstantEvaluator implements EvalOperator.ExpressionEv try { result.appendBytesRef(Replace.process(strVector.getBytesRef(p, strScratch), this.regex, newStrVector.getBytesRef(p, newStrScratch))); } catch (PatternSyntaxException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -126,6 +128,18 @@ public final class ReplaceConstantEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(str, newStr); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceEvaluator.java index a6544f0b1681..8c58a76cc481 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReplaceEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Replace}. * This class is generated. Do not edit it. */ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -34,14 +34,16 @@ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public ReplaceEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator regex, EvalOperator.ExpressionEvaluator newStr, DriverContext driverContext) { + this.source = source; this.str = str; this.regex = regex; this.newStr = newStr; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -80,7 +82,7 @@ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -91,7 +93,7 @@ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator } if (regexBlock.getValueCount(p) != 1) { if (regexBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -102,7 +104,7 @@ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator } if (newStrBlock.getValueCount(p) != 1) { if (newStrBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -110,7 +112,7 @@ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendBytesRef(Replace.process(strBlock.getBytesRef(strBlock.getFirstValueIndex(p), strScratch), regexBlock.getBytesRef(regexBlock.getFirstValueIndex(p), regexScratch), newStrBlock.getBytesRef(newStrBlock.getFirstValueIndex(p), newStrScratch))); } catch (PatternSyntaxException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -128,7 +130,7 @@ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendBytesRef(Replace.process(strVector.getBytesRef(p, strScratch), regexVector.getBytesRef(p, regexScratch), newStrVector.getBytesRef(p, newStrScratch))); } catch (PatternSyntaxException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -146,6 +148,18 @@ public final class ReplaceEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(str, regex, newStr); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReverseEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReverseEvaluator.java index 68ea53ad342e..408c16a9c4f7 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReverseEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ReverseEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Reverse}. * This class is generated. Do not edit it. */ public final class ReverseEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public ReverseEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class ReverseEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -88,6 +90,18 @@ public final class ReverseEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightEvaluator.java index b100cd592495..a296096a13fb 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/RightEvaluator.java @@ -18,16 +18,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Right}. * This class is generated. Do not edit it. */ public final class RightEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final BytesRef out; @@ -39,15 +39,17 @@ public final class RightEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public RightEvaluator(Source source, BytesRef out, UnicodeUtil.UTF8CodePoint cp, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator length, DriverContext driverContext) { + this.source = source; this.out = out; this.cp = cp; this.str = str; this.length = length; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -77,7 +79,7 @@ public final class RightEvaluator implements EvalOperator.ExpressionEvaluator { } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -88,7 +90,7 @@ public final class RightEvaluator implements EvalOperator.ExpressionEvaluator { } if (lengthBlock.getValueCount(p) != 1) { if (lengthBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -119,6 +121,18 @@ public final class RightEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(str, length); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceEvaluator.java index 0252bd85f6ff..14228522d941 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SpaceEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.BreakingBytesRefBuilder; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Space}. * This class is generated. Do not edit it. */ public final class SpaceEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final BreakingBytesRefBuilder scratch; @@ -33,12 +33,14 @@ public final class SpaceEvaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public SpaceEvaluator(Source source, BreakingBytesRefBuilder scratch, EvalOperator.ExpressionEvaluator number, DriverContext driverContext) { + this.source = source; this.scratch = scratch; this.number = number; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SpaceEvaluator implements EvalOperator.ExpressionEvaluator { } if (numberBlock.getValueCount(p) != 1) { if (numberBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -69,7 +71,7 @@ public final class SpaceEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendBytesRef(Space.process(this.scratch, numberBlock.getInt(numberBlock.getFirstValueIndex(p)))); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -83,7 +85,7 @@ public final class SpaceEvaluator implements EvalOperator.ExpressionEvaluator { try { result.appendBytesRef(Space.process(this.scratch, numberVector.getInt(p))); } catch (IllegalArgumentException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -101,6 +103,18 @@ public final class SpaceEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(scratch, number); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSingleByteEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSingleByteEvaluator.java index 31639b981f84..8b80b4ec0618 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSingleByteEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitSingleByteEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Split}. * This class is generated. Do not edit it. */ public final class SplitSingleByteEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -34,13 +34,15 @@ public final class SplitSingleByteEvaluator implements EvalOperator.ExpressionEv private final DriverContext driverContext; + private Warnings warnings; + public SplitSingleByteEvaluator(Source source, EvalOperator.ExpressionEvaluator str, byte delim, BytesRef scratch, DriverContext driverContext) { + this.source = source; this.str = str; this.delim = delim; this.scratch = scratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -64,7 +66,7 @@ public final class SplitSingleByteEvaluator implements EvalOperator.ExpressionEv } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -95,6 +97,18 @@ public final class SplitSingleByteEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(str); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitVariableEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitVariableEvaluator.java index bccfa9ab680e..54a1d6863cd8 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitVariableEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SplitVariableEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Split}. * This class is generated. Do not edit it. */ public final class SplitVariableEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -34,13 +34,15 @@ public final class SplitVariableEvaluator implements EvalOperator.ExpressionEval private final DriverContext driverContext; + private Warnings warnings; + public SplitVariableEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator delim, BytesRef scratch, DriverContext driverContext) { + this.source = source; this.str = str; this.delim = delim; this.scratch = scratch; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -71,7 +73,7 @@ public final class SplitVariableEvaluator implements EvalOperator.ExpressionEval } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -82,7 +84,7 @@ public final class SplitVariableEvaluator implements EvalOperator.ExpressionEval } if (delimBlock.getValueCount(p) != 1) { if (delimBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -115,6 +117,18 @@ public final class SplitVariableEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(str, delim); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithEvaluator.java index a932e449f650..b175ea0b0d17 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/StartsWithEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link StartsWith}. * This class is generated. Do not edit it. */ public final class StartsWithEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -33,12 +33,14 @@ public final class StartsWithEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public StartsWithEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator prefix, DriverContext driverContext) { + this.source = source; this.str = str; this.prefix = prefix; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class StartsWithEvaluator implements EvalOperator.ExpressionEvaluat } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class StartsWithEvaluator implements EvalOperator.ExpressionEvaluat } if (prefixBlock.getValueCount(p) != 1) { if (prefixBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -113,6 +115,18 @@ public final class StartsWithEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(str, prefix); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringEvaluator.java index 92a2d622eaf5..2ceb2230fb8f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Substring}. * This class is generated. Do not edit it. */ public final class SubstringEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -35,14 +35,16 @@ public final class SubstringEvaluator implements EvalOperator.ExpressionEvaluato private final DriverContext driverContext; + private Warnings warnings; + public SubstringEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator start, EvalOperator.ExpressionEvaluator length, DriverContext driverContext) { + this.source = source; this.str = str; this.start = start; this.length = length; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -79,7 +81,7 @@ public final class SubstringEvaluator implements EvalOperator.ExpressionEvaluato } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -90,7 +92,7 @@ public final class SubstringEvaluator implements EvalOperator.ExpressionEvaluato } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -101,7 +103,7 @@ public final class SubstringEvaluator implements EvalOperator.ExpressionEvaluato } if (lengthBlock.getValueCount(p) != 1) { if (lengthBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -133,6 +135,18 @@ public final class SubstringEvaluator implements EvalOperator.ExpressionEvaluato Releasables.closeExpectNoException(str, start, length); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringNoLengthEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringNoLengthEvaluator.java index 9177b31ab64f..31268b4557a6 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringNoLengthEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/SubstringNoLengthEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Substring}. * This class is generated. Do not edit it. */ public final class SubstringNoLengthEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator str; @@ -33,12 +33,14 @@ public final class SubstringNoLengthEvaluator implements EvalOperator.Expression private final DriverContext driverContext; + private Warnings warnings; + public SubstringNoLengthEvaluator(Source source, EvalOperator.ExpressionEvaluator str, EvalOperator.ExpressionEvaluator start, DriverContext driverContext) { + this.source = source; this.str = str; this.start = start; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -68,7 +70,7 @@ public final class SubstringNoLengthEvaluator implements EvalOperator.Expression } if (strBlock.getValueCount(p) != 1) { if (strBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -79,7 +81,7 @@ public final class SubstringNoLengthEvaluator implements EvalOperator.Expression } if (startBlock.getValueCount(p) != 1) { if (startBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -110,6 +112,18 @@ public final class SubstringNoLengthEvaluator implements EvalOperator.Expression Releasables.closeExpectNoException(str, start); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerEvaluator.java index 703fb1cae5d8..61e7c5c3042d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToLowerEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link ToLower}. * This class is generated. Do not edit it. */ public final class ToLowerEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -32,12 +32,14 @@ public final class ToLowerEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public ToLowerEvaluator(Source source, EvalOperator.ExpressionEvaluator val, Locale locale, DriverContext driverContext) { + this.source = source; this.val = val; this.locale = locale; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class ToLowerEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -92,6 +94,18 @@ public final class ToLowerEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperEvaluator.java index 2a99af3033b0..82412dde5394 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/ToUpperEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link ToUpper}. * This class is generated. Do not edit it. */ public final class ToUpperEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; @@ -32,12 +32,14 @@ public final class ToUpperEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public ToUpperEvaluator(Source source, EvalOperator.ExpressionEvaluator val, Locale locale, DriverContext driverContext) { + this.source = source; this.val = val; this.locale = locale; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class ToUpperEvaluator implements EvalOperator.ExpressionEvaluator } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -92,6 +94,18 @@ public final class ToUpperEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/TrimEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/TrimEvaluator.java index d4a884fc97b9..44215c06c906 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/TrimEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/TrimEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Trim}. * This class is generated. Do not edit it. */ public final class TrimEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator val; private final DriverContext driverContext; + private Warnings warnings; + public TrimEvaluator(Source source, EvalOperator.ExpressionEvaluator val, DriverContext driverContext) { + this.source = source; this.val = val; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -57,7 +59,7 @@ public final class TrimEvaluator implements EvalOperator.ExpressionEvaluator { } if (valBlock.getValueCount(p) != 1) { if (valBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -88,6 +90,18 @@ public final class TrimEvaluator implements EvalOperator.ExpressionEvaluator { Releasables.closeExpectNoException(val); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDatetimesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDatetimesEvaluator.java index 962fb4e2e681..3cd91fdeb7ea 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDatetimesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDatetimesEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Add}. * This class is generated. Do not edit it. */ public final class AddDatetimesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator datetime; @@ -33,12 +33,14 @@ public final class AddDatetimesEvaluator implements EvalOperator.ExpressionEvalu private final DriverContext driverContext; + private Warnings warnings; + public AddDatetimesEvaluator(Source source, EvalOperator.ExpressionEvaluator datetime, TemporalAmount temporalAmount, DriverContext driverContext) { + this.source = source; this.datetime = datetime; this.temporalAmount = temporalAmount; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class AddDatetimesEvaluator implements EvalOperator.ExpressionEvalu } if (datetimeBlock.getValueCount(p) != 1) { if (datetimeBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -69,7 +71,7 @@ public final class AddDatetimesEvaluator implements EvalOperator.ExpressionEvalu try { result.appendLong(Add.processDatetimes(datetimeBlock.getLong(datetimeBlock.getFirstValueIndex(p)), this.temporalAmount)); } catch (ArithmeticException | DateTimeException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -83,7 +85,7 @@ public final class AddDatetimesEvaluator implements EvalOperator.ExpressionEvalu try { result.appendLong(Add.processDatetimes(datetimeVector.getLong(p), this.temporalAmount)); } catch (ArithmeticException | DateTimeException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -101,6 +103,18 @@ public final class AddDatetimesEvaluator implements EvalOperator.ExpressionEvalu Releasables.closeExpectNoException(datetime); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDoublesEvaluator.java index d6a81f2873e3..61ef4215b3e2 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddDoublesEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Add}. * This class is generated. Do not edit it. */ public final class AddDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class AddDoublesEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public AddDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class AddDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class AddDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class AddDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Add.processDoubles(lhsBlock.getDouble(lhsBlock.getFirstValueIndex(p)), rhsBlock.getDouble(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class AddDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Add.processDoubles(lhsVector.getDouble(p), rhsVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class AddDoublesEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddIntsEvaluator.java index 570b66667633..3616711127ce 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddIntsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Add}. * This class is generated. Do not edit it. */ public final class AddIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class AddIntsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public AddIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class AddIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class AddIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class AddIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Add.processInts(lhsBlock.getInt(lhsBlock.getFirstValueIndex(p)), rhsBlock.getInt(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class AddIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Add.processInts(lhsVector.getInt(p), rhsVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class AddIntsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddLongsEvaluator.java index 71dda4fd9752..fd046049980f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Add}. * This class is generated. Do not edit it. */ public final class AddLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class AddLongsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public AddLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class AddLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class AddLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class AddLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Add.processLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class AddLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Add.processLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class AddLongsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddUnsignedLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddUnsignedLongsEvaluator.java index 16db58fe5bd6..d89a0c83acd8 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddUnsignedLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/AddUnsignedLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Add}. * This class is generated. Do not edit it. */ public final class AddUnsignedLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class AddUnsignedLongsEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public AddUnsignedLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class AddUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class AddUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class AddUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Add.processUnsignedLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class AddUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Add.processUnsignedLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class AddUnsignedLongsEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivDoublesEvaluator.java index 20d1647d6bc9..fb2fc81b2523 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivDoublesEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Div}. * This class is generated. Do not edit it. */ public final class DivDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class DivDoublesEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public DivDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class DivDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class DivDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class DivDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Div.processDoubles(lhsBlock.getDouble(lhsBlock.getFirstValueIndex(p)), rhsBlock.getDouble(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class DivDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Div.processDoubles(lhsVector.getDouble(p), rhsVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class DivDoublesEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivIntsEvaluator.java index a1b4f3857ad0..fc3e58759688 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivIntsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Div}. * This class is generated. Do not edit it. */ public final class DivIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class DivIntsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public DivIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class DivIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class DivIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class DivIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Div.processInts(lhsBlock.getInt(lhsBlock.getFirstValueIndex(p)), rhsBlock.getInt(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class DivIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Div.processInts(lhsVector.getInt(p), rhsVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class DivIntsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivLongsEvaluator.java index 902d7d2f0b98..49f15a6c90a4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Div}. * This class is generated. Do not edit it. */ public final class DivLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class DivLongsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public DivLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class DivLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class DivLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class DivLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Div.processLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class DivLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Div.processLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class DivLongsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivUnsignedLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivUnsignedLongsEvaluator.java index 65ba26984012..2307b4984f49 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivUnsignedLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/DivUnsignedLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Div}. * This class is generated. Do not edit it. */ public final class DivUnsignedLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class DivUnsignedLongsEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public DivUnsignedLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class DivUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class DivUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class DivUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Div.processUnsignedLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class DivUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Div.processUnsignedLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class DivUnsignedLongsEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModDoublesEvaluator.java index 0f1b344e6add..b9a3e1419a12 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModDoublesEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mod}. * This class is generated. Do not edit it. */ public final class ModDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class ModDoublesEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public ModDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class ModDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class ModDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class ModDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Mod.processDoubles(lhsBlock.getDouble(lhsBlock.getFirstValueIndex(p)), rhsBlock.getDouble(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class ModDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Mod.processDoubles(lhsVector.getDouble(p), rhsVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class ModDoublesEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModIntsEvaluator.java index 014bc32e0e25..38aaab26eccd 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModIntsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mod}. * This class is generated. Do not edit it. */ public final class ModIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class ModIntsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public ModIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class ModIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class ModIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class ModIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Mod.processInts(lhsBlock.getInt(lhsBlock.getFirstValueIndex(p)), rhsBlock.getInt(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class ModIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Mod.processInts(lhsVector.getInt(p), rhsVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class ModIntsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModLongsEvaluator.java index 3436c10521b6..ec6cdaa93b1b 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mod}. * This class is generated. Do not edit it. */ public final class ModLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class ModLongsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public ModLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class ModLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class ModLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class ModLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Mod.processLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class ModLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Mod.processLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class ModLongsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModUnsignedLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModUnsignedLongsEvaluator.java index b031a21e79f7..e85291598ba5 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModUnsignedLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/ModUnsignedLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mod}. * This class is generated. Do not edit it. */ public final class ModUnsignedLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class ModUnsignedLongsEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public ModUnsignedLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class ModUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class ModUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class ModUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Mod.processUnsignedLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class ModUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Mod.processUnsignedLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class ModUnsignedLongsEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulDoublesEvaluator.java index 9104b9b920a9..65ea4fe3e0a1 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulDoublesEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mul}. * This class is generated. Do not edit it. */ public final class MulDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class MulDoublesEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public MulDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class MulDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class MulDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class MulDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Mul.processDoubles(lhsBlock.getDouble(lhsBlock.getFirstValueIndex(p)), rhsBlock.getDouble(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class MulDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Mul.processDoubles(lhsVector.getDouble(p), rhsVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class MulDoublesEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulIntsEvaluator.java index 089765b1662c..cfc30966deae 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulIntsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mul}. * This class is generated. Do not edit it. */ public final class MulIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class MulIntsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public MulIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class MulIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class MulIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class MulIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Mul.processInts(lhsBlock.getInt(lhsBlock.getFirstValueIndex(p)), rhsBlock.getInt(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class MulIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Mul.processInts(lhsVector.getInt(p), rhsVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class MulIntsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulLongsEvaluator.java index 2cbc69a7face..8e5a12b9ea1b 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mul}. * This class is generated. Do not edit it. */ public final class MulLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class MulLongsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public MulLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class MulLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class MulLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class MulLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Mul.processLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class MulLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Mul.processLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class MulLongsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulUnsignedLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulUnsignedLongsEvaluator.java index 3a74466a9bc4..b4babd6b9317 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulUnsignedLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/MulUnsignedLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Mul}. * This class is generated. Do not edit it. */ public final class MulUnsignedLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class MulUnsignedLongsEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public MulUnsignedLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class MulUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class MulUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class MulUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Mul.processUnsignedLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class MulUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Mul.processUnsignedLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class MulUnsignedLongsEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegDoublesEvaluator.java index 24f04a23ebb4..8f573c9f431b 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegDoublesEvaluator.java @@ -13,26 +13,28 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Neg}. * This class is generated. Do not edit it. */ public final class NegDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public NegDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -55,7 +57,7 @@ public final class NegDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -85,6 +87,18 @@ public final class NegDoublesEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegIntsEvaluator.java index 0b27ba7f4615..7da1c1080293 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegIntsEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Neg}. * This class is generated. Do not edit it. */ public final class NegIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public NegIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class NegIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class NegIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Neg.processInts(vBlock.getInt(vBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class NegIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Neg.processInts(vVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class NegIntsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegLongsEvaluator.java index e6c2ccb469bb..d259edb076e4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/NegLongsEvaluator.java @@ -14,26 +14,28 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Neg}. * This class is generated. Do not edit it. */ public final class NegLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator v; private final DriverContext driverContext; + private Warnings warnings; + public NegLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator v, DriverContext driverContext) { + this.source = source; this.v = v; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -56,7 +58,7 @@ public final class NegLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (vBlock.getValueCount(p) != 1) { if (vBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -64,7 +66,7 @@ public final class NegLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Neg.processLongs(vBlock.getLong(vBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -78,7 +80,7 @@ public final class NegLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Neg.processLongs(vVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -96,6 +98,18 @@ public final class NegLongsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(v); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDatetimesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDatetimesEvaluator.java index e9b540468fb3..0ad395b4e575 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDatetimesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDatetimesEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sub}. * This class is generated. Do not edit it. */ public final class SubDatetimesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator datetime; @@ -33,12 +33,14 @@ public final class SubDatetimesEvaluator implements EvalOperator.ExpressionEvalu private final DriverContext driverContext; + private Warnings warnings; + public SubDatetimesEvaluator(Source source, EvalOperator.ExpressionEvaluator datetime, TemporalAmount temporalAmount, DriverContext driverContext) { + this.source = source; this.datetime = datetime; this.temporalAmount = temporalAmount; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -61,7 +63,7 @@ public final class SubDatetimesEvaluator implements EvalOperator.ExpressionEvalu } if (datetimeBlock.getValueCount(p) != 1) { if (datetimeBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -69,7 +71,7 @@ public final class SubDatetimesEvaluator implements EvalOperator.ExpressionEvalu try { result.appendLong(Sub.processDatetimes(datetimeBlock.getLong(datetimeBlock.getFirstValueIndex(p)), this.temporalAmount)); } catch (ArithmeticException | DateTimeException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -83,7 +85,7 @@ public final class SubDatetimesEvaluator implements EvalOperator.ExpressionEvalu try { result.appendLong(Sub.processDatetimes(datetimeVector.getLong(p), this.temporalAmount)); } catch (ArithmeticException | DateTimeException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -101,6 +103,18 @@ public final class SubDatetimesEvaluator implements EvalOperator.ExpressionEvalu Releasables.closeExpectNoException(datetime); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDoublesEvaluator.java index c9097145df61..30e44ed5b72e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubDoublesEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sub}. * This class is generated. Do not edit it. */ public final class SubDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class SubDoublesEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public SubDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class SubDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class SubDoublesEvaluator implements EvalOperator.ExpressionEvaluat } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class SubDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Sub.processDoubles(lhsBlock.getDouble(lhsBlock.getFirstValueIndex(p)), rhsBlock.getDouble(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class SubDoublesEvaluator implements EvalOperator.ExpressionEvaluat try { result.appendDouble(Sub.processDoubles(lhsVector.getDouble(p), rhsVector.getDouble(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class SubDoublesEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubIntsEvaluator.java index ec572bd491ec..83680e58640f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubIntsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sub}. * This class is generated. Do not edit it. */ public final class SubIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class SubIntsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public SubIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class SubIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class SubIntsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class SubIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Sub.processInts(lhsBlock.getInt(lhsBlock.getFirstValueIndex(p)), rhsBlock.getInt(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class SubIntsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendInt(Sub.processInts(lhsVector.getInt(p), rhsVector.getInt(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class SubIntsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubLongsEvaluator.java index eaa1efeb3922..fbead2000b58 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sub}. * This class is generated. Do not edit it. */ public final class SubLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class SubLongsEvaluator implements EvalOperator.ExpressionEvaluator private final DriverContext driverContext; + private Warnings warnings; + public SubLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class SubLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class SubLongsEvaluator implements EvalOperator.ExpressionEvaluator } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class SubLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Sub.processLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class SubLongsEvaluator implements EvalOperator.ExpressionEvaluator try { result.appendLong(Sub.processLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class SubLongsEvaluator implements EvalOperator.ExpressionEvaluator Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubUnsignedLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubUnsignedLongsEvaluator.java index f221e9b07235..6acb5deb0622 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubUnsignedLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/arithmetic/SubUnsignedLongsEvaluator.java @@ -14,16 +14,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Sub}. * This class is generated. Do not edit it. */ public final class SubUnsignedLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -31,12 +31,14 @@ public final class SubUnsignedLongsEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public SubUnsignedLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -65,7 +67,7 @@ public final class SubUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -76,7 +78,7 @@ public final class SubUnsignedLongsEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -84,7 +86,7 @@ public final class SubUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Sub.processUnsignedLongs(lhsBlock.getLong(lhsBlock.getFirstValueIndex(p)), rhsBlock.getLong(rhsBlock.getFirstValueIndex(p)))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -98,7 +100,7 @@ public final class SubUnsignedLongsEvaluator implements EvalOperator.ExpressionE try { result.appendLong(Sub.processUnsignedLongs(lhsVector.getLong(p), rhsVector.getLong(p))); } catch (ArithmeticException e) { - warnings.registerException(e); + warnings().registerException(e); result.appendNull(); } } @@ -116,6 +118,18 @@ public final class SubUnsignedLongsEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsBoolsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsBoolsEvaluator.java index e39a9482215f..9403efd70908 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsBoolsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsBoolsEvaluator.java @@ -13,16 +13,16 @@ import org.elasticsearch.compute.data.BooleanVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}. * This class is generated. Do not edit it. */ public final class EqualsBoolsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -30,12 +30,14 @@ public final class EqualsBoolsEvaluator implements EvalOperator.ExpressionEvalua private final DriverContext driverContext; + private Warnings warnings; + public EqualsBoolsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -64,7 +66,7 @@ public final class EqualsBoolsEvaluator implements EvalOperator.ExpressionEvalua } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -75,7 +77,7 @@ public final class EqualsBoolsEvaluator implements EvalOperator.ExpressionEvalua } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -105,6 +107,18 @@ public final class EqualsBoolsEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsDoublesEvaluator.java index cdf84e050621..9b3daa731767 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsDoublesEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}. * This class is generated. Do not edit it. */ public final class EqualsDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class EqualsDoublesEvaluator implements EvalOperator.ExpressionEval private final DriverContext driverContext; + private Warnings warnings; + public EqualsDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class EqualsDoublesEvaluator implements EvalOperator.ExpressionEval } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class EqualsDoublesEvaluator implements EvalOperator.ExpressionEval } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class EqualsDoublesEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsGeometriesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsGeometriesEvaluator.java index ad942e63c6f4..73c0ab28f154 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsGeometriesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsGeometriesEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}. * This class is generated. Do not edit it. */ public final class EqualsGeometriesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class EqualsGeometriesEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public EqualsGeometriesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class EqualsGeometriesEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class EqualsGeometriesEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class EqualsGeometriesEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsIntsEvaluator.java index d60efd0edded..93a776f558e9 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsIntsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}. * This class is generated. Do not edit it. */ public final class EqualsIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class EqualsIntsEvaluator implements EvalOperator.ExpressionEvaluat private final DriverContext driverContext; + private Warnings warnings; + public EqualsIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class EqualsIntsEvaluator implements EvalOperator.ExpressionEvaluat } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class EqualsIntsEvaluator implements EvalOperator.ExpressionEvaluat } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class EqualsIntsEvaluator implements EvalOperator.ExpressionEvaluat Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsKeywordsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsKeywordsEvaluator.java index e28dcaeba31d..578ec20bfd18 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsKeywordsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsKeywordsEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}. * This class is generated. Do not edit it. */ public final class EqualsKeywordsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class EqualsKeywordsEvaluator implements EvalOperator.ExpressionEva private final DriverContext driverContext; + private Warnings warnings; + public EqualsKeywordsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class EqualsKeywordsEvaluator implements EvalOperator.ExpressionEva } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class EqualsKeywordsEvaluator implements EvalOperator.ExpressionEva } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class EqualsKeywordsEvaluator implements EvalOperator.ExpressionEva Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsLongsEvaluator.java index 504422e59071..606e8d0a39ef 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/EqualsLongsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link Equals}. * This class is generated. Do not edit it. */ public final class EqualsLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class EqualsLongsEvaluator implements EvalOperator.ExpressionEvalua private final DriverContext driverContext; + private Warnings warnings; + public EqualsLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class EqualsLongsEvaluator implements EvalOperator.ExpressionEvalua } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class EqualsLongsEvaluator implements EvalOperator.ExpressionEvalua } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class EqualsLongsEvaluator implements EvalOperator.ExpressionEvalua Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanDoublesEvaluator.java index c1e0fcd09f17..0f24db582699 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanDoublesEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThan}. * This class is generated. Do not edit it. */ public final class GreaterThanDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class GreaterThanDoublesEvaluator implements EvalOperator.Expressio private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreaterThanDoublesEvaluator implements EvalOperator.Expressio } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class GreaterThanDoublesEvaluator implements EvalOperator.Expressio } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreaterThanDoublesEvaluator implements EvalOperator.Expressio Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanIntsEvaluator.java index 721310c8a751..f7d0e46efd5d 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanIntsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThan}. * This class is generated. Do not edit it. */ public final class GreaterThanIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class GreaterThanIntsEvaluator implements EvalOperator.ExpressionEv private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreaterThanIntsEvaluator implements EvalOperator.ExpressionEv } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class GreaterThanIntsEvaluator implements EvalOperator.ExpressionEv } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreaterThanIntsEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanKeywordsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanKeywordsEvaluator.java index 1edb13c789a9..970f42f80bdf 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanKeywordsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanKeywordsEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThan}. * This class is generated. Do not edit it. */ public final class GreaterThanKeywordsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class GreaterThanKeywordsEvaluator implements EvalOperator.Expressi private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanKeywordsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class GreaterThanKeywordsEvaluator implements EvalOperator.Expressi } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class GreaterThanKeywordsEvaluator implements EvalOperator.Expressi } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class GreaterThanKeywordsEvaluator implements EvalOperator.Expressi Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanLongsEvaluator.java index 79bc2b646b2f..9a5c2b03b2b9 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanLongsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThan}. * This class is generated. Do not edit it. */ public final class GreaterThanLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class GreaterThanLongsEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreaterThanLongsEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class GreaterThanLongsEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreaterThanLongsEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualDoublesEvaluator.java index 9b39defdf744..149e5c62a697 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualDoublesEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThanOrEqual}. * This class is generated. Do not edit it. */ public final class GreaterThanOrEqualDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class GreaterThanOrEqualDoublesEvaluator implements EvalOperator.Ex private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanOrEqualDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreaterThanOrEqualDoublesEvaluator implements EvalOperator.Ex } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class GreaterThanOrEqualDoublesEvaluator implements EvalOperator.Ex } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreaterThanOrEqualDoublesEvaluator implements EvalOperator.Ex Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualIntsEvaluator.java index c6aa1e89c199..dfcf20534293 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualIntsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThanOrEqual}. * This class is generated. Do not edit it. */ public final class GreaterThanOrEqualIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class GreaterThanOrEqualIntsEvaluator implements EvalOperator.Expre private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanOrEqualIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreaterThanOrEqualIntsEvaluator implements EvalOperator.Expre } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class GreaterThanOrEqualIntsEvaluator implements EvalOperator.Expre } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreaterThanOrEqualIntsEvaluator implements EvalOperator.Expre Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualKeywordsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualKeywordsEvaluator.java index baddf53e4d74..fb1d92c45a75 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualKeywordsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualKeywordsEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThanOrEqual}. * This class is generated. Do not edit it. */ public final class GreaterThanOrEqualKeywordsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class GreaterThanOrEqualKeywordsEvaluator implements EvalOperator.E private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanOrEqualKeywordsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class GreaterThanOrEqualKeywordsEvaluator implements EvalOperator.E } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class GreaterThanOrEqualKeywordsEvaluator implements EvalOperator.E } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class GreaterThanOrEqualKeywordsEvaluator implements EvalOperator.E Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualLongsEvaluator.java index d2291d175263..b64c8093e5be 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/GreaterThanOrEqualLongsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link GreaterThanOrEqual}. * This class is generated. Do not edit it. */ public final class GreaterThanOrEqualLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class GreaterThanOrEqualLongsEvaluator implements EvalOperator.Expr private final DriverContext driverContext; + private Warnings warnings; + public GreaterThanOrEqualLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class GreaterThanOrEqualLongsEvaluator implements EvalOperator.Expr } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class GreaterThanOrEqualLongsEvaluator implements EvalOperator.Expr } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class GreaterThanOrEqualLongsEvaluator implements EvalOperator.Expr Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsConstantEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsConstantEvaluator.java index b2d177f61ef5..eedaf9754538 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsConstantEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsConstantEvaluator.java @@ -17,16 +17,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link InsensitiveEquals}. * This class is generated. Do not edit it. */ public final class InsensitiveEqualsConstantEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -34,12 +34,14 @@ public final class InsensitiveEqualsConstantEvaluator implements EvalOperator.Ex private final DriverContext driverContext; + private Warnings warnings; + public InsensitiveEqualsConstantEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, ByteRunAutomaton rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -63,7 +65,7 @@ public final class InsensitiveEqualsConstantEvaluator implements EvalOperator.Ex } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -94,6 +96,18 @@ public final class InsensitiveEqualsConstantEvaluator implements EvalOperator.Ex Releasables.closeExpectNoException(lhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsEvaluator.java index 9dc408311b15..432c70dd1ae5 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InsensitiveEqualsEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link InsensitiveEquals}. * This class is generated. Do not edit it. */ public final class InsensitiveEqualsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class InsensitiveEqualsEvaluator implements EvalOperator.Expression private final DriverContext driverContext; + private Warnings warnings; + public InsensitiveEqualsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class InsensitiveEqualsEvaluator implements EvalOperator.Expression } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class InsensitiveEqualsEvaluator implements EvalOperator.Expression } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class InsensitiveEqualsEvaluator implements EvalOperator.Expression Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanDoublesEvaluator.java index 922c95b2bb55..cc6661a3f02c 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanDoublesEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThan}. * This class is generated. Do not edit it. */ public final class LessThanDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class LessThanDoublesEvaluator implements EvalOperator.ExpressionEv private final DriverContext driverContext; + private Warnings warnings; + public LessThanDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LessThanDoublesEvaluator implements EvalOperator.ExpressionEv } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class LessThanDoublesEvaluator implements EvalOperator.ExpressionEv } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LessThanDoublesEvaluator implements EvalOperator.ExpressionEv Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanIntsEvaluator.java index f8d7b716b337..93be674d4972 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanIntsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThan}. * This class is generated. Do not edit it. */ public final class LessThanIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class LessThanIntsEvaluator implements EvalOperator.ExpressionEvalu private final DriverContext driverContext; + private Warnings warnings; + public LessThanIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LessThanIntsEvaluator implements EvalOperator.ExpressionEvalu } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class LessThanIntsEvaluator implements EvalOperator.ExpressionEvalu } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LessThanIntsEvaluator implements EvalOperator.ExpressionEvalu Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanKeywordsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanKeywordsEvaluator.java index af31709cc957..69d73a7f134a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanKeywordsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanKeywordsEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThan}. * This class is generated. Do not edit it. */ public final class LessThanKeywordsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class LessThanKeywordsEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public LessThanKeywordsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class LessThanKeywordsEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class LessThanKeywordsEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class LessThanKeywordsEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanLongsEvaluator.java index 8911398202ce..86bb587e1af4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanLongsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThan}. * This class is generated. Do not edit it. */ public final class LessThanLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class LessThanLongsEvaluator implements EvalOperator.ExpressionEval private final DriverContext driverContext; + private Warnings warnings; + public LessThanLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LessThanLongsEvaluator implements EvalOperator.ExpressionEval } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class LessThanLongsEvaluator implements EvalOperator.ExpressionEval } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LessThanLongsEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualDoublesEvaluator.java index ea2097bead16..07d1dad29fca 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualDoublesEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThanOrEqual}. * This class is generated. Do not edit it. */ public final class LessThanOrEqualDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class LessThanOrEqualDoublesEvaluator implements EvalOperator.Expre private final DriverContext driverContext; + private Warnings warnings; + public LessThanOrEqualDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LessThanOrEqualDoublesEvaluator implements EvalOperator.Expre } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class LessThanOrEqualDoublesEvaluator implements EvalOperator.Expre } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LessThanOrEqualDoublesEvaluator implements EvalOperator.Expre Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualIntsEvaluator.java index 01a46e011d34..819878ff7c0e 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualIntsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThanOrEqual}. * This class is generated. Do not edit it. */ public final class LessThanOrEqualIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class LessThanOrEqualIntsEvaluator implements EvalOperator.Expressi private final DriverContext driverContext; + private Warnings warnings; + public LessThanOrEqualIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LessThanOrEqualIntsEvaluator implements EvalOperator.Expressi } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class LessThanOrEqualIntsEvaluator implements EvalOperator.Expressi } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LessThanOrEqualIntsEvaluator implements EvalOperator.Expressi Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualKeywordsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualKeywordsEvaluator.java index d30033733130..bfc192443b40 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualKeywordsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualKeywordsEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThanOrEqual}. * This class is generated. Do not edit it. */ public final class LessThanOrEqualKeywordsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class LessThanOrEqualKeywordsEvaluator implements EvalOperator.Expr private final DriverContext driverContext; + private Warnings warnings; + public LessThanOrEqualKeywordsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class LessThanOrEqualKeywordsEvaluator implements EvalOperator.Expr } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class LessThanOrEqualKeywordsEvaluator implements EvalOperator.Expr } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class LessThanOrEqualKeywordsEvaluator implements EvalOperator.Expr Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualLongsEvaluator.java index 3c1a03006a84..7ebf8695839f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/LessThanOrEqualLongsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link LessThanOrEqual}. * This class is generated. Do not edit it. */ public final class LessThanOrEqualLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class LessThanOrEqualLongsEvaluator implements EvalOperator.Express private final DriverContext driverContext; + private Warnings warnings; + public LessThanOrEqualLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class LessThanOrEqualLongsEvaluator implements EvalOperator.Express } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class LessThanOrEqualLongsEvaluator implements EvalOperator.Express } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class LessThanOrEqualLongsEvaluator implements EvalOperator.Express Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsBoolsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsBoolsEvaluator.java index 0dc80fdbcf16..ceb67a59021f 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsBoolsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsBoolsEvaluator.java @@ -13,16 +13,16 @@ import org.elasticsearch.compute.data.BooleanVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}. * This class is generated. Do not edit it. */ public final class NotEqualsBoolsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -30,12 +30,14 @@ public final class NotEqualsBoolsEvaluator implements EvalOperator.ExpressionEva private final DriverContext driverContext; + private Warnings warnings; + public NotEqualsBoolsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -64,7 +66,7 @@ public final class NotEqualsBoolsEvaluator implements EvalOperator.ExpressionEva } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -75,7 +77,7 @@ public final class NotEqualsBoolsEvaluator implements EvalOperator.ExpressionEva } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -105,6 +107,18 @@ public final class NotEqualsBoolsEvaluator implements EvalOperator.ExpressionEva Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsDoublesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsDoublesEvaluator.java index f439ec0e94d9..0f0a60fc03f2 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsDoublesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsDoublesEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.DoubleVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}. * This class is generated. Do not edit it. */ public final class NotEqualsDoublesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class NotEqualsDoublesEvaluator implements EvalOperator.ExpressionE private final DriverContext driverContext; + private Warnings warnings; + public NotEqualsDoublesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class NotEqualsDoublesEvaluator implements EvalOperator.ExpressionE } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class NotEqualsDoublesEvaluator implements EvalOperator.ExpressionE } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class NotEqualsDoublesEvaluator implements EvalOperator.ExpressionE Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsGeometriesEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsGeometriesEvaluator.java index 7553a5667f4a..a745eaffaf27 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsGeometriesEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsGeometriesEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}. * This class is generated. Do not edit it. */ public final class NotEqualsGeometriesEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class NotEqualsGeometriesEvaluator implements EvalOperator.Expressi private final DriverContext driverContext; + private Warnings warnings; + public NotEqualsGeometriesEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class NotEqualsGeometriesEvaluator implements EvalOperator.Expressi } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class NotEqualsGeometriesEvaluator implements EvalOperator.Expressi } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class NotEqualsGeometriesEvaluator implements EvalOperator.Expressi Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsIntsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsIntsEvaluator.java index 19098d89be46..a3c803169b98 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsIntsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsIntsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.IntVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}. * This class is generated. Do not edit it. */ public final class NotEqualsIntsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class NotEqualsIntsEvaluator implements EvalOperator.ExpressionEval private final DriverContext driverContext; + private Warnings warnings; + public NotEqualsIntsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class NotEqualsIntsEvaluator implements EvalOperator.ExpressionEval } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class NotEqualsIntsEvaluator implements EvalOperator.ExpressionEval } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class NotEqualsIntsEvaluator implements EvalOperator.ExpressionEval Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsKeywordsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsKeywordsEvaluator.java index 124674540475..9e28b6d1dfe4 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsKeywordsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsKeywordsEvaluator.java @@ -16,16 +16,16 @@ import org.elasticsearch.compute.data.BytesRefVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}. * This class is generated. Do not edit it. */ public final class NotEqualsKeywordsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -33,12 +33,14 @@ public final class NotEqualsKeywordsEvaluator implements EvalOperator.Expression private final DriverContext driverContext; + private Warnings warnings; + public NotEqualsKeywordsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -69,7 +71,7 @@ public final class NotEqualsKeywordsEvaluator implements EvalOperator.Expression } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -80,7 +82,7 @@ public final class NotEqualsKeywordsEvaluator implements EvalOperator.Expression } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -112,6 +114,18 @@ public final class NotEqualsKeywordsEvaluator implements EvalOperator.Expression Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsLongsEvaluator.java b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsLongsEvaluator.java index 25f95af9266e..8114c6cb934a 100644 --- a/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsLongsEvaluator.java +++ b/x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/NotEqualsLongsEvaluator.java @@ -15,16 +15,16 @@ import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link NotEquals}. * This class is generated. Do not edit it. */ public final class NotEqualsLongsEvaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -32,12 +32,14 @@ public final class NotEqualsLongsEvaluator implements EvalOperator.ExpressionEva private final DriverContext driverContext; + private Warnings warnings; + public NotEqualsLongsEvaluator(Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator rhs, DriverContext driverContext) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -66,7 +68,7 @@ public final class NotEqualsLongsEvaluator implements EvalOperator.ExpressionEva } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -77,7 +79,7 @@ public final class NotEqualsLongsEvaluator implements EvalOperator.ExpressionEva } if (rhsBlock.getValueCount(p) != 1) { if (rhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue position; @@ -107,6 +109,18 @@ public final class NotEqualsLongsEvaluator implements EvalOperator.ExpressionEva Releasables.closeExpectNoException(lhs, rhs); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java deleted file mode 100644 index 87809ba53687..000000000000 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/Warnings.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.xpack.esql.expression.function; - -import org.elasticsearch.compute.operator.DriverContext; -import org.elasticsearch.xpack.esql.core.tree.Source; - -import static org.elasticsearch.common.logging.HeaderWarning.addWarning; -import static org.elasticsearch.common.logging.LoggerMessageFormat.format; - -/** - * Utilities to collect warnings for running an executor. - */ -public class Warnings { - static final int MAX_ADDED_WARNINGS = 20; - - private final String location; - private final String first; - - private int addedWarnings; - - public static final Warnings NOOP_WARNINGS = new Warnings(Source.EMPTY) { - @Override - public void registerException(Exception exception) { - // this space intentionally left blank - } - }; - - /** - * Create a new warnings object based on the given mode which warns that - * it treats the result as {@code null}. - * @param warningsMode The warnings collection strategy to use - * @param source used to indicate where in the query the warning occurred - * @return A warnings collector object - */ - public static Warnings createWarnings(DriverContext.WarningsMode warningsMode, Source source) { - return createWarnings(warningsMode, source, "treating result as null"); - } - - /** - * Create a new warnings object based on the given mode which warns that - * it treats the result as {@code false}. - * @param warningsMode The warnings collection strategy to use - * @param source used to indicate where in the query the warning occurred - * @return A warnings collector object - */ - public static Warnings createWarningsTreatedAsFalse(DriverContext.WarningsMode warningsMode, Source source) { - return createWarnings(warningsMode, source, "treating result as false"); - } - - /** - * Create a new warnings object based on the given mode - * @param warningsMode The warnings collection strategy to use - * @param source used to indicate where in the query the warning occurred - * @param first warning message attached to the first result - * @return A warnings collector object - */ - public static Warnings createWarnings(DriverContext.WarningsMode warningsMode, Source source, String first) { - return switch (warningsMode) { - case COLLECT -> new Warnings(source, first); - case IGNORE -> NOOP_WARNINGS; - }; - } - - public Warnings(Source source) { - this(source, "treating result as null"); - } - - public Warnings(Source source, String first) { - location = format("Line {}:{}: ", source.source().getLineNumber(), source.source().getColumnNumber()); - this.first = format( - null, - "{}evaluation of [{}] failed, {}. Only first {} failures recorded.", - location, - source.text(), - first, - MAX_ADDED_WARNINGS - ); - } - - public void registerException(Exception exception) { - if (addedWarnings < MAX_ADDED_WARNINGS) { - if (addedWarnings == 0) { - addWarning(first); - } - // location needs to be added to the exception too, since the headers are deduplicated - addWarning(location + exception.getClass().getName() + ": " + exception.getMessage()); - addedWarnings++; - } - } -} diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java index 62e5651d07dc..d833a796cbec 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/conditional/Case.java @@ -19,6 +19,7 @@ import org.elasticsearch.compute.data.ToMask; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.expression.Expression; @@ -31,7 +32,6 @@ import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.expression.function.Example; import org.elasticsearch.xpack.esql.expression.function.FunctionInfo; import org.elasticsearch.xpack.esql.expression.function.Param; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import org.elasticsearch.xpack.esql.planner.PlannerUtils; @@ -341,7 +341,12 @@ public final class Case extends EsqlScalarFunction { * Rather than go into depth about this in the warning message, * we just say "false". */ - Warnings.createWarningsTreatedAsFalse(driverContext.warningsMode(), conditionSource), + Warnings.createWarningsTreatedAsFalse( + driverContext.warningsMode(), + conditionSource.source().getLineNumber(), + conditionSource.source().getColumnNumber(), + conditionSource.text() + ), condition.get(driverContext), value.get(driverContext) ); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java index 43c9a0864118..5401fcf188d4 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/AbstractConvertFunction.java @@ -18,12 +18,12 @@ import org.elasticsearch.compute.data.Vector; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; import org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException; import org.elasticsearch.xpack.esql.core.expression.Expression; import org.elasticsearch.xpack.esql.core.tree.Source; import org.elasticsearch.xpack.esql.core.type.DataType; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import org.elasticsearch.xpack.esql.expression.function.scalar.UnaryScalarFunction; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; @@ -138,7 +138,12 @@ public abstract class AbstractConvertFunction extends UnaryScalarFunction { protected AbstractEvaluator(DriverContext driverContext, EvalOperator.ExpressionEvaluator field, Source source) { this.driverContext = driverContext; this.fieldEvaluator = field; - this.warnings = new Warnings(source); + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); } protected abstract String name(); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InEvaluator.java.st b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/X-InEvaluator.java.st similarity index 92% rename from x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InEvaluator.java.st rename to x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/X-InEvaluator.java.st index bcbc1ae9ccce..f63815f475d8 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/InEvaluator.java.st +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/predicate/operator/comparison/X-InEvaluator.java.st @@ -30,20 +30,20 @@ $endif$ import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.core.Releasable; import org.elasticsearch.core.Releasables; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.util.Arrays; import java.util.BitSet; /** * {@link EvalOperator.ExpressionEvaluator} implementation for {@link In}. - * This class is generated. Edit {@code InEvaluator.java.st} instead. + * This class is generated. Edit {@code X-InEvaluator.java.st} instead. */ public class In$Type$Evaluator implements EvalOperator.ExpressionEvaluator { - private final Warnings warnings; + private final Source source; private final EvalOperator.ExpressionEvaluator lhs; @@ -51,16 +51,18 @@ public class In$Type$Evaluator implements EvalOperator.ExpressionEvaluator { private final DriverContext driverContext; + private Warnings warnings; + public In$Type$Evaluator( Source source, EvalOperator.ExpressionEvaluator lhs, EvalOperator.ExpressionEvaluator[] rhs, DriverContext driverContext ) { + this.source = source; this.lhs = lhs; this.rhs = rhs; this.driverContext = driverContext; - this.warnings = Warnings.createWarnings(driverContext.warningsMode(), source); } @Override @@ -116,7 +118,7 @@ $endif$ } if (lhsBlock.getValueCount(p) != 1) { if (lhsBlock.getValueCount(p) > 1) { - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); } result.appendNull(); continue; @@ -135,7 +137,7 @@ $endif$ } if (rhsBlocks[i].getValueCount(p) > 1) { mvs.set(i); - warnings.registerException(new IllegalArgumentException("single-value function encountered multi-value")); + warnings().registerException(new IllegalArgumentException("single-value function encountered multi-value")); continue; } $if(boolean)$ @@ -246,6 +248,18 @@ $endif$ Releasables.closeExpectNoException(lhs, () -> Releasables.close(rhs)); } + private Warnings warnings() { + if (warnings == null) { + this.warnings = Warnings.createWarnings( + driverContext.warningsMode(), + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ); + } + return warnings; + } + static class Factory implements EvalOperator.ExpressionEvaluator.Factory { private final Source source; private final EvalOperator.ExpressionEvaluator.Factory lhs; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/package-info.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/package-info.java index 17d317bedbb6..d86729fe785b 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/package-info.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/package-info.java @@ -38,7 +38,7 @@ *

Don't waste people's time

*
    *
  • Queries should not fail at runtime. Instead we should return a - * {@link org.elasticsearch.xpack.esql.expression.function.Warnings warning} and {@code null}.
  • + * {@link org.elasticsearch.compute.operator.Warnings warning} and {@code null}. *
  • It is ok to fail a query up front at analysis time. Just not after it's * started.
  • *
  • It is better if things can be made to work.
  • diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMatchQuery.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMatchQuery.java index 386c983c8e6a..214c7b105335 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMatchQuery.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMatchQuery.java @@ -25,13 +25,13 @@ import org.apache.lucene.search.Scorer; import org.apache.lucene.search.ScorerSupplier; import org.apache.lucene.search.TwoPhaseIterator; import org.apache.lucene.search.Weight; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.index.fielddata.FieldData; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.LeafFieldData; import org.elasticsearch.index.fielddata.LeafNumericFieldData; import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.io.IOException; import java.util.Objects; diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueQuery.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueQuery.java index ad17c97e3d9c..8d33e9b48059 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueQuery.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueQuery.java @@ -16,6 +16,8 @@ import org.elasticsearch.TransportVersions; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.compute.operator.DriverContext; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.query.AbstractQueryBuilder; import org.elasticsearch.index.query.MatchNoneQueryBuilder; @@ -26,7 +28,6 @@ import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xpack.esql.core.querydsl.query.Query; import org.elasticsearch.xpack.esql.core.tree.Location; import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; import java.io.IOException; @@ -173,7 +174,12 @@ public class SingleValueQuery extends Query { } SingleValueMatchQuery singleValueQuery = new SingleValueMatchQuery( context.getForField(ft, MappedFieldType.FielddataOperation.SEARCH), - new Warnings(source) + Warnings.createWarnings( + DriverContext.WarningsMode.COLLECT, + source.source().getLineNumber(), + source.source().getColumnNumber(), + source.text() + ) ); org.apache.lucene.search.Query rewrite = singleValueQuery.rewrite(context.searcher()); if (rewrite instanceof MatchAllDocsQuery) { diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMathQueryTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMathQueryTests.java index f49dfe67e591..7e75a1adc831 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMathQueryTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/querydsl/query/SingleValueMathQueryTests.java @@ -20,13 +20,13 @@ import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; import org.apache.lucene.store.Directory; import org.apache.lucene.tests.index.RandomIndexWriter; +import org.elasticsearch.compute.operator.DriverContext; +import org.elasticsearch.compute.operator.Warnings; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MapperServiceTestCase; import org.elasticsearch.index.query.SearchExecutionContext; import org.elasticsearch.xcontent.XContentBuilder; -import org.elasticsearch.xpack.esql.core.tree.Source; -import org.elasticsearch.xpack.esql.expression.function.Warnings; import java.io.IOException; import java.util.ArrayList; @@ -74,7 +74,7 @@ public class SingleValueMathQueryTests extends MapperServiceTestCase { SearchExecutionContext ctx = createSearchExecutionContext(mapper, new IndexSearcher(reader)); Query query = new SingleValueMatchQuery( ctx.getForField(mapper.fieldType("foo"), MappedFieldType.FielddataOperation.SEARCH), - new Warnings(Source.EMPTY) + Warnings.createWarnings(DriverContext.WarningsMode.COLLECT, 1, 1, "test") ); runCase(fieldValues, ctx.searcher().count(query)); setup.assertRewrite(ctx.searcher(), query); @@ -89,7 +89,7 @@ public class SingleValueMathQueryTests extends MapperServiceTestCase { SearchExecutionContext ctx = createSearchExecutionContext(mapper, new IndexSearcher(reader)); Query query = new SingleValueMatchQuery( ctx.getForField(mapper.fieldType("foo"), MappedFieldType.FielddataOperation.SEARCH), - new Warnings(Source.EMPTY) + Warnings.createWarnings(DriverContext.WarningsMode.COLLECT, 1, 1, "test") ); runCase(List.of(), ctx.searcher().count(query)); } @@ -112,8 +112,8 @@ public class SingleValueMathQueryTests extends MapperServiceTestCase { // inner query matches none, so warn if MVs have been encountered within given range, OR if a full scan is required if (mvCountInRange > 0) { assertWarnings( - "Line -1:-1: evaluation of [] failed, treating result as null. Only first 20 failures recorded.", - "Line -1:-1: java.lang.IllegalArgumentException: single-value function encountered multi-value" + "Line 1:1: evaluation of [test] failed, treating result as null. Only first 20 failures recorded.", + "Line 1:1: java.lang.IllegalArgumentException: single-value function encountered multi-value" ); } } From 1708d9e25ebe207d6727bea898f6f94c86c52170 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Wed, 9 Oct 2024 23:10:21 +0100 Subject: [PATCH 19/43] Ensure that all rewriteable are called in retrievers (#114366) This PR ensures that all retriever applies the rewrite to all their rewriteable. Rewriting eagerly at the retriever level ensures that we don't rewrite the same query multiple times when compound retrievers are used. --- .../search/retriever/KnnRetrieverBuilder.java | 89 +++++++++++++++++-- .../retriever/StandardRetrieverBuilder.java | 44 +++++++++ .../rankdoc/RankDocsQueryBuilder.java | 17 ++++ .../search/vectors/KnnVectorQueryBuilder.java | 2 +- .../xpack/rank/rrf/RRFRetrieverBuilderIT.java | 62 +++++++++++++ 5 files changed, 204 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/search/retriever/KnnRetrieverBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/KnnRetrieverBuilder.java index 8e564430ef57..facda1a30a5a 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/KnnRetrieverBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/KnnRetrieverBuilder.java @@ -9,10 +9,12 @@ package org.elasticsearch.search.retriever; +import org.apache.lucene.util.SetOnce; import org.elasticsearch.common.ParsingException; import org.elasticsearch.features.NodeFeature; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryRewriteContext; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.retriever.rankdoc.RankDocsQueryBuilder; import org.elasticsearch.search.vectors.ExactKnnQueryBuilder; @@ -29,7 +31,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.function.Supplier; +import static org.elasticsearch.common.Strings.format; import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg; import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg; @@ -96,7 +100,7 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { } private final String field; - private final float[] queryVector; + private final Supplier queryVector; private final QueryVectorBuilder queryVectorBuilder; private final int k; private final int numCands; @@ -110,23 +114,85 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { int numCands, Float similarity ) { + if (queryVector == null && queryVectorBuilder == null) { + throw new IllegalArgumentException( + format( + "either [%s] or [%s] must be provided", + QUERY_VECTOR_FIELD.getPreferredName(), + QUERY_VECTOR_BUILDER_FIELD.getPreferredName() + ) + ); + } else if (queryVector != null && queryVectorBuilder != null) { + throw new IllegalArgumentException( + format( + "only one of [%s] and [%s] must be provided", + QUERY_VECTOR_FIELD.getPreferredName(), + QUERY_VECTOR_BUILDER_FIELD.getPreferredName() + ) + ); + } this.field = field; - this.queryVector = queryVector; + this.queryVector = queryVector != null ? () -> queryVector : null; this.queryVectorBuilder = queryVectorBuilder; this.k = k; this.numCands = numCands; this.similarity = similarity; } - // ---- FOR TESTING XCONTENT PARSING ---- + private KnnRetrieverBuilder(KnnRetrieverBuilder clone, Supplier queryVector, QueryVectorBuilder queryVectorBuilder) { + this.queryVector = queryVector; + this.queryVectorBuilder = queryVectorBuilder; + this.field = clone.field; + this.k = clone.k; + this.numCands = clone.numCands; + this.similarity = clone.similarity; + this.retrieverName = clone.retrieverName; + this.preFilterQueryBuilders = clone.preFilterQueryBuilders; + } @Override public String getName() { return NAME; } + @Override + public RetrieverBuilder rewrite(QueryRewriteContext ctx) throws IOException { + var rewrittenFilters = rewritePreFilters(ctx); + if (rewrittenFilters != preFilterQueryBuilders) { + var rewritten = new KnnRetrieverBuilder(this, queryVector, queryVectorBuilder); + rewritten.preFilterQueryBuilders = rewrittenFilters; + return rewritten; + } + + if (queryVectorBuilder != null) { + SetOnce toSet = new SetOnce<>(); + ctx.registerAsyncAction((c, l) -> { + queryVectorBuilder.buildVector(c, l.delegateFailureAndWrap((ll, v) -> { + toSet.set(v); + if (v == null) { + ll.onFailure( + new IllegalArgumentException( + format( + "[%s] with name [%s] returned null query_vector", + QUERY_VECTOR_BUILDER_FIELD.getPreferredName(), + queryVectorBuilder.getWriteableName() + ) + ) + ); + return; + } + ll.onResponse(null); + })); + }); + var rewritten = new KnnRetrieverBuilder(this, () -> toSet.get(), null); + return rewritten; + } + return super.rewrite(ctx); + } + @Override public QueryBuilder topDocsQuery() { + assert queryVector != null : "query vector must be materialized at this point"; assert rankDocs != null : "rankDocs should have been materialized by now"; var rankDocsQuery = new RankDocsQueryBuilder(rankDocs, null, true); if (preFilterQueryBuilders.isEmpty()) { @@ -139,10 +205,11 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { @Override public QueryBuilder explainQuery() { + assert queryVector != null : "query vector must be materialized at this point"; assert rankDocs != null : "rankDocs should have been materialized by now"; var rankDocsQuery = new RankDocsQueryBuilder( rankDocs, - new QueryBuilder[] { new ExactKnnQueryBuilder(VectorData.fromFloats(queryVector), field, similarity) }, + new QueryBuilder[] { new ExactKnnQueryBuilder(VectorData.fromFloats(queryVector.get()), field, similarity) }, true ); if (preFilterQueryBuilders.isEmpty()) { @@ -155,10 +222,11 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { @Override public void extractToSearchSourceBuilder(SearchSourceBuilder searchSourceBuilder, boolean compoundUsed) { + assert queryVector != null : "query vector must be materialized at this point."; KnnSearchBuilder knnSearchBuilder = new KnnSearchBuilder( field, - VectorData.fromFloats(queryVector), - queryVectorBuilder, + VectorData.fromFloats(queryVector.get()), + null, k, numCands, similarity @@ -174,6 +242,8 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { searchSourceBuilder.knnSearch(knnSearchBuilders); } + // ---- FOR TESTING XCONTENT PARSING ---- + @Override public void doToXContent(XContentBuilder builder, Params params) throws IOException { builder.field(FIELD_FIELD.getPreferredName(), field); @@ -181,7 +251,7 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { builder.field(NUM_CANDS_FIELD.getPreferredName(), numCands); if (queryVector != null) { - builder.field(QUERY_VECTOR_FIELD.getPreferredName(), queryVector); + builder.field(QUERY_VECTOR_FIELD.getPreferredName(), queryVector.get()); } if (queryVectorBuilder != null) { @@ -199,7 +269,8 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { return k == that.k && numCands == that.numCands && Objects.equals(field, that.field) - && Arrays.equals(queryVector, that.queryVector) + && ((queryVector == null && that.queryVector == null) + || (queryVector != null && that.queryVector != null && Arrays.equals(queryVector.get(), that.queryVector.get()))) && Objects.equals(queryVectorBuilder, that.queryVectorBuilder) && Objects.equals(similarity, that.similarity); } @@ -207,7 +278,7 @@ public final class KnnRetrieverBuilder extends RetrieverBuilder { @Override public int doHashCode() { int result = Objects.hash(field, queryVectorBuilder, k, numCands, similarity); - result = 31 * result + Arrays.hashCode(queryVector); + result = 31 * result + Arrays.hashCode(queryVector != null ? queryVector.get() : null); return result; } diff --git a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java index ac329eb293e9..108aafd8c777 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java @@ -14,6 +14,7 @@ import org.elasticsearch.features.NodeFeature; import org.elasticsearch.index.query.AbstractQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryRewriteContext; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SubSearchSourceBuilder; import org.elasticsearch.search.collapse.CollapseBuilder; @@ -27,6 +28,7 @@ import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentParser; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -105,6 +107,48 @@ public final class StandardRetrieverBuilder extends RetrieverBuilder implements this.queryBuilder = queryBuilder; } + private StandardRetrieverBuilder(StandardRetrieverBuilder clone) { + this.retrieverName = clone.retrieverName; + this.queryBuilder = clone.queryBuilder; + this.minScore = clone.minScore; + this.sortBuilders = clone.sortBuilders; + this.preFilterQueryBuilders = clone.preFilterQueryBuilders; + this.collapseBuilder = clone.collapseBuilder; + this.searchAfterBuilder = clone.searchAfterBuilder; + this.terminateAfter = clone.terminateAfter; + } + + @Override + public RetrieverBuilder rewrite(QueryRewriteContext ctx) throws IOException { + boolean changed = false; + List> newSortBuilders = null; + if (sortBuilders != null) { + newSortBuilders = new ArrayList<>(sortBuilders.size()); + for (var sort : sortBuilders) { + var newSort = sort.rewrite(ctx); + newSortBuilders.add(newSort); + changed = newSort != sort; + } + } + var rewrittenFilters = rewritePreFilters(ctx); + changed |= rewrittenFilters != preFilterQueryBuilders; + + QueryBuilder queryBuilderRewrite = null; + if (queryBuilder != null) { + queryBuilderRewrite = queryBuilder.rewrite(ctx); + changed |= queryBuilderRewrite != queryBuilder; + } + + if (changed) { + var rewritten = new StandardRetrieverBuilder(this); + rewritten.sortBuilders = newSortBuilders; + rewritten.preFilterQueryBuilders = preFilterQueryBuilders; + rewritten.queryBuilder = queryBuilderRewrite; + return rewritten; + } + return this; + } + @Override public QueryBuilder topDocsQuery() { if (preFilterQueryBuilders.isEmpty()) { diff --git a/server/src/main/java/org/elasticsearch/search/retriever/rankdoc/RankDocsQueryBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/rankdoc/RankDocsQueryBuilder.java index 86cb27cb7ba7..1539be9a46ab 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/rankdoc/RankDocsQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/rankdoc/RankDocsQueryBuilder.java @@ -18,6 +18,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.query.AbstractQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryRewriteContext; import org.elasticsearch.index.query.SearchExecutionContext; import org.elasticsearch.search.rank.RankDoc; import org.elasticsearch.xcontent.XContentBuilder; @@ -54,6 +55,22 @@ public class RankDocsQueryBuilder extends AbstractQueryBuilder client().prepareSearch(INDEX).setSource(source).get()); } + + public void testRewriteOnce() { + final float[] vector = new float[] { 1 }; + AtomicInteger numAsyncCalls = new AtomicInteger(); + QueryVectorBuilder vectorBuilder = new QueryVectorBuilder() { + @Override + public void buildVector(Client client, ActionListener listener) { + numAsyncCalls.incrementAndGet(); + listener.onResponse(vector); + } + + @Override + public String getWriteableName() { + throw new IllegalStateException("Should not be called"); + } + + @Override + public TransportVersion getMinimalSupportedVersion() { + throw new IllegalStateException("Should not be called"); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + throw new IllegalStateException("Should not be called"); + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + throw new IllegalStateException("Should not be called"); + } + }; + var knn = new KnnRetrieverBuilder("vector", null, vectorBuilder, 10, 10, null); + var standard = new StandardRetrieverBuilder(new KnnVectorQueryBuilder("vector", vectorBuilder, 10, 10, null)); + var rrf = new RRFRetrieverBuilder( + List.of(new CompoundRetrieverBuilder.RetrieverSource(knn, null), new CompoundRetrieverBuilder.RetrieverSource(standard, null)), + 10, + 10 + ); + assertResponse( + client().prepareSearch(INDEX).setSource(new SearchSourceBuilder().retriever(rrf)), + searchResponse -> assertThat(searchResponse.getHits().getTotalHits().value, is(4L)) + ); + assertThat(numAsyncCalls.get(), equalTo(2)); + + // check that we use the rewritten vector to build the explain query + assertResponse( + client().prepareSearch(INDEX).setSource(new SearchSourceBuilder().retriever(rrf).explain(true)), + searchResponse -> assertThat(searchResponse.getHits().getTotalHits().value, is(4L)) + ); + assertThat(numAsyncCalls.get(), equalTo(4)); + } } From 19ec3d960e34298efb7cf981df0d6f3593d97f0b Mon Sep 17 00:00:00 2001 From: Salvatore Campagna <93581129+salvatore-campagna@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:21:57 +0200 Subject: [PATCH 20/43] Return `_ignored_source` only if explicitly requested via `stored_fields` or `fields` (#114145) We do not want to return `_ignored_source` with every search hit. Other than being expensive (especially when there are many ignored fields), it also exposes some implementation details. Anyway, it might still be useful to have the ability to retrieve it if necessary, at least for debugging purposes. For this reason we require that it is explicitly requested using `stored_fields` or `fields` and we do not return it by default or if requested via a wildcard `*` in `stored_fields` or `fields`. --- .../fetch/subphase/FetchFieldsPhase.java | 28 ++- .../rest-api-spec/test/20_ignored_source.yml | 164 ++++++++++++++++++ 2 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/20_ignored_source.yml diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java index 9c5677542136..03bfbd40d97b 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java @@ -11,8 +11,10 @@ package org.elasticsearch.search.fetch.subphase; import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.common.document.DocumentField; +import org.elasticsearch.common.regex.Regex; import org.elasticsearch.index.mapper.IdFieldMapper; import org.elasticsearch.index.mapper.IgnoredFieldMapper; +import org.elasticsearch.index.mapper.IgnoredSourceFieldMapper; import org.elasticsearch.index.mapper.LegacyTypeFieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.RoutingFieldMapper; @@ -61,6 +63,21 @@ public final class FetchFieldsPhase implements FetchSubPhase { : fetchFieldsContext.fields().isEmpty() ? null : FieldFetcher.create(searchExecutionContext, fetchFieldsContext.fields()); + // NOTE: Collect stored metadata fields requested via `fields` (in FetchFieldsContext`) like for instance the _ignored source field + final Set fetchContextMetadataFields = new HashSet<>(); + if (fetchFieldsContext != null && fetchFieldsContext.fields() != null && fetchFieldsContext.fields().isEmpty() == false) { + for (final FieldAndFormat fieldAndFormat : fetchFieldsContext.fields()) { + // NOTE: _id and _source are always retrieved anyway, no need to do it explicitly. See FieldsVisitor. + if (SourceFieldMapper.NAME.equals(fieldAndFormat.field) || IdFieldMapper.NAME.equals(fieldAndFormat.field)) { + continue; + } + if (searchExecutionContext.isMetadataField(fieldAndFormat.field) + && searchExecutionContext.getFieldType(fieldAndFormat.field).isStored()) { + fetchContextMetadataFields.add(fieldAndFormat); + } + } + } + final FieldFetcher metadataFieldFetcher; if (storedFieldsContext != null && storedFieldsContext.fieldNames() != null @@ -73,6 +90,10 @@ public final class FetchFieldsPhase implements FetchSubPhase { continue; } final MappedFieldType fieldType = searchExecutionContext.getFieldType(matchingFieldName); + // NOTE: Exclude _ignored_source when requested via wildcard '*' + if (matchingFieldName.equals(IgnoredSourceFieldMapper.NAME) && Regex.isSimpleMatchPattern(storedField)) { + continue; + } // NOTE: checking if the field is stored is required for backward compatibility reasons and to make // sure we also handle here stored fields requested via `stored_fields`, which was previously a // responsibility of StoredFieldsPhase. @@ -81,9 +102,14 @@ public final class FetchFieldsPhase implements FetchSubPhase { } } } + // NOTE: Include also metadata stored fields requested via `fields` + metadataFields.addAll(fetchContextMetadataFields); metadataFieldFetcher = FieldFetcher.create(searchExecutionContext, metadataFields); } else { - metadataFieldFetcher = FieldFetcher.create(searchExecutionContext, DEFAULT_METADATA_FIELDS); + // NOTE: Include also metadata stored fields requested via `fields` + final Set allMetadataFields = new HashSet<>(DEFAULT_METADATA_FIELDS); + allMetadataFields.addAll(fetchContextMetadataFields); + metadataFieldFetcher = FieldFetcher.create(searchExecutionContext, allMetadataFields); } return new FetchSubPhaseProcessor() { @Override diff --git a/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/20_ignored_source.yml b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/20_ignored_source.yml new file mode 100644 index 000000000000..c54edb099486 --- /dev/null +++ b/x-pack/plugin/logsdb/src/yamlRestTest/resources/rest-api-spec/test/20_ignored_source.yml @@ -0,0 +1,164 @@ +--- +setup: + - skip: + features: headers + - do: + indices.create: + index: test + body: + mappings: + _source: + mode: synthetic + properties: + object: + enabled: false + + - do: + headers: + Content-Type: application/yaml + index: + index: test + id: "1" + refresh: true + body: + object: + name: "foo" + value: 10 + +--- +"fetch stored fields wildcard": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + stored_fields: [ "*" ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: null } + +--- +"fetch fields wildcard": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + fields: [ "*" ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: null } + +--- +"fetch stored fields by name": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + stored_fields: [ _ignored_source ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: !!binary "BgAAAG9iamVjdHktLS0KbmFtZTogImZvbyIKdmFsdWU6IDEwCg==" } + +--- +"fetch fields by name": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + fields: [ _ignored_source ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: !!binary "BgAAAG9iamVjdHktLS0KbmFtZTogImZvbyIKdmFsdWU6IDEwCg==" } + +--- +"fields and stored fields combination": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + stored_fields: [ _ignored_source ] + fields: [ _ignored_source ] + query: + match_all: {} + + - match: { hits.total.value: 1 } + - match: { hits.hits.0.fields.object: null } + - match: { hits.hits.0._ignored_source: !!binary "BgAAAG9iamVjdHktLS0KbmFtZTogImZvbyIKdmFsdWU6IDEwCg==" } + +--- +"wildcard fields and stored fields combination": + - do: + search: + index: test + body: + stored_fields: [ "*" ] + fields: [ "*" ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: null } + +--- +"fields with ignored source in stored fields": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + stored_fields: [ _ignored_source ] + fields: [ object ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: !!binary "BgAAAG9iamVjdHktLS0KbmFtZTogImZvbyIKdmFsdWU6IDEwCg==" } + - match: { hits.hits.0.fields: null } + +--- +"fields with ignored source in fields": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + stored_fields: [ object ] + fields: [ _ignored_source ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: !!binary "BgAAAG9iamVjdHktLS0KbmFtZTogImZvbyIKdmFsdWU6IDEwCg==" } + +--- +"ignored source via fields and wildcard stored fields": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + stored_fields: [ "*" ] + fields: [ _ignored_source ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: !!binary "BgAAAG9iamVjdHktLS0KbmFtZTogImZvbyIKdmFsdWU6IDEwCg==" } + +--- +"wildcard fields and ignored source via stored fields": + - do: + headers: + Content-Type: application/yaml + search: + index: test + body: + stored_fields: [ _ignored_source ] + fields: [ "*" ] + + - match: { hits.total.value: 1 } + - match: { hits.hits.0._ignored_source: !!binary "BgAAAG9iamVjdHktLS0KbmFtZTogImZvbyIKdmFsdWU6IDEwCg==" } From ee5be48fddee15ae9aea64d94788e5947c6a0c87 Mon Sep 17 00:00:00 2001 From: Joe Gallo Date: Wed, 9 Oct 2024 19:16:59 -0400 Subject: [PATCH 21/43] IPinfo privacy detection support (#114456) --- .../elasticsearch/ingest/geoip/Database.java | 14 ++- .../ingest/geoip/IpinfoIpDataLookups.java | 90 ++++++++++++++++++ .../geoip/IpinfoIpDataLookupsTests.java | 87 +++++++++++++++++ .../ingest/geoip/MaxMindSupportTests.java | 6 +- .../ipinfo/privacy_detection_sample.mmdb | Bin 0 -> 26352 bytes 5 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 modules/ingest-geoip/src/test/resources/ipinfo/privacy_detection_sample.mmdb diff --git a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/Database.java b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/Database.java index 4c2f047c3570..61ec1e74b40a 100644 --- a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/Database.java +++ b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/Database.java @@ -181,7 +181,11 @@ enum Database { Property.POSTAL_CODE ), Set.of(Property.COUNTRY_ISO_CODE, Property.REGION_NAME, Property.CITY_NAME, Property.LOCATION) - ),; + ), + PrivacyDetection( + Set.of(Property.IP, Property.HOSTING, Property.PROXY, Property.RELAY, Property.TOR, Property.VPN, Property.SERVICE), + Set.of(Property.HOSTING, Property.PROXY, Property.RELAY, Property.TOR, Property.VPN, Property.SERVICE) + ); private final Set properties; private final Set defaultProperties; @@ -262,7 +266,13 @@ enum Database { TYPE, POSTAL_CODE, POSTAL_CONFIDENCE, - ACCURACY_RADIUS; + ACCURACY_RADIUS, + HOSTING, + TOR, + PROXY, + RELAY, + VPN, + SERVICE; /** * Parses a string representation of a property into an actual Property instance. Not all properties that exist are diff --git a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookups.java b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookups.java index d2c734cb9bae..06051879a074 100644 --- a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookups.java +++ b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookups.java @@ -58,6 +58,31 @@ final class IpinfoIpDataLookups { } } + /** + * Lax-ly parses a string that contains a boolean into a Boolean (or null, if such parsing isn't possible). + * @param bool a potentially empty (or null) string that is expected to contain a parsable boolean + * @return the parsed boolean + */ + static Boolean parseBoolean(final String bool) { + if (bool == null) { + return null; + } else { + String trimmed = bool.toLowerCase(Locale.ROOT).trim(); + if ("true".equals(trimmed)) { + return true; + } else if ("false".equals(trimmed)) { + // "false" can represent false -- this an expected future enhancement in how the database represents booleans + return false; + } else if (trimmed.isEmpty()) { + // empty string can represent false -- this is how the database currently represents 'false' values + return false; + } else { + logger.trace("Unable to parse non-compliant boolean string [{}]", bool); + return null; + } + } + } + /** * Lax-ly parses a string that contains a double into a Double (or null, if such parsing isn't possible). * @param latlon a potentially empty (or null) string that is expected to contain a parsable double @@ -132,6 +157,22 @@ final class IpinfoIpDataLookups { } } + public record PrivacyDetectionResult(Boolean hosting, Boolean proxy, Boolean relay, String service, Boolean tor, Boolean vpn) { + @SuppressWarnings("checkstyle:RedundantModifier") + @MaxMindDbConstructor + public PrivacyDetectionResult( + @MaxMindDbParameter(name = "hosting") String hosting, + // @MaxMindDbParameter(name = "network") String network, // for now we're not exposing this + @MaxMindDbParameter(name = "proxy") String proxy, + @MaxMindDbParameter(name = "relay") String relay, + @MaxMindDbParameter(name = "service") String service, // n.b. this remains a string, the rest are parsed as booleans + @MaxMindDbParameter(name = "tor") String tor, + @MaxMindDbParameter(name = "vpn") String vpn + ) { + this(parseBoolean(hosting), parseBoolean(proxy), parseBoolean(relay), service, parseBoolean(tor), parseBoolean(vpn)); + } + } + static class Asn extends AbstractBase { Asn(Set properties) { super(properties, AsnResult.class); @@ -286,6 +327,55 @@ final class IpinfoIpDataLookups { } } + static class PrivacyDetection extends AbstractBase { + PrivacyDetection(Set properties) { + super(properties, PrivacyDetectionResult.class); + } + + @Override + protected Map transform(final Result result) { + PrivacyDetectionResult response = result.result; + + Map data = new HashMap<>(); + for (Database.Property property : this.properties) { + switch (property) { + case IP -> data.put("ip", result.ip); + case HOSTING -> { + if (response.hosting != null) { + data.put("hosting", response.hosting); + } + } + case TOR -> { + if (response.tor != null) { + data.put("tor", response.tor); + } + } + case PROXY -> { + if (response.proxy != null) { + data.put("proxy", response.proxy); + } + } + case RELAY -> { + if (response.relay != null) { + data.put("relay", response.relay); + } + } + case VPN -> { + if (response.vpn != null) { + data.put("vpn", response.vpn); + } + } + case SERVICE -> { + if (Strings.hasText(response.service)) { + data.put("service", response.service); + } + } + } + } + return data; + } + } + /** * Just a little record holder -- there's the data that we receive via the binding to our record objects from the Reader via the * getRecord call, but then we also need to capture the passed-in ip address that came from the caller as well as the network for diff --git a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookupsTests.java b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookupsTests.java index f58f8819e7ed..039c826337ca 100644 --- a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookupsTests.java +++ b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/IpinfoIpDataLookupsTests.java @@ -38,7 +38,9 @@ import java.util.function.BiConsumer; import static java.util.Map.entry; import static org.elasticsearch.ingest.geoip.GeoIpTestUtils.copyDatabase; import static org.elasticsearch.ingest.geoip.IpinfoIpDataLookups.parseAsn; +import static org.elasticsearch.ingest.geoip.IpinfoIpDataLookups.parseBoolean; import static org.elasticsearch.ingest.geoip.IpinfoIpDataLookups.parseLocationDouble; +import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -93,6 +95,21 @@ public class IpinfoIpDataLookupsTests extends ESTestCase { assertThat(parseAsn("anythingelse"), nullValue()); } + public void testParseBoolean() { + // expected cases: "true" is true and "" is false + assertThat(parseBoolean("true"), equalTo(true)); + assertThat(parseBoolean(""), equalTo(false)); + assertThat(parseBoolean("false"), equalTo(false)); // future proofing + // defensive case: null becomes null, this is not expected fwiw + assertThat(parseBoolean(null), nullValue()); + // defensive cases: we strip whitespace and ignore case + assertThat(parseBoolean(" "), equalTo(false)); + assertThat(parseBoolean(" TrUe "), equalTo(true)); + assertThat(parseBoolean(" FaLSE "), equalTo(false)); + // bottom case: a non-parsable string is null + assertThat(parseBoolean(randomAlphaOfLength(8)), nullValue()); + } + public void testParseLocationDouble() { // expected case: "123.45" is 123.45 assertThat(parseLocationDouble("123.45"), equalTo(123.45)); @@ -287,6 +304,76 @@ public class IpinfoIpDataLookupsTests extends ESTestCase { } } + public void testPrivacyDetection() throws IOException { + assumeFalse("https://github.com/elastic/elasticsearch/issues/114266", Constants.WINDOWS); + Path configDir = tmpDir; + copyDatabase("ipinfo/privacy_detection_sample.mmdb", configDir.resolve("privacy_detection_sample.mmdb")); + + GeoIpCache cache = new GeoIpCache(1000); // real cache to test purging of entries upon a reload + ConfigDatabases configDatabases = new ConfigDatabases(configDir, cache); + configDatabases.initialize(resourceWatcherService); + + // testing the first row in the sample database + try (DatabaseReaderLazyLoader loader = configDatabases.getDatabase("privacy_detection_sample.mmdb")) { + IpDataLookup lookup = new IpinfoIpDataLookups.PrivacyDetection(Database.PrivacyDetection.properties()); + Map data = lookup.getData(loader, "1.53.59.33"); + assertThat( + data, + equalTo( + Map.ofEntries( + entry("ip", "1.53.59.33"), + entry("hosting", false), + entry("proxy", false), + entry("relay", false), + entry("tor", false), + entry("vpn", true) + ) + ) + ); + } + + // testing a row with a non-empty service in the sample database + try (DatabaseReaderLazyLoader loader = configDatabases.getDatabase("privacy_detection_sample.mmdb")) { + IpDataLookup lookup = new IpinfoIpDataLookups.PrivacyDetection(Database.PrivacyDetection.properties()); + Map data = lookup.getData(loader, "216.131.74.65"); + assertThat( + data, + equalTo( + Map.ofEntries( + entry("ip", "216.131.74.65"), + entry("hosting", true), + entry("proxy", false), + entry("service", "FastVPN"), + entry("relay", false), + entry("tor", false), + entry("vpn", true) + ) + ) + ); + } + } + + public void testPrivacyDetectionInvariants() { + assumeFalse("https://github.com/elastic/elasticsearch/issues/114266", Constants.WINDOWS); + Path configDir = tmpDir; + copyDatabase("ipinfo/privacy_detection_sample.mmdb", configDir.resolve("privacy_detection_sample.mmdb")); + + { + final Set expectedColumns = Set.of("network", "service", "hosting", "proxy", "relay", "tor", "vpn"); + + Path databasePath = configDir.resolve("privacy_detection_sample.mmdb"); + assertDatabaseInvariants(databasePath, (ip, row) -> { + assertThat(row.keySet(), equalTo(expectedColumns)); + + for (String booleanColumn : Set.of("hosting", "proxy", "relay", "tor", "vpn")) { + String bool = (String) row.get(booleanColumn); + assertThat(bool, anyOf(equalTo("true"), equalTo(""), equalTo("false"))); + assertThat(parseBoolean(bool), notNullValue()); + } + }); + } + } + private static void assertDatabaseInvariants(final Path databasePath, final BiConsumer> rowConsumer) { try (Reader reader = new Reader(pathToFile(databasePath))) { Networks networks = reader.networks(Map.class); diff --git a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/MaxMindSupportTests.java b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/MaxMindSupportTests.java index d377a9b97fcc..068867deeea3 100644 --- a/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/MaxMindSupportTests.java +++ b/modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/MaxMindSupportTests.java @@ -361,7 +361,11 @@ public class MaxMindSupportTests extends ESTestCase { private static final Set> KNOWN_UNSUPPORTED_RESPONSE_CLASSES = Set.of(IpRiskResponse.class); - private static final Set KNOWN_UNSUPPORTED_DATABASE_VARIANTS = Set.of(Database.AsnV2, Database.CityV2); + private static final Set KNOWN_UNSUPPORTED_DATABASE_VARIANTS = Set.of( + Database.AsnV2, + Database.CityV2, + Database.PrivacyDetection + ); public void testMaxMindSupport() { for (Database databaseType : Database.values()) { diff --git a/modules/ingest-geoip/src/test/resources/ipinfo/privacy_detection_sample.mmdb b/modules/ingest-geoip/src/test/resources/ipinfo/privacy_detection_sample.mmdb new file mode 100644 index 0000000000000000000000000000000000000000..ac669536ae18322cb5d8d87e9e99023a47becd48 GIT binary patch literal 26352 zcmb811$0zbw1y`N!QCaeX2?t&DZ#C{6DWibAV>lsXesXQ?(Xg_6fG2YZK1fkw52V) z|D5wDv!`$9darApe*6FT-shfs@40tovbt)qSlld@6af~C#hvu9SbTnm_N4YAy~$)` za?*!PL8c^Ak*UcvWLh#EnV!r*W+XF_naM09`q8(o~Y|3^1bP+b@yf5PvpOa-=F?>oDG0crcJe~14#N!c9qMkrbgs(gd%Vd$C z!u(WnnxU?nA>x_nncN7;}wpnJ4n|;V%$+p{ZB*MBkUi$S+~Mlw4-0^ULY2 zK;25=uYz7J^cv{3La&2f&)yBf-$-v0xtZL8`mKz&k=w}~hI&0aQMZfwAoF|3?~%KJ z@dNcsOQC8mP7Op3;ziGpXeVI{xNz#lgCkag7HaFcMAS#q0c~{W!*X9 zpGW+b{zdWh)j8yf=jYg*Cszzlre_;}*T&MBQ!pcj(_G?}_|<=x6MCj=C4Ze+m7Hx!2?ylIO3_=N-NGsQD6*lzfjs#U|y9m7LtPiQZpy`hr{ot%9>@KXpsC3Gt0QVTx~ zy|lPaJ%yhh^%Y!8oU=%S8|O#4Qiwydv*QFCX&x85a=w zg7gX@Ul^k}brG^CSr0XTq>Z$biT5KA^931C_Xk6VuqKoY zBTJKI40U~3)RzS?{bLfVB==K<+CPshO) zoebgY$)=L=rtyrpuVZdH>2MiehcA8&~FL9mGHlTZp~a9GE(H* z(u+b}I}@kE-d5+V&$~U@0r`%?kAdzabZ6);tnEt1l5wK08|u0X9nYE`WCHT?Iq5~e zH`#~mi@JV{zcoz7ec<*Taxvc_~KMnqL#xorGRJf*YvoJO@H=CRTZ!Y6`j(WHG@E6cu zDEvk67Yn_FHA~55$m5w#y8kPnR|>s~b*tg8u~<@JZnw4MIzxRv>shyf+=#kOj=b*M z0`COIR@Q7Iw;Sqtb|Ak~=v}PYP3|GTCx1ZwUdH^*YYdKL;QENqrZfFA9AL`m)ehps%v` zn((i~zajK5(7$5bW$jJGw=9;_p5SlfZ9~1DJEl(O?}_+6YagKRq3|Dx-Y59|5RLp( z9_tx&AmiuoUqE|Nzl46p__d)v{u}sj>Aw^Hd-xxO{vG-cq5ovhNBDmU|8MAjg#HBm z*`eJnSd*L3Fx)+icE>eRYf2p~^4`oPBa@Rp=u3f-3nL}HRAg#0jiH*;JuOB$`sv9G zWJWR*nVHN&W+k&3>iM!`z8pg5G;!+otj$g4A@ic%*TlL%A9Q}^3XlcKLZYrP>WW}k znJbF87_QL_>f&SxvLxwesOsEHiP#_7#u__`>!YuG;+#RKsf`hAe7)Wf=un}cI zxq70$KD`FWHxzy&`i6l&`a63j9gBxAXk#B(6^fL8bh`IG+4X)I{NF$4UW9~MtYl2w^{gG=x-&rk=s$X zgYiy7eVul}-!1eW)_f2D2gZ9vejnDx=h1yXYRA7h+2 z-*M^_AV{JXBLY`9q>8*7vxL$zVKgx z$?3g@e#7{!p+2v7@ZSslfi=Iw|3mnHLVpzcFV_7{{zKyWx_>sYhlO-ARLAph$3Q~I zo}?G)O(ru;+s;te`Y@LQ{V5rz68Y5h(vWFUmyU6IGJ~O>FC+4qgw70|Md+;1+1Qs| z_&Mn1L_U}BbJNd5<~2+^lR6*j^D{1hIE-;YvJhFAEJ7AVZ865h4fXm$y7vI1F=tc2rL zW?aQkucs<}>}?fmU7f5!)i9H&UjgW6F z@=fSBC7Y4W$rfY;`dTt>MSf$b*WDWVHuNLOwqz73_jfev+Z$i^cYy9Fbd1H44)mlJjV0M1)^>ty+x>7?C{fJJswLjb}_#U z@p8s19CaQm;ja>UHEY(uU(0wMxt`o$sLy93>Ne5eOl}eRt;lbqzg_q{;O{g#-G1Tk zX6+vGd-4ZzFS(EWk>ng62dEE{hseV?-Vw$>8S3>PrFRVZpM`(i#OYo!f08^!o+i(b zXUTJz=RD&JhWa=c;a?K^GV~SJT^0T{_}A&*5dJUle--*B^exu?M&2gxIO@_DLft)l zj%Nk$V|-%G1M(sH2)W0OK948RPlbL4{aol5&@b7Wc#U3*{2S)pqV65z_ags+-tXie zsQXjoKSKY-+~30g$HeJdF!$Ne(}Ht!W9&|P7^>^LCH0YsB0tgki~9bIzas}2>h%qzHwblug+GM;Q24_b z4;T3n@J9+g3VJl_#t45bJv^(P;~7tI!u2S8olYr&tN>0oF(dJ z)0>03xs2zL^F`eP^gZbNLO)>NL->z`{}>wAQaxMx`Fct| zga2IkFX+D{Uy-j3GuEMgOTI(@dlTzhjM#f# zSyK!C*TSz2&Ashamo@ds`l7A@ zy@sf7B>cuE&V+mE)f5AJ+N&7`o?ox#7$Y%Sur~s6JmZ#REAkuUS~G4#MjGn#X^VW6 z(Ct_g4Zl6(4rE6%hU{dh=jn|4E<$%@O)MElc0*lvM_ndd8?PSBC6GPIUXD7i-l*$C zzc1NO@jk(d}7;-Ff<1iLc zk4HR#@kB#?ohHGbEc6uUsX|X<&vbGI@-sz#7X8`q=Lml;^gQO~3x5H+Mco$Uw>osDr_kG3$Mt&c zq~3+xNyfX$J>>V~59D5QA9{W?vA+KM=^uc9knth%FnPpK*Z+jNqe35p{#oeb>^WhW z*%$d!B7d6sGvrzF9O}-Cx(m=3nY$$X%kZxVeU&xW;9qBaL*##f|Eth9p>G+Txq1NaXaKN9)J@Sg~c`=+ngGx9n40(CDLzcSQyuj#!({w>A_>UZRO z!^|U*`<>n&!uu2cNBVyW|8I*$_2^@K!hh#njqzv17L05dZpQO=Cp`>RkGCg=7kxA+ zPy5N>Cl}fWI)%_Fp;NIoweZu>ON)Fu;ispc0e(itnaIqdE(^V^I4|sFy_W3g@n@Wa z%t_`#E;r*mhPo#&J?u~Ke8SI9zW`Yf`9dOJn0^uXMTK9CesQt{SrT=AjICrT!_2tP zdM!56P9|RCK%;d{5atPHK1BGT@Wber7JeD{W$Bj_{#WqJ(+?*rkQK>FhWfab=~W@C z8fL+HdRG^9HK1!^L}Jtu{@3iQP1ZrauE^J;Umrf7NAHFr-w1wV)-)lTlFdY2bJVq< zA3?Sh`BwD4AzP!qjft}$R_ChEw=Efkd^^U`BHtc<2cbJc$FQyw*_rG@b~V)V$D%%t zemCKFrx#E5AQQ-*WH0phHnEy7%S7nD7E5wmXYYO%OS134Z!zv;^v5`kp}d*wA3zR- zH^?!M_h9-%$f3v&V?3N3VW`hzB=V!^k0!^6{8;422|b=Q6X0XbY7RZmBStqYVeK4pF1&f7Za(w^<`$BRM1C>7C8%2}{AJL~gxy{qIk)L&awCQo6y;zbFeNanM>qzBcDg;ysYsh z^O5<<0;n&@xR9Yf-@@>V&@U?dV)TlWd=|3dnkMrTbynz7tnnvpB5$Xcczpv=A4D%$ z)P>LsCBw+ls4v5~tf5|aIeK3qU!HL|;;M`*Ag*Y!WK+khWT^WpGhf9}<#kOp)KzD$ z23eD=<*3zj)TUp@Pc=`Wt4OkNg0PyYvSl9)vN6dN4Tz-cZKF4E6ek!yiF^ zr0_@48;$%J#$(BG|PZxRy^h}{=v2V6vw)4o(#W+rX z9;wcM0me4!g@_lKSg&U>{Uz|1GG0b5Cs!Ei`jzxnk*moy=wB=9)P6|+-a!Su?zX#Lhph8o^?M6e=og#$p0w({m=)5KFGR5@DDRSLjFV^ zC65{Eb^L6xWDgPg1o}_1?i6{NJR|DPqV61h+&ewj1(ClkHgr6QdgU}hFGqE-^nT5WVWiVW`(p z622dXKZey}$)T=aDMOW4T6;E!mmI$C4J3oeU@H0YWE(OPeQg;>k?joiywUX9qpkzvj)*%k zjxo#;hx>@3d+-iX)NxnT#tNNS(~bG=$j6I(5BdpYPvm=vd~f=F;P++RPvpO)*Pr~3 z96$~v2cds3<00fwL%r@{^oHZS7Be1+|38S@f1@zI#~6*V1Y->IV@3Zs_~V71z?zBh zCkcNt{VDLL3V#~(bmnG|Gev$Dz1id()Xx?9dC>EPUI4vN=tb&XqM+sJs6p}x+W>1{!NE8}eO3HCRX$1 zOb-16b9)iL!Ptj!gWiwie)0fv2N@qC50gg>^*Vn--BF>BvF2y;IPxbLpA>bc;Gf30 z#M~M3EWC4AZ#eaN=nFz$G``BKk^C~o6^EA`_bmA}_Fi}Rdab|E|J6`?H|gCXe?$Lm z#&^iOa;>ey=d zU?Rnw*zZ0m>7^o5lWEAbhPp2uz4T-T^k-z8Nz`SApGD}b(Ak8}&Ym1(PULfmd~W)A z$h=r9@3&7rQJ0_j0_ZO&{6h2#!!N?PC|QgwZm7?z1nNo(?FVfYx)gi-;oF37hfchv zfvgF#SaRWf^}NA`O8bOj;Cb{3!&r$?8lw+J8H@(3FH4pqze29OiS>MVrhFdJNnUNd$I#^F&G_jUxpe_F)`Nb>de|M zsOxHC?Z?uOgWrvDcQT&rVVG+#Y7#K7Vo$Oc;@*zDp0h8!N$l;1_*)a}Tz}~AgdV`U zf$#?je=z+a@Oe%?!{`ksN01{8_57pgjYi)X;g6+1jvP-;K;1+~U9K1OCzDgispK@& zPiH)XoN1_!KMVQULeF8%Tyh@r^F@9E{e|Qr&Xq|Mnk>+O{m*Ue+#*l+(vFEcaS^LvybsE#Jeq)+}Qg*dkpow-$VaE zANxn;m9Oi56!Cu49pGFCg?|YCVWE#W=FsyWMgAE3en$Ko760Z zlIO_t45c57_{8;3l(0hvfGse$J?sYxSOXOeCe{HD!H}K!me@DI-`41+}t?ut1%>M~y zVf>N&3;Dkp|3iKvKO3g7kZzhLy#>hjRSNOh&^9h}wF`n-f z1sN9-`NE8gkVU~_jEj>c$daTVX(iQqN-_2)ZJ?bo@_EYP<~aTHuv*8s9tknA9m1={ zMkn-+i|^dnW(^9k28CGz0{k3dm2UBIefox1iI46Q**CmekLdVbF;UUsl@j9O!z=ab z7F#(XzGw79UpL?Cz9}MXR+}xvY6}js+JZtciB=*0R=dC5w`jO;sc_%maNqLbzLmq- z(LBIv4@Lu;0_=WLIM@4DM?<)8iiUw!yEP=#8fy1TidR%0s=NMtf zbqK`iDcJp-l=C5yIs$^N0l4O&I7XnqpOgA>hdn?a!)DhV4)ukOKs#0xVhzK^w1xON zDHk2;O0^8cnsDxRtj!+gC)JlOmafKj3BdIY^%E-eUmHlDy54hvA$ncv+=B!B911td zd0o6A%>%=%xOZXxsK+6Ma4t_ef@-h_hFSyE9aIfT!nq-FPq$PhK{)kb8?Kgapn~(i zTht!G)(Z`^+Uz!*ioc(ea&Abv<3V`1)T}rQe{@Lor4F@K1FfOBA2^L5sa$uovfu>l zcC0H{U8_JpC;5fV%O*9u+P-0?DM|j!Q3_+LI~IO5hw}4z0nV$Zb(vJxGfQ(>Q>^Z!n*K3UjXc>b{cZGkpFDV)m_H*s^6s2dm-XblKf^-01-y;@Q$3yN@m z@p$1<`Qz;?q|NoB(4*>c7TszKfWa3eHR?!=cK;S zf!Cr{-;Pjg7`}=~<+`Jl#paKP#6L)VG~ii5kCZN&%$BsN4=X(6>TwSVLYG5^erZeE z{PCp#FGaP#@TfRT7e`X>2vrn>OAzR94bdHm!gYOw%^zFDA7_uVQ4K=5?!X1Wi_wN{ zk2`7$4fAuBuA3rs5k4C6e!%NdsxQ8V@sd-U(Hf?%R4{s^bbT1LHdNuUSD%w%I3FkJ zx(RDj4;CI_>|)g-l;i=RUqI zaV$G7HwuGsxz!$ZlFmJeugq5NHnlo+Cg`-|%ih2A7us+vw5e|}>bod*sgrcw)ZB*c zsecYw?P_%n;krITmDufJR&}HB_(wZYYa~E@55zTa)-Dc&_Z99f%IxYZy!u?gOU_BUZfdUXsCsJ$=?7K_*Y!9EzRKG| z@D&jINWJEqdE5n-fu2VNu2-o!yHhjlYw*#9j1UFME7ae?! z;3cYWh7vPTDD~S2uOIcJSWS{7U2lh0?&?$0riOYs z;5X&J^cRj5q06w>@Z%*|U3W}Cm2~y0RgLVC(4<}+{gs`rDx)f|lP3jB0- zK9;!bA?oL=O?_{`*Ax61LP+PH#I2-G3*YzgT?>~SPolaOPTEDAx`fTtpLp;}z}pBr z(8RdOfl24&_%oLJxnRfV7j~=K={9U~sazZ&u|r)byo>{I+0^G>qH@up?`lqauzx`5 zApfX<(oz2Y{-sO%IgIxBr}UTpEMj_(l@7rWT~-`SX0M|M%IwmoCI zv}+yREiS5~r+WwYV`*!*i%f`Y8`&eebwb~6(XEojbc=~?ALrXGKBiY>RNvO^q7$N{ z5-@S=9+6$Ub&0li?b@zwt#;8pqT*w^DgSoG=-B^TSIwAiNvrg((IqmrL(j+#(LLNe kF+mD)vq8I!A4^hu&qyPW_ literal 0 HcmV?d00001 From 5f25cf90eb602368d6f276ab6bc00c18ae98c048 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Thu, 10 Oct 2024 00:32:42 +0100 Subject: [PATCH 22/43] [ML] Filter empty task settings objects from the API response (#114389) Inference endpoints that do not define task settings or where there are no defaults return an empty task_setting object. Filter this object from the response --- docs/changelog/114389.yaml | 5 +++++ .../elasticsearch/inference/EmptyTaskSettings.java | 5 +++++ .../elasticsearch/inference/ModelConfigurations.java | 12 ++++++++++-- .../org/elasticsearch/inference/TaskSettings.java | 4 +++- .../inference/qa/mixed/OpenAIServiceMixedIT.java | 6 ++++-- .../xpack/application/CohereServiceUpgradeIT.java | 5 ++++- .../application/HuggingFaceServiceUpgradeIT.java | 5 ++++- .../xpack/application/OpenAiServiceUpgradeIT.java | 9 ++++++--- .../inference/mock/AbstractTestInferenceService.java | 8 +++++++- .../xpack/inference/integration/ModelRegistryIT.java | 5 +++++ .../AlibabaCloudSearchService.java | 4 ++-- .../AlibabaCloudSearchCompletionTaskSettings.java | 7 ++++++- .../AlibabaCloudSearchEmbeddingsTaskSettings.java | 4 ++++ .../rerank/AlibabaCloudSearchRerankTaskSettings.java | 4 ++++ .../sparse/AlibabaCloudSearchSparseTaskSettings.java | 5 +++++ .../services/amazonbedrock/AmazonBedrockService.java | 2 +- .../AmazonBedrockChatCompletionTaskSettings.java | 5 +++++ .../services/anthropic/AnthropicService.java | 2 +- .../AnthropicChatCompletionTaskSettings.java | 5 +++++ .../AzureAiStudioChatCompletionTaskSettings.java | 5 +++++ .../AzureAiStudioEmbeddingsTaskSettings.java | 5 +++++ .../services/azureopenai/AzureOpenAiService.java | 2 +- .../AzureOpenAiCompletionTaskSettings.java | 5 +++++ .../AzureOpenAiEmbeddingsTaskSettings.java | 5 +++++ .../inference/services/cohere/CohereService.java | 4 ++-- .../embeddings/CohereEmbeddingsTaskSettings.java | 5 +++++ .../cohere/rerank/CohereRerankTaskSettings.java | 5 +++++ .../services/elastic/ElasticInferenceService.java | 2 +- .../elasticsearch/CustomElandRerankTaskSettings.java | 5 +++++ .../elasticsearch/ElasticsearchInternalService.java | 6 +++--- .../elasticsearch/ElserMlNodeTaskSettings.java | 5 +++++ .../googleaistudio/GoogleAiStudioService.java | 4 ++-- .../googlevertexai/GoogleVertexAiService.java | 4 ++-- .../GoogleVertexAiEmbeddingsTaskSettings.java | 5 +++++ .../rerank/GoogleVertexAiRerankTaskSettings.java | 5 +++++ .../services/ibmwatsonx/IbmWatsonxService.java | 4 ++-- .../inference/services/openai/OpenAiService.java | 2 +- .../completion/OpenAiChatCompletionTaskSettings.java | 5 +++++ .../embeddings/OpenAiEmbeddingsTaskSettings.java | 5 +++++ .../xpack/inference/model/TestModel.java | 5 +++++ ...libabaCloudSearchCompletionTaskSettingsTests.java | 7 +++++++ ...libabaCloudSearchEmbeddingsTaskSettingsTests.java | 7 +++++++ .../AlibabaCloudSearchSparseTaskSettingsTests.java | 7 +++++++ ...AmazonBedrockChatCompletionTaskSettingsTests.java | 6 ++++++ .../AnthropicChatCompletionTaskSettingsTests.java | 7 +++++++ ...AzureAiStudioChatCompletionTaskSettingsTests.java | 6 ++++++ ...reAiStudioEmbeddingsRequestTaskSettingsTests.java | 1 + .../AzureAiStudioEmbeddingsTaskSettingsTests.java | 5 +++++ .../AzureOpenAiCompletionTaskSettingsTests.java | 6 ++++++ .../AzureOpenAiEmbeddingsTaskSettingsTests.java | 6 ++++++ .../CohereEmbeddingsTaskSettingsTests.java | 6 ++++++ .../CustomElandRerankTaskSettingsTests.java | 6 ++++++ .../GoogleVertexAiEmbeddingsTaskSettingsTests.java | 5 +++++ .../GoogleVertexAiRerankTaskSettingsTests.java | 6 ++++++ .../OpenAiChatCompletionTaskSettingsTests.java | 6 ++++++ .../OpenAiEmbeddingsRequestTaskSettingsTests.java | 5 +++++ .../OpenAiEmbeddingsTaskSettingsTests.java | 6 ++++++ 57 files changed, 263 insertions(+), 30 deletions(-) create mode 100644 docs/changelog/114389.yaml diff --git a/docs/changelog/114389.yaml b/docs/changelog/114389.yaml new file mode 100644 index 000000000000..f56b165bc917 --- /dev/null +++ b/docs/changelog/114389.yaml @@ -0,0 +1,5 @@ +pr: 114389 +summary: Filter empty task settings objects from the API response +area: Machine Learning +type: enhancement +issues: [] diff --git a/server/src/main/java/org/elasticsearch/inference/EmptyTaskSettings.java b/server/src/main/java/org/elasticsearch/inference/EmptyTaskSettings.java index 3d0f35e982a1..0c863932c6af 100644 --- a/server/src/main/java/org/elasticsearch/inference/EmptyTaskSettings.java +++ b/server/src/main/java/org/elasticsearch/inference/EmptyTaskSettings.java @@ -29,6 +29,11 @@ public record EmptyTaskSettings() implements TaskSettings { this(); } + @Override + public boolean isEmpty() { + return true; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java index 9f7a247d00a3..ebf32f041155 100644 --- a/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java +++ b/server/src/main/java/org/elasticsearch/inference/ModelConfigurations.java @@ -173,7 +173,11 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN builder.field(TaskType.NAME, taskType.toString()); builder.field(SERVICE, service); builder.field(SERVICE_SETTINGS, serviceSettings); - builder.field(TASK_SETTINGS, taskSettings); + // Always write task settings to the index even if empty. + // But do not show empty settings in the response + if (params.paramAsBoolean(USE_ID_FOR_INDEX, false) || (taskSettings != null && taskSettings.isEmpty() == false)) { + builder.field(TASK_SETTINGS, taskSettings); + } if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } @@ -192,7 +196,11 @@ public class ModelConfigurations implements ToFilteredXContentObject, VersionedN builder.field(TaskType.NAME, taskType.toString()); builder.field(SERVICE, service); builder.field(SERVICE_SETTINGS, serviceSettings.getFilteredXContentObject()); - builder.field(TASK_SETTINGS, taskSettings); + // Always write task settings to the index even if empty. + // But do not show empty settings in the response + if (params.paramAsBoolean(USE_ID_FOR_INDEX, false) || (taskSettings != null && taskSettings.isEmpty() == false)) { + builder.field(TASK_SETTINGS, taskSettings); + } if (chunkingSettings != null) { builder.field(CHUNKING_SETTINGS, chunkingSettings); } diff --git a/server/src/main/java/org/elasticsearch/inference/TaskSettings.java b/server/src/main/java/org/elasticsearch/inference/TaskSettings.java index 15118566f59a..9862abce2332 100644 --- a/server/src/main/java/org/elasticsearch/inference/TaskSettings.java +++ b/server/src/main/java/org/elasticsearch/inference/TaskSettings.java @@ -12,4 +12,6 @@ package org.elasticsearch.inference; import org.elasticsearch.common.io.stream.VersionedNamedWriteable; import org.elasticsearch.xcontent.ToXContentObject; -public interface TaskSettings extends ToXContentObject, VersionedNamedWriteable {} +public interface TaskSettings extends ToXContentObject, VersionedNamedWriteable { + boolean isEmpty(); +} diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java index ca1dd5a71ea2..d8d5eb49c3c0 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java @@ -19,11 +19,14 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import static org.hamcrest.Matchers.anEmptyMap; +import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; public class OpenAIServiceMixedIT extends BaseMixedTestCase { @@ -118,14 +121,13 @@ public class OpenAIServiceMixedIT extends BaseMixedTestCase { put(inferenceId, chatCompletionsConfig(getUrl(openAiChatCompletionsServer)), TaskType.COMPLETION); var configsMap = get(TaskType.COMPLETION, inferenceId); - logger.warn("Configs: {}", configsMap); var configs = (List>) configsMap.get("endpoints"); assertThat(configs, hasSize(1)); assertEquals("openai", configs.get(0).get("service")); var serviceSettings = (Map) configs.get(0).get("service_settings"); assertThat(serviceSettings, hasEntry("model_id", "gpt-4")); var taskSettings = (Map) configs.get(0).get("task_settings"); - assertThat(taskSettings.keySet(), empty()); + assertThat(taskSettings, anyOf(nullValue(), anEmptyMap())); assertCompletionInference(inferenceId); } diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/CohereServiceUpgradeIT.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/CohereServiceUpgradeIT.java index c7d95f1f512b..32969ffd1d11 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/CohereServiceUpgradeIT.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/CohereServiceUpgradeIT.java @@ -22,10 +22,13 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import static org.hamcrest.Matchers.anEmptyMap; +import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.oneOf; public class CohereServiceUpgradeIT extends InferenceUpgradeTestCase { @@ -122,7 +125,7 @@ public class CohereServiceUpgradeIT extends InferenceUpgradeTestCase { assertThat(serviceSettings, hasEntry("model_id", "embed-english-light-v3.0")); assertThat(serviceSettings, hasEntry("embedding_type", "byte")); var taskSettings = (Map) configs.get(0).get("task_settings"); - assertThat(taskSettings.keySet(), empty()); + assertThat(taskSettings, anyOf(nullValue(), anEmptyMap())); // Inference on old cluster models assertEmbeddingInference(oldClusterIdInt8, CohereEmbeddingType.BYTE); diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/HuggingFaceServiceUpgradeIT.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/HuggingFaceServiceUpgradeIT.java index 9c9a377bbb00..25f57d990f58 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/HuggingFaceServiceUpgradeIT.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/HuggingFaceServiceUpgradeIT.java @@ -20,9 +20,12 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import static org.hamcrest.Matchers.anEmptyMap; +import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; public class HuggingFaceServiceUpgradeIT extends InferenceUpgradeTestCase { @@ -132,7 +135,7 @@ public class HuggingFaceServiceUpgradeIT extends InferenceUpgradeTestCase { var configs = (List>) get(testTaskType, oldClusterId).get("endpoints"); assertEquals("hugging_face", configs.get(0).get("service")); var taskSettings = (Map) configs.get(0).get("task_settings"); - assertThat(taskSettings.keySet(), empty()); + assertThat(taskSettings, anyOf(nullValue(), anEmptyMap())); assertElser(oldClusterId); diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java index a5c891025146..7b43a5b86e61 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/OpenAiServiceUpgradeIT.java @@ -19,10 +19,13 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import static org.hamcrest.Matchers.anEmptyMap; +import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasEntry; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; public class OpenAiServiceUpgradeIT extends InferenceUpgradeTestCase { @@ -91,7 +94,7 @@ public class OpenAiServiceUpgradeIT extends InferenceUpgradeTestCase { // model id is moved to service settings assertThat(serviceSettings, hasEntry("model_id", "text-embedding-ada-002")); var taskSettings = (Map) configs.get(0).get("task_settings"); - assertThat(taskSettings.keySet(), empty()); + assertThat(taskSettings, anyOf(nullValue(), anEmptyMap())); // Inference on old cluster model assertEmbeddingInference(oldClusterId); @@ -145,7 +148,7 @@ public class OpenAiServiceUpgradeIT extends InferenceUpgradeTestCase { var serviceSettings = (Map) configs.get(0).get("service_settings"); assertThat(serviceSettings, hasEntry("model_id", "gpt-4")); var taskSettings = (Map) configs.get(0).get("task_settings"); - assertThat(taskSettings.keySet(), empty()); + assertThat(taskSettings, anyOf(nullValue(), anEmptyMap())); assertCompletionInference(oldClusterId); } else if (isUpgradedCluster()) { @@ -154,7 +157,7 @@ public class OpenAiServiceUpgradeIT extends InferenceUpgradeTestCase { var serviceSettings = (Map) configs.get(0).get("service_settings"); assertThat(serviceSettings, hasEntry("model_id", "gpt-4")); var taskSettings = (Map) configs.get(0).get("task_settings"); - assertThat(taskSettings.keySet(), empty()); + assertThat(taskSettings, anyOf(nullValue(), anEmptyMap())); assertCompletionInference(oldClusterId); diff --git a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java index 1bde3704864d..02dfff1b5c2e 100644 --- a/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java +++ b/x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/AbstractTestInferenceService.java @@ -23,6 +23,7 @@ import org.elasticsearch.inference.TaskType; import org.elasticsearch.xcontent.XContentBuilder; import java.io.IOException; +import java.util.HashMap; import java.util.Map; public abstract class AbstractTestInferenceService implements InferenceService { @@ -47,7 +48,7 @@ public abstract class AbstractTestInferenceService implements InferenceService { if (settings.containsKey(ModelConfigurations.TASK_SETTINGS)) { taskSettingsMap = (Map) settings.remove(ModelConfigurations.TASK_SETTINGS); } else { - taskSettingsMap = Map.of(); + taskSettingsMap = new HashMap<>(); } return taskSettingsMap; @@ -133,6 +134,11 @@ public abstract class AbstractTestInferenceService implements InferenceService { this(in.readOptionalVInt()); } + @Override + public boolean isEmpty() { + return temperature == null; + } + @Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalVInt(temperature); diff --git a/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java b/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java index 8e68ca9dfa56..537ed6a6e5fe 100644 --- a/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java +++ b/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/ModelRegistryIT.java @@ -592,6 +592,11 @@ public class ModelRegistryIT extends ESSingleNodeTestCase { public void writeTo(StreamOutput out) throws IOException { } + + @Override + public boolean isEmpty() { + return true; + } } record TestSecretSettings(String key) implements SecretSettings { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java index 674509b28388..5b8543403304 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchService.java @@ -187,7 +187,7 @@ public class AlibabaCloudSearchService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -209,7 +209,7 @@ public class AlibabaCloudSearchService extends SenderService { @Override public AlibabaCloudSearchModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && List.of(TaskType.TEXT_EMBEDDING, TaskType.SPARSE_EMBEDDING).contains(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettings.java index 6fb726e60835..63f82a8eceb9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettings.java @@ -93,10 +93,15 @@ public class AlibabaCloudSearchCompletionTaskSettings implements TaskSettings { this.parameters = parameters; } + @Override + public boolean isEmpty() { + return parameters == null || parameters.isEmpty(); + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - if (parameters != null) { + if (parameters != null && parameters.isEmpty() == false) { builder.field(PARAMETERS, parameters); } builder.endObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java index abfd49940b67..c908c219e405 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettings.java @@ -89,6 +89,10 @@ public class AlibabaCloudSearchEmbeddingsTaskSettings implements TaskSettings { return new AlibabaCloudSearchEmbeddingsTaskSettings(inputTypeToUse); } + public boolean isEmpty() { + return inputType == null; + } + private static InputType getValidInputType( AlibabaCloudSearchEmbeddingsTaskSettings originalSettings, AlibabaCloudSearchEmbeddingsTaskSettings requestTaskSettings, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankTaskSettings.java index e9fb468eab7f..97e7ecd41223 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/rerank/AlibabaCloudSearchRerankTaskSettings.java @@ -67,6 +67,10 @@ public class AlibabaCloudSearchRerankTaskSettings implements TaskSettings { public AlibabaCloudSearchRerankTaskSettings() {} + public boolean isEmpty() { + return true; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettings.java index 2b1e9ace1b24..873cdf31fbe9 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettings.java @@ -130,6 +130,11 @@ public class AlibabaCloudSearchSparseTaskSettings implements TaskSettings { assert VALID_REQUEST_VALUES.contains(inputType) : invalidInputTypeMessage(inputType); } + @Override + public boolean isEmpty() { + return inputType == null && returnToken == null; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java index c7c073660624..9b066f2a1679 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/AmazonBedrockService.java @@ -177,7 +177,7 @@ public class AmazonBedrockService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettings.java index e689e68794e1..13787ed8cb6a 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettings.java @@ -151,6 +151,11 @@ public class AmazonBedrockChatCompletionTaskSettings implements TaskSettings { out.writeOptionalVInt(maxNewTokens); } + @Override + public boolean isEmpty() { + return temperature == null && topP == null && topK == null && maxNewTokens == null; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java index 3cf4c10f7c9e..8d6f026e12ac 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/AnthropicService.java @@ -134,7 +134,7 @@ public class AnthropicService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java index a1457dda64e4..bb2c02712737 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettings.java @@ -126,6 +126,11 @@ public class AnthropicChatCompletionTaskSettings implements TaskSettings { return topK; } + @Override + public boolean isEmpty() { + return false; // maxTokens is non-optional + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettings.java index 49684d674975..b8e33bac410f 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettings.java @@ -144,6 +144,11 @@ public class AzureAiStudioChatCompletionTaskSettings implements TaskSettings { return TransportVersions.V_8_14_0; } + @Override + public boolean isEmpty() { + return temperature == null && topP == null && doSample == null && maxNewTokens == null; + } + @Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalDouble(temperature); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettings.java index f5d70b89cee5..bdb6ae74e5ab 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettings.java @@ -69,6 +69,11 @@ public class AzureAiStudioEmbeddingsTaskSettings implements TaskSettings { return this.user; } + @Override + public boolean isEmpty() { + return user == null || user.isEmpty(); + } + @Override public String getWriteableName() { return NAME; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java index 07708ee07209..7b13ad85e0cd 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/AzureOpenAiService.java @@ -168,7 +168,7 @@ public class AzureOpenAiService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettings.java index 6e9f77e1ade2..de0a0897a93c 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettings.java @@ -59,6 +59,11 @@ public class AzureOpenAiCompletionTaskSettings implements TaskSettings { this.user = in.readOptionalString(); } + @Override + public boolean isEmpty() { + return user == null; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettings.java index 36cf89ea2d84..28ccade0a06b 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettings.java @@ -70,6 +70,11 @@ public class AzureOpenAiEmbeddingsTaskSettings implements TaskSettings { this.user = in.readOptionalString(); } + @Override + public boolean isEmpty() { + return user == null || user.isEmpty(); + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java index 1804d3bdf593..9538588700e7 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/CohereService.java @@ -171,7 +171,7 @@ public class CohereService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrThrowIfNull(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -193,7 +193,7 @@ public class CohereService extends SenderService { @Override public CohereModel parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java index 0a42df8c0bb4..34d37d0003ad 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettings.java @@ -145,6 +145,11 @@ public class CohereEmbeddingsTaskSettings implements TaskSettings { assert VALID_REQUEST_VALUES.contains(inputType) : invalidInputTypeMessage(inputType); } + @Override + public boolean isEmpty() { + return inputType == null && truncation == null; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java index a01f6a4e65b8..f5893c825efc 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/cohere/rerank/CohereRerankTaskSettings.java @@ -113,6 +113,11 @@ public class CohereRerankTaskSettings implements TaskSettings { this.maxChunksPerDoc = maxChunksPerDoc; } + @Override + public boolean isEmpty() { + return topNDocumentsOnly == null && returnDocuments == null && maxChunksPerDoc == null; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java index 7cfbc272aac5..85c7273b4749 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceService.java @@ -176,7 +176,7 @@ public class ElasticInferenceService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettings.java index 523aff20b8e0..70d787152121 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettings.java @@ -90,6 +90,11 @@ public class CustomElandRerankTaskSettings implements TaskSettings { this.returnDocuments = doReturnDocuments; } + @Override + public boolean isEmpty() { + return returnDocuments == null; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java index 739f514bee1c..9f7be1eb96c2 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElasticsearchInternalService.java @@ -54,7 +54,7 @@ import java.util.function.Consumer; import java.util.function.Function; import static org.elasticsearch.xpack.core.inference.results.ResultUtils.createInvalidChunkedResultException; -import static org.elasticsearch.xpack.inference.services.ServiceUtils.removeFromMap; +import static org.elasticsearch.xpack.inference.services.ServiceUtils.removeFromMapOrDefaultEmpty; import static org.elasticsearch.xpack.inference.services.ServiceUtils.removeFromMapOrThrowIfNull; import static org.elasticsearch.xpack.inference.services.ServiceUtils.throwIfNotEmptyMap; import static org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels.ELSER_V2_MODEL; @@ -115,7 +115,7 @@ public class ElasticsearchInternalService extends BaseElasticsearchInternalServi try { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMap(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); String serviceName = (String) config.remove(ModelConfigurations.SERVICE); // required for elser service in elasticsearch service throwIfNotEmptyMap(config, name()); @@ -385,7 +385,7 @@ public class ElasticsearchInternalService extends BaseElasticsearchInternalServi @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMap(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); String modelId = (String) serviceSettingsMap.get(ElasticsearchInternalServiceSettings.MODEL_ID); if (modelId == null) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserMlNodeTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserMlNodeTaskSettings.java index 934edaa96a15..33696231668a 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserMlNodeTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elasticsearch/ElserMlNodeTaskSettings.java @@ -27,6 +27,11 @@ public class ElserMlNodeTaskSettings implements TaskSettings { public ElserMlNodeTaskSettings(StreamInput in) {} + @Override + public boolean isEmpty() { + return true; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java index 9a04edf13899..798ce4ea5800 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googleaistudio/GoogleAiStudioService.java @@ -145,7 +145,7 @@ public class GoogleAiStudioService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -188,7 +188,7 @@ public class GoogleAiStudioService extends SenderService { @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java index ae9219ba3849..ece23d4226fc 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/GoogleVertexAiService.java @@ -109,7 +109,7 @@ public class GoogleVertexAiService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; @@ -131,7 +131,7 @@ public class GoogleVertexAiService extends SenderService { @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); ChunkingSettings chunkingSettings = null; if (ChunkingSettingsFeatureFlag.isEnabled() && TaskType.TEXT_EMBEDDING.equals(taskType)) { diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettings.java index 6de44fe470a2..5e0185a7abb3 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettings.java @@ -61,6 +61,11 @@ public class GoogleVertexAiEmbeddingsTaskSettings implements TaskSettings { this.autoTruncate = in.readOptionalBoolean(); } + @Override + public boolean isEmpty() { + return autoTruncate == null; + } + public Boolean autoTruncate() { return autoTruncate; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettings.java index e7c20cc0b4fe..8256eed7a5cb 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettings.java @@ -58,6 +58,11 @@ public class GoogleVertexAiRerankTaskSettings implements TaskSettings { this.topN = in.readOptionalVInt(); } + @Override + public boolean isEmpty() { + return topN == null; + } + public Integer topN() { return topN; } diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java index 14be1a70b5da..ee88eb6206b5 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/ibmwatsonx/IbmWatsonxService.java @@ -122,7 +122,7 @@ public class IbmWatsonxService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); return createModelFromPersistent( @@ -157,7 +157,7 @@ public class IbmWatsonxService extends SenderService { @Override public Model parsePersistedConfig(String inferenceEntityId, TaskType taskType, Map config) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); return createModelFromPersistent( inferenceEntityId, diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java index fd5f7197475a..3161493d68d0 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java @@ -168,7 +168,7 @@ public class OpenAiService extends SenderService { Map secrets ) { Map serviceSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.SERVICE_SETTINGS); - Map taskSettingsMap = removeFromMapOrThrowIfNull(config, ModelConfigurations.TASK_SETTINGS); + Map taskSettingsMap = removeFromMapOrDefaultEmpty(config, ModelConfigurations.TASK_SETTINGS); Map secretSettingsMap = removeFromMapOrDefaultEmpty(secrets, ModelSecrets.SECRET_SETTINGS); ChunkingSettings chunkingSettings = null; diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettings.java index 922bbcda2c74..3c2586fb5a26 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettings.java @@ -50,6 +50,11 @@ public class OpenAiChatCompletionTaskSettings implements TaskSettings { this.user = in.readOptionalString(); } + @Override + public boolean isEmpty() { + return user == null; + } + public static OpenAiChatCompletionTaskSettings of( OpenAiChatCompletionTaskSettings originalSettings, OpenAiChatCompletionRequestTaskSettings requestSettings diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java index b4cf9b27d0ff..c7cc60043ef4 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettings.java @@ -67,6 +67,11 @@ public class OpenAiEmbeddingsTaskSettings implements TaskSettings { this.user = user; } + @Override + public boolean isEmpty() { + return user == null; + } + public OpenAiEmbeddingsTaskSettings(StreamInput in) throws IOException { if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_13_0)) { this.user = in.readOptionalString(); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java index 49f3f9d48f18..d8c25fb5a6d8 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/model/TestModel.java @@ -193,6 +193,11 @@ public class TestModel extends Model { out.writeOptionalVInt(temperature); } + @Override + public boolean isEmpty() { + return temperature == null; + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettingsTests.java index 63fdb38b33df..c48d57cf3e03 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionTaskSettingsTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.completion; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.core.Nullable; import org.elasticsearch.test.AbstractWireSerializingTestCase; @@ -33,6 +34,12 @@ public class AlibabaCloudSearchCompletionTaskSettingsTests extends AbstractWireS ); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + @Override protected Writeable.Reader instanceReader() { return AlibabaCloudSearchCompletionTaskSettings::new; diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettingsTests.java index 244685d8e983..9e75a2f47505 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsTaskSettingsTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.embeddings; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.InputType; @@ -45,6 +46,12 @@ public class AlibabaCloudSearchEmbeddingsTaskSettingsTests extends AbstractWireS ); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + @Override protected Writeable.Reader instanceReader() { return AlibabaCloudSearchEmbeddingsTaskSettings::new; diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettingsTests.java index b16d96f9a081..2c134c676507 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/alibabacloudsearch/sparse/AlibabaCloudSearchSparseTaskSettingsTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.inference.services.alibabacloudsearch.sparse; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.core.Nullable; import org.elasticsearch.inference.InputType; @@ -35,6 +36,12 @@ public class AlibabaCloudSearchSparseTaskSettingsTests extends AbstractWireSeria ); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_WhenInputTypeIsNull() { InputType inputType = null; MatcherAssert.assertThat( diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettingsTests.java index 0d5440c6d2cf..69dd3b1e6257 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/amazonbedrock/completion/AmazonBedrockChatCompletionTaskSettingsTests.java @@ -32,6 +32,12 @@ import static org.hamcrest.Matchers.is; public class AmazonBedrockChatCompletionTaskSettingsTests extends AbstractBWCWireSerializationTestCase< AmazonBedrockChatCompletionTaskSettings> { + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_AllValues() { var taskMap = getChatCompletionTaskSettingsMap(1.0, 0.5, 0.6, 512); assertEquals( diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettingsTests.java index 78762af6eee8..e00de80e8709 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/anthropic/completion/AnthropicChatCompletionTaskSettingsTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.xpack.inference.services.anthropic.completion; import org.elasticsearch.TransportVersion; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.core.Nullable; @@ -54,6 +55,12 @@ public class AnthropicChatCompletionTaskSettingsTests extends AbstractBWCWireSer return new AnthropicChatCompletionTaskSettings(randomNonNegativeInt(), randomDouble(), randomDouble(), randomInt()); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_WithMaxTokens() { assertEquals( new AnthropicChatCompletionTaskSettings(1, null, null, null), diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettingsTests.java index d48068d5a400..8d7dcf1ef517 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/completion/AzureAiStudioChatCompletionTaskSettingsTests.java @@ -32,6 +32,12 @@ import static org.hamcrest.Matchers.is; public class AzureAiStudioChatCompletionTaskSettingsTests extends AbstractBWCWireSerializationTestCase< AzureAiStudioChatCompletionTaskSettings> { + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_AllValues() { var taskMap = getTaskSettingsMap(1.0, 2.0, true, 512); assertEquals( diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsRequestTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsRequestTaskSettingsTests.java index 665d350bf249..4359550faf14 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsRequestTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsRequestTaskSettingsTests.java @@ -18,6 +18,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; public class AzureAiStudioEmbeddingsRequestTaskSettingsTests extends ESTestCase { + public void testFromMap_ReturnsEmptySettings_WhenTheMapIsEmpty() { var settings = AzureAiStudioEmbeddingsRequestTaskSettings.fromMap(new HashMap<>(Map.of())); assertThat(settings, is(AzureAiStudioEmbeddingsRequestTaskSettings.EMPTY_SETTINGS)); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettingsTests.java index 5b8c95edcc0a..4b6b38bd15c0 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureaistudio/embeddings/AzureAiStudioEmbeddingsTaskSettingsTests.java @@ -26,6 +26,11 @@ import java.util.Map; import static org.hamcrest.Matchers.is; public class AzureAiStudioEmbeddingsTaskSettingsTests extends AbstractBWCWireSerializationTestCase { + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } public void testFromMap_WithUser() { assertEquals( diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettingsTests.java index 15e1d8d7809c..8e8d9c4f9280 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/completion/AzureOpenAiCompletionTaskSettingsTests.java @@ -32,6 +32,12 @@ public class AzureOpenAiCompletionTaskSettingsTests extends AbstractWireSerializ return new AzureOpenAiCompletionTaskSettings(user); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_WithUser() { var user = "user"; diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettingsTests.java index 324bdd15d925..72a063af37b9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/azureopenai/embeddings/AzureOpenAiEmbeddingsTaskSettingsTests.java @@ -27,6 +27,12 @@ public class AzureOpenAiEmbeddingsTaskSettingsTests extends AbstractWireSerializ return new AzureOpenAiEmbeddingsTaskSettings(randomAlphaOfLength(15)); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + /** * The created settings can have the user set to null. */ diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettingsTests.java index c18310eb9a84..90c9b032465c 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/embeddings/CohereEmbeddingsTaskSettingsTests.java @@ -37,6 +37,12 @@ public class CohereEmbeddingsTaskSettingsTests extends AbstractWireSerializingTe return new CohereEmbeddingsTaskSettings(inputType, truncation); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_CreatesEmptySettings_WhenAllFieldsAreNull() { MatcherAssert.assertThat( CohereEmbeddingsTaskSettings.fromMap(new HashMap<>(Map.of())), diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettingsTests.java index 05515bf9e386..72e6daa911c1 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/elasticsearch/CustomElandRerankTaskSettingsTests.java @@ -22,6 +22,12 @@ import static org.hamcrest.Matchers.sameInstance; public class CustomElandRerankTaskSettingsTests extends AbstractWireSerializingTestCase { + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testDefaultsFromMap_MapIsNull_ReturnsDefaultSettings() { var customElandRerankTaskSettings = CustomElandRerankTaskSettings.defaultsFromMap(null); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettingsTests.java index 364d8090786d..ac7e9348b370 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/embeddings/GoogleVertexAiEmbeddingsTaskSettingsTests.java @@ -25,6 +25,11 @@ import static org.elasticsearch.xpack.inference.services.googlevertexai.embeddin import static org.hamcrest.Matchers.is; public class GoogleVertexAiEmbeddingsTaskSettingsTests extends AbstractBWCWireSerializationTestCase { + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } public void testFromMap_AutoTruncateIsSet() { var autoTruncate = true; diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettingsTests.java index 5bfcbb9a3f63..03f89b6a2c04 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/googlevertexai/rerank/GoogleVertexAiRerankTaskSettingsTests.java @@ -27,6 +27,12 @@ import static org.hamcrest.Matchers.is; public class GoogleVertexAiRerankTaskSettingsTests extends AbstractBWCWireSerializationTestCase { + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_TopNIsSet() { var topN = 1; var taskSettingsMap = getTaskSettingsMap(topN); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettingsTests.java index f2bd26a4e643..16d7e8f1db9b 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/completion/OpenAiChatCompletionTaskSettingsTests.java @@ -25,6 +25,12 @@ public class OpenAiChatCompletionTaskSettingsTests extends AbstractWireSerializi return new OpenAiChatCompletionTaskSettings(randomAlphaOfLength(15)); } + public void testIsEmpty() { + var randomSettings = new OpenAiChatCompletionTaskSettings(randomBoolean() ? null : "username"); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_WithUser() { assertEquals( new OpenAiChatCompletionTaskSettings("user"), diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettingsTests.java index 6892e92d936e..610bfffbcfe2 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsRequestTaskSettingsTests.java @@ -17,6 +17,11 @@ import java.util.Map; import static org.hamcrest.Matchers.is; public class OpenAiEmbeddingsRequestTaskSettingsTests extends ESTestCase { + + public OpenAiEmbeddingsRequestTaskSettings createRandom() { + return new OpenAiEmbeddingsRequestTaskSettings(randomBoolean() ? null : "username"); + } + public void testFromMap_ReturnsEmptySettings_WhenTheMapIsEmpty() { var settings = OpenAiEmbeddingsRequestTaskSettings.fromMap(new HashMap<>(Map.of())); assertNull(settings.user()); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettingsTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettingsTests.java index 464f5a1885d9..a5ae2f0a3a44 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettingsTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/openai/embeddings/OpenAiEmbeddingsTaskSettingsTests.java @@ -36,6 +36,12 @@ public class OpenAiEmbeddingsTaskSettingsTests extends AbstractWireSerializingTe return new OpenAiEmbeddingsTaskSettings(user); } + public void testIsEmpty() { + var randomSettings = createRandom(); + var stringRep = Strings.toString(randomSettings); + assertEquals(stringRep, randomSettings.isEmpty(), stringRep.equals("{}")); + } + public void testFromMap_WithUser() { assertEquals( new OpenAiEmbeddingsTaskSettings("user"), From 41f95ed954a017fe396fd1e94fa791d95d7e2fcd Mon Sep 17 00:00:00 2001 From: Nick Tindall Date: Thu, 10 Oct 2024 14:35:05 +1100 Subject: [PATCH 23/43] Azure: Explain why we don't use batch delete (#114379) --- .../repositories/azure/AzureBlobStore.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java index d520d30f2bac..829868797e38 100644 --- a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java +++ b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java @@ -278,6 +278,19 @@ public class AzureBlobStore implements BlobStore { throw exception; } + /** + * {@inheritDoc} + *

    + * Note that in this Azure implementation we issue a series of individual + * delete blob calls rather than aggregating + * deletions into blob batch calls. + * The reason for this is that the blob batch endpoint has limited support for SAS token authentication. + * + * @see + * API docs around SAS auth limitations + * @see Java SDK issue + * @see Discussion on implementing PR + */ @Override public void deleteBlobsIgnoringIfNotExists(OperationPurpose purpose, Iterator blobs) { if (blobs.hasNext() == false) { From c31935eb732440f676cf898eef9ab942a0e40686 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:26:05 +1100 Subject: [PATCH 24/43] Mute org.elasticsearch.search.retriever.StandardRetrieverBuilderParsingTests testRewrite #114466 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 72fa78b5ec6e..b4c57d06d296 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -366,6 +366,9 @@ tests: - class: org.elasticsearch.xpack.inference.InferenceRestIT method: test {p0=inference/40_semantic_text_query/Query a field that uses the default ELSER 2 endpoint} issue: https://github.com/elastic/elasticsearch/issues/114376 +- class: org.elasticsearch.search.retriever.StandardRetrieverBuilderParsingTests + method: testRewrite + issue: https://github.com/elastic/elasticsearch/issues/114466 # Examples: # From 5f7248b6202b5239a1013f95482192379f93fa80 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:29:51 +1100 Subject: [PATCH 25/43] Mute org.elasticsearch.search.retriever.RankDocsRetrieverBuilderTests testRewrite #114467 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index b4c57d06d296..68f1eea5c577 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -369,6 +369,9 @@ tests: - class: org.elasticsearch.search.retriever.StandardRetrieverBuilderParsingTests method: testRewrite issue: https://github.com/elastic/elasticsearch/issues/114466 +- class: org.elasticsearch.search.retriever.RankDocsRetrieverBuilderTests + method: testRewrite + issue: https://github.com/elastic/elasticsearch/issues/114467 # Examples: # From e129822f11befad0558773d8626e5286715dbff8 Mon Sep 17 00:00:00 2001 From: Ignacio Vera Date: Thu, 10 Oct 2024 07:27:18 +0200 Subject: [PATCH 26/43] Improve performance of Int3Hash#removeAndAdd (#114383) --- .../elasticsearch/common/util/Int3Hash.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/util/Int3Hash.java b/server/src/main/java/org/elasticsearch/common/util/Int3Hash.java index dc49b39a031a..c32da943ea02 100644 --- a/server/src/main/java/org/elasticsearch/common/util/Int3Hash.java +++ b/server/src/main/java/org/elasticsearch/common/util/Int3Hash.java @@ -58,8 +58,8 @@ public final class Int3Hash extends AbstractHash { * Get the id associated with key or -1 if the key is not contained in the hash. */ public long find(int key1, int key2, int key3) { - long index = slot(hash(key1, key2, key3), mask); - while (true) { + final long slot = slot(hash(key1, key2, key3), mask); + for (long index = slot;; index = nextSlot(index, mask)) { final long id = id(index); if (id == -1) { return id; @@ -69,14 +69,13 @@ public final class Int3Hash extends AbstractHash { return id; } } - index = nextSlot(index, mask); } } private long set(int key1, int key2, int key3, long id) { assert size < maxSize; - long index = slot(hash(key1, key2, key3), mask); - while (true) { + long slot = slot(hash(key1, key2, key3), mask); + for (long index = slot;; index = nextSlot(index, mask)) { final long curId = id(index); if (curId == -1) { // means unset setId(index, id); @@ -84,33 +83,35 @@ public final class Int3Hash extends AbstractHash { ++size; return id; } else { - long keyOffset = 3 * curId; + final long keyOffset = 3 * curId; if (keys.get(keyOffset) == key1 && keys.get(keyOffset + 1) == key2 && keys.get(keyOffset + 2) == key3) { return -1 - curId; } } - index = nextSlot(index, mask); } } private void append(long id, int key1, int key2, int key3) { - long keyOffset = 3 * id; + final long keyOffset = 3 * id; keys = bigArrays.grow(keys, keyOffset + 3); keys.set(keyOffset, key1); keys.set(keyOffset + 1, key2); keys.set(keyOffset + 2, key3); } - private void reset(int key1, int key2, int key3, long id) { - long index = slot(hash(key1, key2, key3), mask); - while (true) { + private void reset(long id) { + final IntArray keys = this.keys; + final long keyOffset = id * 3; + final int key1 = keys.get(keyOffset); + final int key2 = keys.get(keyOffset + 1); + final int key3 = keys.get(keyOffset + 2); + final long slot = slot(hash(key1, key2, key3), mask); + for (long index = slot;; index = nextSlot(index, mask)) { final long curId = id(index); if (curId == -1) { // means unset setId(index, id); - append(id, key1, key2, key3); break; } - index = nextSlot(index, mask); } } @@ -132,11 +133,7 @@ public final class Int3Hash extends AbstractHash { protected void removeAndAdd(long index) { final long id = getAndSetId(index, -1); assert id >= 0; - long keyOffset = id * 3; - final int key1 = keys.getAndSet(keyOffset, 0); - final int key2 = keys.getAndSet(keyOffset + 1, 0); - final int key3 = keys.getAndSet(keyOffset + 2, 0); - reset(key1, key2, key3, id); + reset(id); } @Override From fd40f8b1cbfb5472ee9c9dd7a708b892fdc01baf Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:51:05 +1100 Subject: [PATCH 27/43] Mute org.elasticsearch.xpack.logsdb.LogsdbTestSuiteIT org.elasticsearch.xpack.logsdb.LogsdbTestSuiteIT #114471 --- muted-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 68f1eea5c577..18e179c0c063 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -372,6 +372,8 @@ tests: - class: org.elasticsearch.search.retriever.RankDocsRetrieverBuilderTests method: testRewrite issue: https://github.com/elastic/elasticsearch/issues/114467 +- class: org.elasticsearch.xpack.logsdb.LogsdbTestSuiteIT + issue: https://github.com/elastic/elasticsearch/issues/114471 # Examples: # From 4eab631e5f77597e39838481c1f0cf696ae8fbdb Mon Sep 17 00:00:00 2001 From: Panagiotis Bailis Date: Thu, 10 Oct 2024 09:57:42 +0300 Subject: [PATCH 28/43] Add telemetry for retrievers (#114109) --- docs/changelog/114109.yaml | 5 + docs/reference/cluster/stats.asciidoc | 4 + .../retriever/RetrieverTelemetryIT.java | 151 ++++++++++++++ .../org/elasticsearch/TransportVersions.java | 1 + .../admin/cluster/stats/SearchUsageStats.java | 28 ++- .../admin/cluster/RestClusterStatsAction.java | 3 +- .../search/builder/SearchSourceBuilder.java | 1 + .../search/retriever/RetrieverBuilder.java | 12 +- .../retriever/RetrieverParserContext.java | 4 + .../retriever/StandardRetrieverBuilder.java | 46 ++--- .../org/elasticsearch/usage/SearchUsage.java | 15 ++ .../usage/SearchUsageHolder.java | 7 + .../cluster/stats/SearchUsageStatsTests.java | 51 ++++- .../TextSimilarityRankRetrieverBuilder.java | 6 +- ...xtSimilarityRankRetrieverBuilderTests.java | 5 +- ...SimilarityRankRetrieverTelemetryTests.java | 187 +++++++++++++++++ .../ClusterStatsMonitoringDocTests.java | 3 +- .../rank/rrf/RRFRetrieverTelemetryIT.java | 194 ++++++++++++++++++ .../xpack/rank/rrf/RRFRetrieverBuilder.java | 1 + 19 files changed, 677 insertions(+), 47 deletions(-) create mode 100644 docs/changelog/114109.yaml create mode 100644 server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java create mode 100644 x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java create mode 100644 x-pack/plugin/rank-rrf/src/internalClusterTest/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverTelemetryIT.java diff --git a/docs/changelog/114109.yaml b/docs/changelog/114109.yaml new file mode 100644 index 000000000000..ce51ed50f724 --- /dev/null +++ b/docs/changelog/114109.yaml @@ -0,0 +1,5 @@ +pr: 114109 +summary: Update cluster stats for retrievers +area: Search +type: enhancement +issues: [] diff --git a/docs/reference/cluster/stats.asciidoc b/docs/reference/cluster/stats.asciidoc index 5dd84abc96e1..bd818a538f78 100644 --- a/docs/reference/cluster/stats.asciidoc +++ b/docs/reference/cluster/stats.asciidoc @@ -762,6 +762,10 @@ Queries are counted once per search request, meaning that if the same query type (object) Search sections used in selected nodes. For each section, name and number of times it's been used is reported. +`retrievers`:: +(object) Retriever types that were used in selected nodes. +For each retriever, name and number of times it's been used is reported. + ===== `dense_vector`:: diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java new file mode 100644 index 000000000000..537ace30e88f --- /dev/null +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/retriever/RetrieverTelemetryIT.java @@ -0,0 +1,151 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.search.retriever; + +import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesRequest; +import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesResponse; +import org.elasticsearch.action.admin.cluster.stats.SearchUsageStats; +import org.elasticsearch.client.Request; +import org.elasticsearch.common.Strings; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.vectors.KnnSearchBuilder; +import org.elasticsearch.search.vectors.KnnVectorQueryBuilder; +import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentFactory; +import org.junit.Before; + +import java.io.IOException; +import java.util.List; + +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.hamcrest.Matchers.equalTo; + +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) +public class RetrieverTelemetryIT extends ESIntegTestCase { + + private static final String INDEX_NAME = "test_index"; + + @Override + protected boolean addMockHttpTransport() { + return false; // enable http + } + + @Before + public void setup() throws IOException { + XContentBuilder builder = XContentFactory.jsonBuilder() + .startObject() + .startObject("properties") + .startObject("vector") + .field("type", "dense_vector") + .field("dims", 1) + .field("index", true) + .field("similarity", "l2_norm") + .startObject("index_options") + .field("type", "hnsw") + .endObject() + .endObject() + .startObject("text") + .field("type", "text") + .endObject() + .startObject("integer") + .field("type", "integer") + .endObject() + .startObject("topic") + .field("type", "keyword") + .endObject() + .endObject() + .endObject(); + + assertAcked(prepareCreate(INDEX_NAME).setMapping(builder)); + ensureGreen(INDEX_NAME); + } + + private void performSearch(SearchSourceBuilder source) throws IOException { + Request request = new Request("GET", INDEX_NAME + "/_search"); + request.setJsonEntity(Strings.toString(source)); + getRestClient().performRequest(request); + } + + public void testTelemetryForRetrievers() throws IOException { + + if (false == isRetrieverTelemetryEnabled()) { + return; + } + + // search#1 - this will record 1 entry for "retriever" in `sections`, and 1 for "knn" under `retrievers` + { + performSearch(new SearchSourceBuilder().retriever(new KnnRetrieverBuilder("vector", new float[] { 1.0f }, null, 10, 15, null))); + } + + // search#2 - this will record 1 entry for "retriever" in `sections`, 1 for "standard" under `retrievers`, and 1 for "range" under + // `queries` + { + performSearch(new SearchSourceBuilder().retriever(new StandardRetrieverBuilder(QueryBuilders.rangeQuery("integer").gte(2)))); + } + + // search#3 - this will record 1 entry for "retriever" in `sections`, and 1 for "standard" under `retrievers`, and 1 for "knn" under + // `queries` + { + performSearch( + new SearchSourceBuilder().retriever( + new StandardRetrieverBuilder(new KnnVectorQueryBuilder("vector", new float[] { 1.0f }, 10, 15, null)) + ) + ); + } + + // search#4 - this will record 1 entry for "retriever" in `sections`, and 1 for "standard" under `retrievers`, and 1 for "term" + // under `queries` + { + performSearch(new SearchSourceBuilder().retriever(new StandardRetrieverBuilder(QueryBuilders.termQuery("topic", "foo")))); + } + + // search#5 - t + // his will record 1 entry for "knn" in `sections` + { + performSearch(new SearchSourceBuilder().knnSearch(List.of(new KnnSearchBuilder("vector", new float[] { 1.0f }, 10, 15, null)))); + } + + // search#6 - this will record 1 entry for "query" in `sections`, and 1 for "match_all" under `queries` + { + performSearch(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery())); + } + + // cluster stats + { + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + assertEquals(6, stats.getTotalSearchCount()); + + assertThat(stats.getSectionsUsage().size(), equalTo(3)); + assertThat(stats.getSectionsUsage().get("retriever"), equalTo(4L)); + assertThat(stats.getSectionsUsage().get("query"), equalTo(1L)); + assertThat(stats.getSectionsUsage().get("knn"), equalTo(1L)); + + assertThat(stats.getRetrieversUsage().size(), equalTo(2)); + assertThat(stats.getRetrieversUsage().get("standard"), equalTo(3L)); + assertThat(stats.getRetrieversUsage().get("knn"), equalTo(1L)); + + assertThat(stats.getQueryUsage().size(), equalTo(4)); + assertThat(stats.getQueryUsage().get("range"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("term"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("match_all"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("knn"), equalTo(1L)); + } + } + + private boolean isRetrieverTelemetryEnabled() throws IOException { + NodesCapabilitiesResponse res = clusterAdmin().nodesCapabilities( + new NodesCapabilitiesRequest().method(RestRequest.Method.GET).path("_cluster/stats").capabilities("retrievers-usage-stats") + ).actionGet(); + return res != null && res.isSupported().orElse(false); + } +} diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index 78fddad603ca..d136aac8a2e5 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -238,6 +238,7 @@ public class TransportVersions { public static final TransportVersion FAST_REFRESH_RCO = def(8_762_00_0); public static final TransportVersion TEXT_SIMILARITY_RERANKER_QUERY_REWRITE = def(8_763_00_0); public static final TransportVersion SIMULATE_INDEX_TEMPLATES_SUBSTITUTIONS = def(8_764_00_0); + public static final TransportVersion RETRIEVERS_TELEMETRY_ADDED = def(8_765_00_0); /* * STOP! READ THIS FIRST! No, really, diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStats.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStats.java index da78e04d2b0d..0f6c56fd21bd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStats.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStats.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; +import static org.elasticsearch.TransportVersions.RETRIEVERS_TELEMETRY_ADDED; import static org.elasticsearch.TransportVersions.V_8_12_0; /** @@ -34,6 +35,7 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { private final Map queries; private final Map rescorers; private final Map sections; + private final Map retrievers; /** * Creates a new empty stats instance, that will get additional stats added through {@link #add(SearchUsageStats)} @@ -43,17 +45,25 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { this.queries = new HashMap<>(); this.sections = new HashMap<>(); this.rescorers = new HashMap<>(); + this.retrievers = new HashMap<>(); } /** * Creates a new stats instance with the provided info. The expectation is that when a new instance is created using * this constructor, the provided stats are final and won't be modified further. */ - public SearchUsageStats(Map queries, Map rescorers, Map sections, long totalSearchCount) { + public SearchUsageStats( + Map queries, + Map rescorers, + Map sections, + Map retrievers, + long totalSearchCount + ) { this.totalSearchCount = totalSearchCount; this.queries = queries; this.sections = sections; this.rescorers = rescorers; + this.retrievers = retrievers; } public SearchUsageStats(StreamInput in) throws IOException { @@ -61,6 +71,7 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { this.sections = in.readMap(StreamInput::readLong); this.totalSearchCount = in.readVLong(); this.rescorers = in.getTransportVersion().onOrAfter(V_8_12_0) ? in.readMap(StreamInput::readLong) : Map.of(); + this.retrievers = in.getTransportVersion().onOrAfter(RETRIEVERS_TELEMETRY_ADDED) ? in.readMap(StreamInput::readLong) : Map.of(); } @Override @@ -72,6 +83,9 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { if (out.getTransportVersion().onOrAfter(V_8_12_0)) { out.writeMap(rescorers, StreamOutput::writeLong); } + if (out.getTransportVersion().onOrAfter(RETRIEVERS_TELEMETRY_ADDED)) { + out.writeMap(retrievers, StreamOutput::writeLong); + } } /** @@ -81,6 +95,7 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { stats.queries.forEach((query, count) -> queries.merge(query, count, Long::sum)); stats.rescorers.forEach((rescorer, count) -> rescorers.merge(rescorer, count, Long::sum)); stats.sections.forEach((query, count) -> sections.merge(query, count, Long::sum)); + stats.retrievers.forEach((query, count) -> retrievers.merge(query, count, Long::sum)); this.totalSearchCount += stats.totalSearchCount; } @@ -95,6 +110,8 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { builder.map(rescorers); builder.field("sections"); builder.map(sections); + builder.field("retrievers"); + builder.map(retrievers); } builder.endObject(); return builder; @@ -112,6 +129,10 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { return Collections.unmodifiableMap(sections); } + public Map getRetrieversUsage() { + return Collections.unmodifiableMap(retrievers); + } + public long getTotalSearchCount() { return totalSearchCount; } @@ -128,12 +149,13 @@ public final class SearchUsageStats implements Writeable, ToXContentFragment { return totalSearchCount == that.totalSearchCount && queries.equals(that.queries) && rescorers.equals(that.rescorers) - && sections.equals(that.sections); + && sections.equals(that.sections) + && retrievers.equals(that.retrievers); } @Override public int hashCode() { - return Objects.hash(totalSearchCount, queries, rescorers, sections); + return Objects.hash(totalSearchCount, queries, rescorers, sections, retrievers); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java index 6427e6139a7a..63bd4523f9bd 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterStatsAction.java @@ -32,7 +32,8 @@ public class RestClusterStatsAction extends BaseRestHandler { private static final Set SUPPORTED_CAPABILITIES = Set.of( "human-readable-total-docs-size", "verbose-dense-vector-mapping-stats", - "ccs-stats" + "ccs-stats", + "retrievers-usage-stats" ); private static final Set SUPPORTED_QUERY_PARAMETERS = Set.of("include_remotes", "nodeId", REST_TIMEOUT_PARAM); diff --git a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index fc0cb72bb82e..9f94ec145201 100644 --- a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -1409,6 +1409,7 @@ public final class SearchSourceBuilder implements Writeable, ToXContentObject, R parser, new RetrieverParserContext(searchUsage, clusterSupportsFeature) ); + searchUsage.trackSectionUsage(RETRIEVER.getPreferredName()); } else if (QUERY_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { if (subSearchSourceBuilders.isEmpty() == false) { throw new IllegalArgumentException( diff --git a/server/src/main/java/org/elasticsearch/search/retriever/RetrieverBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/RetrieverBuilder.java index 1c6f8c4a7ce4..882d44adb79c 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/RetrieverBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/RetrieverBuilder.java @@ -62,11 +62,11 @@ public abstract class RetrieverBuilder implements Rewriteable, String name, AbstractObjectParser parser ) { - parser.declareObjectArray((r, v) -> r.preFilterQueryBuilders = v, (p, c) -> { - QueryBuilder preFilterQueryBuilder = AbstractQueryBuilder.parseTopLevelQuery(p, c::trackQueryUsage); - c.trackSectionUsage(name + ":" + PRE_FILTER_FIELD.getPreferredName()); - return preFilterQueryBuilder; - }, PRE_FILTER_FIELD); + parser.declareObjectArray( + (r, v) -> r.preFilterQueryBuilders = v, + (p, c) -> AbstractQueryBuilder.parseTopLevelQuery(p, c::trackQueryUsage), + PRE_FILTER_FIELD + ); parser.declareString(RetrieverBuilder::retrieverName, NAME_FIELD); parser.declareFloat(RetrieverBuilder::minScore, MIN_SCORE_FIELD); } @@ -138,7 +138,7 @@ public abstract class RetrieverBuilder implements Rewriteable, throw new ParsingException(new XContentLocation(nonfe.getLineNumber(), nonfe.getColumnNumber()), message, nonfe); } - context.trackSectionUsage(retrieverName); + context.trackRetrieverUsage(retrieverName); if (parser.currentToken() != XContentParser.Token.END_OBJECT) { throw new ParsingException( diff --git a/server/src/main/java/org/elasticsearch/search/retriever/RetrieverParserContext.java b/server/src/main/java/org/elasticsearch/search/retriever/RetrieverParserContext.java index 1f9444fc284f..bdf3f8a19454 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/RetrieverParserContext.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/RetrieverParserContext.java @@ -37,6 +37,10 @@ public class RetrieverParserContext { searchUsage.trackRescorerUsage(name); } + public void trackRetrieverUsage(String name) { + searchUsage.trackRetrieverUsage(name); + } + public boolean clusterSupportsFeature(NodeFeature nodeFeature) { return clusterSupportsFeature != null && clusterSupportsFeature.test(nodeFeature); } diff --git a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java index 108aafd8c777..22439e5c996a 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java @@ -55,36 +55,28 @@ public final class StandardRetrieverBuilder extends RetrieverBuilder implements static { PARSER.declareObject((r, v) -> r.queryBuilder = v, (p, c) -> { QueryBuilder queryBuilder = AbstractQueryBuilder.parseTopLevelQuery(p, c::trackQueryUsage); - c.trackSectionUsage(NAME + ":" + QUERY_FIELD.getPreferredName()); return queryBuilder; }, QUERY_FIELD); - PARSER.declareField((r, v) -> r.searchAfterBuilder = v, (p, c) -> { - SearchAfterBuilder searchAfterBuilder = SearchAfterBuilder.fromXContent(p); - c.trackSectionUsage(NAME + ":" + SEARCH_AFTER_FIELD.getPreferredName()); - return searchAfterBuilder; - }, SEARCH_AFTER_FIELD, ObjectParser.ValueType.OBJECT_ARRAY); - - PARSER.declareField((r, v) -> r.terminateAfter = v, (p, c) -> { - int terminateAfter = p.intValue(); - c.trackSectionUsage(NAME + ":" + TERMINATE_AFTER_FIELD.getPreferredName()); - return terminateAfter; - }, TERMINATE_AFTER_FIELD, ObjectParser.ValueType.INT); - - PARSER.declareField((r, v) -> r.sortBuilders = v, (p, c) -> { - List> sortBuilders = SortBuilder.fromXContent(p); - c.trackSectionUsage(NAME + ":" + SORT_FIELD.getPreferredName()); - return sortBuilders; - }, SORT_FIELD, ObjectParser.ValueType.OBJECT_ARRAY); - - PARSER.declareField((r, v) -> r.collapseBuilder = v, (p, c) -> { - CollapseBuilder collapseBuilder = CollapseBuilder.fromXContent(p); - if (collapseBuilder.getField() != null) { - c.trackSectionUsage(COLLAPSE_FIELD.getPreferredName()); - } - return collapseBuilder; - }, COLLAPSE_FIELD, ObjectParser.ValueType.OBJECT); - + PARSER.declareField( + (r, v) -> r.searchAfterBuilder = v, + (p, c) -> SearchAfterBuilder.fromXContent(p), + SEARCH_AFTER_FIELD, + ObjectParser.ValueType.OBJECT_ARRAY + ); + PARSER.declareField((r, v) -> r.terminateAfter = v, (p, c) -> p.intValue(), TERMINATE_AFTER_FIELD, ObjectParser.ValueType.INT); + PARSER.declareField( + (r, v) -> r.sortBuilders = v, + (p, c) -> SortBuilder.fromXContent(p), + SORT_FIELD, + ObjectParser.ValueType.OBJECT_ARRAY + ); + PARSER.declareField( + (r, v) -> r.collapseBuilder = v, + (p, c) -> CollapseBuilder.fromXContent(p), + COLLAPSE_FIELD, + ObjectParser.ValueType.OBJECT + ); RetrieverBuilder.declareBaseParserFields(NAME, PARSER); } diff --git a/server/src/main/java/org/elasticsearch/usage/SearchUsage.java b/server/src/main/java/org/elasticsearch/usage/SearchUsage.java index 7df7a302f1b1..e35594fb161a 100644 --- a/server/src/main/java/org/elasticsearch/usage/SearchUsage.java +++ b/server/src/main/java/org/elasticsearch/usage/SearchUsage.java @@ -20,6 +20,7 @@ public final class SearchUsage { private final Set queries = new HashSet<>(); private final Set rescorers = new HashSet<>(); private final Set sections = new HashSet<>(); + private final Set retrievers = new HashSet<>(); /** * Track the usage of the provided query @@ -42,6 +43,13 @@ public final class SearchUsage { rescorers.add(name); } + /** + * Track retrieve usage + */ + public void trackRetrieverUsage(String retriever) { + retrievers.add(retriever); + } + /** * Returns the query types that have been used at least once in the tracked search request */ @@ -62,4 +70,11 @@ public final class SearchUsage { public Set getSectionsUsage() { return Collections.unmodifiableSet(sections); } + + /** + * Returns the retriever names that have been used at least once in the tracked search request + */ + public Set getRetrieverUsage() { + return Collections.unmodifiableSet(retrievers); + } } diff --git a/server/src/main/java/org/elasticsearch/usage/SearchUsageHolder.java b/server/src/main/java/org/elasticsearch/usage/SearchUsageHolder.java index 652dfbdd20c5..ef802723cf16 100644 --- a/server/src/main/java/org/elasticsearch/usage/SearchUsageHolder.java +++ b/server/src/main/java/org/elasticsearch/usage/SearchUsageHolder.java @@ -27,6 +27,7 @@ public final class SearchUsageHolder { private final Map queriesUsage = new ConcurrentHashMap<>(); private final Map rescorersUsage = new ConcurrentHashMap<>(); private final Map sectionsUsage = new ConcurrentHashMap<>(); + private final Map retrieversUsage = new ConcurrentHashMap<>(); SearchUsageHolder() {} @@ -44,6 +45,9 @@ public final class SearchUsageHolder { for (String rescorer : searchUsage.getRescorerUsage()) { rescorersUsage.computeIfAbsent(rescorer, q -> new LongAdder()).increment(); } + for (String retriever : searchUsage.getRetrieverUsage()) { + retrieversUsage.computeIfAbsent(retriever, q -> new LongAdder()).increment(); + } } /** @@ -56,10 +60,13 @@ public final class SearchUsageHolder { sectionsUsage.forEach((query, adder) -> sectionsUsageMap.put(query, adder.longValue())); Map rescorersUsageMap = Maps.newMapWithExpectedSize(rescorersUsage.size()); rescorersUsage.forEach((query, adder) -> rescorersUsageMap.put(query, adder.longValue())); + Map retrieversUsageMap = Maps.newMapWithExpectedSize(retrieversUsage.size()); + retrieversUsage.forEach((retriever, adder) -> retrieversUsageMap.put(retriever, adder.longValue())); return new SearchUsageStats( Collections.unmodifiableMap(queriesUsageMap), Collections.unmodifiableMap(rescorersUsageMap), Collections.unmodifiableMap(sectionsUsageMap), + Collections.unmodifiableMap(retrieversUsageMap), totalSearchCount.longValue() ); } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStatsTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStatsTests.java index a705514f5659..89ccd4ab63d7 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStatsTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStatsTests.java @@ -10,6 +10,7 @@ package org.elasticsearch.action.admin.cluster.stats; import org.elasticsearch.TransportVersion; +import org.elasticsearch.TransportVersions; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.Writeable.Reader; import org.elasticsearch.test.AbstractWireSerializingTestCase; @@ -43,9 +44,12 @@ public class SearchUsageStatsTests extends AbstractWireSerializingTestCase RETRIEVERS = List.of("standard", "knn", "rrf", "random", "text_similarity_reranker"); + @Override protected Reader instanceReader() { return SearchUsageStats::new; @@ -75,6 +79,14 @@ public class SearchUsageStatsTests extends AbstractWireSerializingTestCase randomRetrieversUsage(int size) { + Map retrieversUsage = new HashMap<>(); + while (retrieversUsage.size() < size) { + retrieversUsage.put(randomFrom(RETRIEVERS), randomLongBetween(1, Long.MAX_VALUE)); + } + return retrieversUsage; + } + @Override protected SearchUsageStats createTestInstance() { if (randomBoolean()) { @@ -84,6 +96,7 @@ public class SearchUsageStatsTests extends AbstractWireSerializingTestCase randomQueryUsage(randomIntBetween(0, QUERY_TYPES.size()))), instance.getRescorerUsage(), instance.getSectionsUsage(), + instance.getRetrieversUsage(), instance.getTotalSearchCount() ); case 1 -> new SearchUsageStats( instance.getQueryUsage(), randomValueOtherThan(instance.getRescorerUsage(), () -> randomRescorerUsage(randomIntBetween(0, RESCORER_TYPES.size()))), instance.getSectionsUsage(), + instance.getRetrieversUsage(), instance.getTotalSearchCount() ); case 2 -> new SearchUsageStats( instance.getQueryUsage(), instance.getRescorerUsage(), randomValueOtherThan(instance.getSectionsUsage(), () -> randomSectionsUsage(randomIntBetween(0, SECTIONS.size()))), + instance.getRetrieversUsage(), instance.getTotalSearchCount() ); - default -> new SearchUsageStats( + case 3 -> new SearchUsageStats( instance.getQueryUsage(), instance.getRescorerUsage(), instance.getSectionsUsage(), - randomLongBetween(10, Long.MAX_VALUE) + randomValueOtherThan(instance.getRetrieversUsage(), () -> randomSectionsUsage(randomIntBetween(0, SECTIONS.size()))), + instance.getTotalSearchCount() ); + case 4 -> new SearchUsageStats( + instance.getQueryUsage(), + instance.getRescorerUsage(), + instance.getSectionsUsage(), + instance.getRetrieversUsage(), + randomValueOtherThan(instance.getTotalSearchCount(), () -> randomLongBetween(10, Long.MAX_VALUE)) + ); + default -> throw new IllegalStateException("Unexpected value: " + i); }; } @@ -126,7 +151,9 @@ public class SearchUsageStatsTests extends AbstractWireSerializingTestCase p.namedObject(RetrieverBuilder.class, n, c), RETRIEVER_FIELD); + PARSER.declareNamedObject(constructorArg(), (p, c, n) -> { + RetrieverBuilder innerRetriever = p.namedObject(RetrieverBuilder.class, n, c); + c.trackRetrieverUsage(innerRetriever.getName()); + return innerRetriever; + }, RETRIEVER_FIELD); PARSER.declareString(constructorArg(), INFERENCE_ID_FIELD); PARSER.declareString(constructorArg(), INFERENCE_TEXT_FIELD); PARSER.declareString(constructorArg(), FIELD_FIELD); diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilderTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilderTests.java index 32301bf9efea..478f3b2f33c9 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilderTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilderTests.java @@ -117,7 +117,10 @@ public class TextSimilarityRankRetrieverBuilderTests extends AbstractXContentTes }"""; try (XContentParser parser = createParser(JsonXContent.jsonXContent, json)) { - TextSimilarityRankRetrieverBuilder parsed = TextSimilarityRankRetrieverBuilder.PARSER.parse(parser, null); + TextSimilarityRankRetrieverBuilder parsed = TextSimilarityRankRetrieverBuilder.PARSER.parse( + parser, + new RetrieverParserContext(new SearchUsage(), nf -> true) + ); assertEquals(DEFAULT_RANK_WINDOW_SIZE, parsed.rankWindowSize()); } } diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java new file mode 100644 index 000000000000..916703446995 --- /dev/null +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverTelemetryTests.java @@ -0,0 +1,187 @@ +/* + * 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.xpack.inference.rank.textsimilarity; + +import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesRequest; +import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesResponse; +import org.elasticsearch.action.admin.cluster.stats.SearchUsageStats; +import org.elasticsearch.client.Request; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.retriever.KnnRetrieverBuilder; +import org.elasticsearch.search.retriever.StandardRetrieverBuilder; +import org.elasticsearch.search.vectors.KnnSearchBuilder; +import org.elasticsearch.search.vectors.KnnVectorQueryBuilder; +import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentFactory; +import org.elasticsearch.xpack.core.XPackPlugin; +import org.elasticsearch.xpack.inference.InferencePlugin; +import org.junit.Before; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.hamcrest.Matchers.equalTo; + +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) +public class TextSimilarityRankRetrieverTelemetryTests extends ESIntegTestCase { + + private static final String INDEX_NAME = "test_index"; + + @Override + protected boolean addMockHttpTransport() { + return false; // enable http + } + + @Override + protected Collection> nodePlugins() { + return List.of(InferencePlugin.class, XPackPlugin.class, TextSimilarityTestPlugin.class); + } + + @Override + protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal, otherSettings)) + .put("xpack.license.self_generated.type", "trial") + .build(); + } + + @Before + public void setup() throws IOException { + XContentBuilder builder = XContentFactory.jsonBuilder() + .startObject() + .startObject("properties") + .startObject("vector") + .field("type", "dense_vector") + .field("dims", 1) + .field("index", true) + .field("similarity", "l2_norm") + .startObject("index_options") + .field("type", "hnsw") + .endObject() + .endObject() + .startObject("text") + .field("type", "text") + .endObject() + .startObject("integer") + .field("type", "integer") + .endObject() + .startObject("topic") + .field("type", "keyword") + .endObject() + .endObject() + .endObject(); + + assertAcked(prepareCreate(INDEX_NAME).setMapping(builder)); + ensureGreen(INDEX_NAME); + } + + private void performSearch(SearchSourceBuilder source) throws IOException { + Request request = new Request("GET", INDEX_NAME + "/_search"); + request.setJsonEntity(Strings.toString(source)); + getRestClient().performRequest(request); + } + + public void testTelemetryForRRFRetriever() throws IOException { + + if (false == isRetrieverTelemetryEnabled()) { + return; + } + + // search#1 - this will record 1 entry for "retriever" in `sections`, and 1 for "knn" under `retrievers` + { + performSearch(new SearchSourceBuilder().retriever(new KnnRetrieverBuilder("vector", new float[] { 1.0f }, null, 10, 15, null))); + } + + // search#2 - this will record 1 entry for "retriever" in `sections`, 1 for "standard" under `retrievers`, and 1 for "range" under + // `queries` + { + performSearch(new SearchSourceBuilder().retriever(new StandardRetrieverBuilder(QueryBuilders.rangeQuery("integer").gte(2)))); + } + + // search#3 - this will record 1 entry for "retriever" in `sections`, and 1 for "standard" under `retrievers`, and 1 for "knn" under + // `queries` + { + performSearch( + new SearchSourceBuilder().retriever( + new StandardRetrieverBuilder(new KnnVectorQueryBuilder("vector", new float[] { 1.0f }, 10, 15, null)) + ) + ); + } + + // search#4 - this will record 1 entry for "retriever" in `sections`, and 1 for "standard" under `retrievers`, and 1 for "term" + // under `queries` + { + performSearch(new SearchSourceBuilder().retriever(new StandardRetrieverBuilder(QueryBuilders.termQuery("topic", "foo")))); + } + + // search#5 - this will record 1 entry for "retriever" in `sections`, and 1 for "text_similarity_reranker" under `retrievers`, as + // well as + // 1 "standard" under `retrievers`, and eventually 1 for "match" under `queries` + { + performSearch( + new SearchSourceBuilder().retriever( + new TextSimilarityRankRetrieverBuilder( + new StandardRetrieverBuilder(QueryBuilders.matchQuery("text", "foo")), + "some_inference_id", + "some_inference_text", + "some_field", + 10 + ) + ) + ); + } + + // search#6 - this will record 1 entry for "knn" in `sections` + { + performSearch(new SearchSourceBuilder().knnSearch(List.of(new KnnSearchBuilder("vector", new float[] { 1.0f }, 10, 15, null)))); + } + + // search#7 - this will record 1 entry for "query" in `sections`, and 1 for "match_all" under `queries` + { + performSearch(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery())); + } + + // cluster stats + { + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + assertEquals(7, stats.getTotalSearchCount()); + + assertThat(stats.getSectionsUsage().size(), equalTo(3)); + assertThat(stats.getSectionsUsage().get("retriever"), equalTo(5L)); + assertThat(stats.getSectionsUsage().get("query"), equalTo(1L)); + assertThat(stats.getSectionsUsage().get("knn"), equalTo(1L)); + + assertThat(stats.getRetrieversUsage().size(), equalTo(3)); + assertThat(stats.getRetrieversUsage().get("standard"), equalTo(4L)); + assertThat(stats.getRetrieversUsage().get("knn"), equalTo(1L)); + assertThat(stats.getRetrieversUsage().get("text_similarity_reranker"), equalTo(1L)); + + assertThat(stats.getQueryUsage().size(), equalTo(5)); + assertThat(stats.getQueryUsage().get("range"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("term"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("match"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("match_all"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("knn"), equalTo(1L)); + } + } + + private boolean isRetrieverTelemetryEnabled() throws IOException { + NodesCapabilitiesResponse res = clusterAdmin().nodesCapabilities( + new NodesCapabilitiesRequest().method(RestRequest.Method.GET).path("_cluster/stats").capabilities("retrievers-usage-stats") + ).actionGet(); + return res != null && res.isSupported().orElse(false); + } +} diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java index c3d502e561bd..3a9069dee064 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java @@ -590,7 +590,8 @@ public class ClusterStatsMonitoringDocTests extends BaseMonitoringDocTestCase> nodePlugins() { + return List.of(RRFRankPlugin.class, XPackPlugin.class); + } + + @Override + protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal, otherSettings)) + .put("xpack.license.self_generated.type", "trial") + .build(); + } + + @Before + public void setup() throws IOException { + XContentBuilder builder = XContentFactory.jsonBuilder() + .startObject() + .startObject("properties") + .startObject("vector") + .field("type", "dense_vector") + .field("dims", 1) + .field("index", true) + .field("similarity", "l2_norm") + .startObject("index_options") + .field("type", "hnsw") + .endObject() + .endObject() + .startObject("text") + .field("type", "text") + .endObject() + .startObject("integer") + .field("type", "integer") + .endObject() + .startObject("topic") + .field("type", "keyword") + .endObject() + .endObject() + .endObject(); + + assertAcked(prepareCreate(INDEX_NAME).setMapping(builder)); + ensureGreen(INDEX_NAME); + } + + private void performSearch(SearchSourceBuilder source) throws IOException { + Request request = new Request("GET", INDEX_NAME + "/_search"); + request.setJsonEntity(Strings.toString(source)); + getRestClient().performRequest(request); + } + + public void testTelemetryForRRFRetriever() throws IOException { + + if (false == isRetrieverTelemetryEnabled()) { + return; + } + + // search#1 - this will record 1 entry for "retriever" in `sections`, and 1 for "knn" under `retrievers` + { + performSearch(new SearchSourceBuilder().retriever(new KnnRetrieverBuilder("vector", new float[] { 1.0f }, null, 10, 15, null))); + } + + // search#2 - this will record 1 entry for "retriever" in `sections`, 1 for "standard" under `retrievers`, and 1 for "range" under + // `queries` + { + performSearch(new SearchSourceBuilder().retriever(new StandardRetrieverBuilder(QueryBuilders.rangeQuery("integer").gte(2)))); + } + + // search#3 - this will record 1 entry for "retriever" in `sections`, and 1 for "standard" under `retrievers`, and 1 for "knn" under + // `queries` + { + performSearch( + new SearchSourceBuilder().retriever( + new StandardRetrieverBuilder(new KnnVectorQueryBuilder("vector", new float[] { 1.0f }, 10, 15, null)) + ) + ); + } + + // search#4 - this will record 1 entry for "retriever" in `sections`, and 1 for "standard" under `retrievers`, and 1 for "term" + // under `queries` + { + performSearch(new SearchSourceBuilder().retriever(new StandardRetrieverBuilder(QueryBuilders.termQuery("topic", "foo")))); + } + + // search#5 - this will record 1 entry for "retriever" in `sections`, and 1 for "rrf" under `retrievers`, as well as + // 1 for "knn" and 1 for "standard" under `retrievers`, and eventually 1 for "match" under `queries` + { + performSearch( + new SearchSourceBuilder().retriever( + new RRFRetrieverBuilder( + Arrays.asList( + new CompoundRetrieverBuilder.RetrieverSource( + new KnnRetrieverBuilder("vector", new float[] { 1.0f }, null, 10, 15, null), + null + ), + new CompoundRetrieverBuilder.RetrieverSource( + new StandardRetrieverBuilder(QueryBuilders.matchQuery("text", "foo")), + null + ) + ), + 10, + 10 + ) + ) + ); + } + + // search#6 - this will record 1 entry for "knn" in `sections` + { + performSearch(new SearchSourceBuilder().knnSearch(List.of(new KnnSearchBuilder("vector", new float[] { 1.0f }, 10, 15, null)))); + } + + // search#7 - this will record 1 entry for "query" in `sections`, and 1 for "match_all" under `queries` + { + performSearch(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery())); + } + + // cluster stats + { + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + assertEquals(7, stats.getTotalSearchCount()); + + assertThat(stats.getSectionsUsage().size(), equalTo(3)); + assertThat(stats.getSectionsUsage().get("retriever"), equalTo(5L)); + assertThat(stats.getSectionsUsage().get("query"), equalTo(1L)); + assertThat(stats.getSectionsUsage().get("knn"), equalTo(1L)); + + assertThat(stats.getRetrieversUsage().size(), equalTo(3)); + assertThat(stats.getRetrieversUsage().get("standard"), equalTo(4L)); + assertThat(stats.getRetrieversUsage().get("knn"), equalTo(2L)); + assertThat(stats.getRetrieversUsage().get("rrf"), equalTo(1L)); + + assertThat(stats.getQueryUsage().size(), equalTo(5)); + assertThat(stats.getQueryUsage().get("range"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("term"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("match"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("match_all"), equalTo(1L)); + assertThat(stats.getQueryUsage().get("knn"), equalTo(1L)); + } + } + + private boolean isRetrieverTelemetryEnabled() throws IOException { + NodesCapabilitiesResponse res = clusterAdmin().nodesCapabilities( + new NodesCapabilitiesRequest().method(RestRequest.Method.GET).path("_cluster/stats").capabilities("retrievers-usage-stats") + ).actionGet(); + return res != null && res.isSupported().orElse(false); + } +} diff --git a/x-pack/plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverBuilder.java b/x-pack/plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverBuilder.java index 5f19e361d857..12c43a2f169f 100644 --- a/x-pack/plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverBuilder.java +++ b/x-pack/plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverBuilder.java @@ -68,6 +68,7 @@ public final class RRFRetrieverBuilder extends CompoundRetrieverBuilder Date: Thu, 10 Oct 2024 09:23:10 +0200 Subject: [PATCH 29/43] Update wolfi image and fix breaking change (#114390) --- .../main/java/org/elasticsearch/gradle/internal/DockerBase.java | 2 +- distribution/docker/src/docker/Dockerfile.ess | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DockerBase.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DockerBase.java index ac83a01ffc29..95f279bfa516 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DockerBase.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DockerBase.java @@ -31,7 +31,7 @@ public enum DockerBase { // Chainguard based wolfi image with latest jdk // This is usually updated via renovatebot // spotless:off - WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:c16d3ad6cebf387e8dd2ad769f54320c4819fbbaa21e729fad087c7ae223b4d0", + WOLFI("docker.elastic.co/wolfi/chainguard-base:latest@sha256:90888b190da54062f67f3fef1372eb0ae7d81ea55f5a1f56d748b13e4853d984", "-wolfi", "apk" ), diff --git a/distribution/docker/src/docker/Dockerfile.ess b/distribution/docker/src/docker/Dockerfile.ess index 4a230bb56278..3ca5e8f2b42a 100644 --- a/distribution/docker/src/docker/Dockerfile.ess +++ b/distribution/docker/src/docker/Dockerfile.ess @@ -25,7 +25,7 @@ USER root COPY plugins/*.zip /opt/plugins/archive/ -RUN chown root.root /opt/plugins/archive/* +RUN chown 1000:1000 /opt/plugins/archive/* RUN chmod 0444 /opt/plugins/archive/* FROM ${base_image} From c8c6f5af530031fe24d4e034d87cf87605c361c3 Mon Sep 17 00:00:00 2001 From: Pete Gillin Date: Thu, 10 Oct 2024 08:34:43 +0100 Subject: [PATCH 30/43] Actually add `terminate` docs page (#114440) A docs page for the `terminate` processor was added in https://github.com/elastic/elasticsearch/pull/114157, but the change to include it in the outer processor reference page was omitted. This change corrects that oversight. --- docs/reference/ingest/processors.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/reference/ingest/processors.asciidoc b/docs/reference/ingest/processors.asciidoc index 8622e0b98602..8f7cef06d12a 100644 --- a/docs/reference/ingest/processors.asciidoc +++ b/docs/reference/ingest/processors.asciidoc @@ -185,6 +185,9 @@ Executes another pipeline. <>:: Reroutes documents to another target index or data stream. +<>:: +Terminates the current ingest pipeline, causing no further processors to be run. + [discrete] [[ingest-process-category-array-json-handling]] === Array/JSON handling processors @@ -258,6 +261,7 @@ include::processors/set.asciidoc[] include::processors/set-security-user.asciidoc[] include::processors/sort.asciidoc[] include::processors/split.asciidoc[] +include::processors/terminate.asciidoc[] include::processors/trim.asciidoc[] include::processors/uppercase.asciidoc[] include::processors/url-decode.asciidoc[] From 3152e418105470ea2aea8d78c49a4425ee5c6fca Mon Sep 17 00:00:00 2001 From: Jan Kuipers <148754765+jan-elastic@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:24:13 +0200 Subject: [PATCH 31/43] Refactor change point detection (#114289) * Move change detection code to separate class * Uniformize ChangeDetector and SkipeAndDipDetector * Separate ChangeDetectorTests and ChangePointAggregatorTests. * Public entrypoint for change point detection * Move p-value computation to ChangeDetector * Move main entrypoint to a separate file --- .../ml/aggs/changepoint/ChangeDetector.java | 560 +++++++++++++++++ .../changepoint/ChangePointAggregator.java | 588 +----------------- .../aggs/changepoint/ChangePointDetector.java | 59 ++ .../aggs/changepoint/SpikeAndDipDetector.java | 7 +- .../aggs/changepoint/ChangeDetectorTests.java | 246 ++++++++ .../ChangePointAggregatorTests.java | 194 ------ .../changepoint/SpikeAndDipDetectorTests.java | 20 +- 7 files changed, 881 insertions(+), 793 deletions(-) create mode 100644 x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetector.java create mode 100644 x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointDetector.java create mode 100644 x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetectorTests.java diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetector.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetector.java new file mode 100644 index 000000000000..e771fb3b9456 --- /dev/null +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetector.java @@ -0,0 +1,560 @@ +/* + * 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.xpack.ml.aggs.changepoint; + +import org.apache.commons.math3.distribution.UniformRealDistribution; +import org.apache.commons.math3.random.RandomGeneratorFactory; +import org.apache.commons.math3.special.Beta; +import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; +import org.apache.commons.math3.stat.regression.SimpleRegression; +import org.elasticsearch.common.util.set.Sets; +import org.elasticsearch.logging.LogManager; +import org.elasticsearch.logging.Logger; +import org.elasticsearch.xpack.ml.aggs.MlAggsHelper; + +import java.util.Arrays; +import java.util.Random; +import java.util.Set; +import java.util.function.IntToDoubleFunction; +import java.util.stream.IntStream; + +/** + * Detects whether a time series is stationary or changing + * (either continuously or at a specific change point). + */ +public class ChangeDetector { + + private static final int MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST = 500; + private static final int MAXIMUM_CANDIDATE_CHANGE_POINTS = 1000; + + private static final KolmogorovSmirnovTest KOLMOGOROV_SMIRNOV_TEST = new KolmogorovSmirnovTest(); + + private static final Logger logger = LogManager.getLogger(ChangeDetector.class); + + private final MlAggsHelper.DoubleBucketValues bucketValues; + private final double[] values; + + ChangeDetector(MlAggsHelper.DoubleBucketValues bucketValues) { + this.bucketValues = bucketValues; + this.values = bucketValues.getValues(); + } + + ChangeType detect(double minBucketsPValue) { + // This was obtained by simulating the test power for a fixed size effect as a + // function of the bucket value count. + double pValueThreshold = minBucketsPValue * Math.exp(-0.04 * (values.length - 2 * (ChangePointDetector.MINIMUM_BUCKETS + 1))); + return testForChange(pValueThreshold).changeType(bucketValues, slope(values)); + } + + private TestStats testForChange(double pValueThreshold) { + + int[] candidateChangePoints = computeCandidateChangePoints(values); + logger.trace("candidatePoints: [{}]", Arrays.toString(candidateChangePoints)); + + double[] valuesWeights = outlierWeights(values); + logger.trace("values: [{}]", Arrays.toString(values)); + logger.trace("valuesWeights: [{}]", Arrays.toString(valuesWeights)); + RunningStats dataRunningStats = RunningStats.from(values, i -> valuesWeights[i]); + DataStats dataStats = new DataStats( + dataRunningStats.count(), + dataRunningStats.mean(), + dataRunningStats.variance(), + candidateChangePoints.length + ); + logger.trace("dataStats: [{}]", dataStats); + TestStats stationary = new TestStats(Type.STATIONARY, 1.0, dataStats.var(), 1.0, dataStats); + + if (dataStats.varianceZeroToWorkingPrecision()) { + return stationary; + } + + TestStats trendVsStationary = testTrendVs(stationary, values, valuesWeights); + logger.trace("trend vs stationary: [{}]", trendVsStationary); + + TestStats best = stationary; + Set discoveredChangePoints = Sets.newHashSetWithExpectedSize(4); + if (trendVsStationary.accept(pValueThreshold)) { + // Check if there is a change in the trend. + TestStats trendChangeVsTrend = testTrendChangeVs(trendVsStationary, values, valuesWeights, candidateChangePoints); + discoveredChangePoints.add(trendChangeVsTrend.changePoint()); + logger.trace("trend change vs trend: [{}]", trendChangeVsTrend); + + if (trendChangeVsTrend.accept(pValueThreshold)) { + // Check if modeling a trend change adds much over modeling a step change. + best = testVsStepChange(trendChangeVsTrend, values, valuesWeights, candidateChangePoints, pValueThreshold); + } else { + best = trendVsStationary; + } + + } else { + // Check if there is a step change. + TestStats stepChangeVsStationary = testStepChangeVs(stationary, values, valuesWeights, candidateChangePoints); + discoveredChangePoints.add(stepChangeVsStationary.changePoint()); + logger.trace("step change vs stationary: [{}]", stepChangeVsStationary); + + if (stepChangeVsStationary.accept(pValueThreshold)) { + // Check if modeling a trend change adds much over modeling a step change. + TestStats trendChangeVsStepChange = testTrendChangeVs(stepChangeVsStationary, values, valuesWeights, candidateChangePoints); + discoveredChangePoints.add(stepChangeVsStationary.changePoint()); + logger.trace("trend change vs step change: [{}]", trendChangeVsStepChange); + if (trendChangeVsStepChange.accept(pValueThreshold)) { + best = trendChangeVsStepChange; + } else { + best = stepChangeVsStationary; + } + + } else { + // Check if there is a trend change. + TestStats trendChangeVsStationary = testTrendChangeVs(stationary, values, valuesWeights, candidateChangePoints); + discoveredChangePoints.add(stepChangeVsStationary.changePoint()); + logger.trace("trend change vs stationary: [{}]", trendChangeVsStationary); + if (trendChangeVsStationary.accept(pValueThreshold)) { + best = trendChangeVsStationary; + } + } + } + + logger.trace("best: [{}]", best.pValueVsStationary()); + + // We're not very confident in the change point, so check if a distribution change + // fits the data better. + if (best.pValueVsStationary() > 1e-5) { + TestStats distChange = testDistributionChange(dataStats, values, valuesWeights, candidateChangePoints, discoveredChangePoints); + logger.trace("distribution change: [{}]", distChange); + if (distChange.pValue() < Math.min(pValueThreshold, 0.1 * best.pValueVsStationary())) { + best = distChange; + } + } + + return best; + } + + private int[] computeCandidateChangePoints(double[] values) { + int minValues = Math.max((int) (0.1 * values.length + 0.5), ChangePointDetector.MINIMUM_BUCKETS); + if (values.length - 2 * minValues <= MAXIMUM_CANDIDATE_CHANGE_POINTS) { + return IntStream.range(minValues, values.length - minValues).toArray(); + } else { + int step = (int) Math.ceil((double) (values.length - 2 * minValues) / MAXIMUM_CANDIDATE_CHANGE_POINTS); + return IntStream.range(minValues, values.length - minValues).filter(i -> i % step == 0).toArray(); + } + } + + private double[] outlierWeights(double[] values) { + int i = (int) Math.ceil(0.025 * values.length); + double[] weights = Arrays.copyOf(values, values.length); + Arrays.sort(weights); + // We have to be careful here if we have a lot of duplicate values. To avoid marking + // runs of duplicates as outliers we define outliers to be the smallest (largest) + // value strictly less (greater) than the value at i (values.length - i - 1). This + // means if i lands in a run of duplicates the entire run will be marked as inliers. + double a = weights[i]; + double b = weights[values.length - i - 1]; + for (int j = 0; j < values.length; j++) { + if (values[j] <= b && values[j] >= a) { + weights[j] = 1.0; + } else { + weights[j] = 0.01; + } + } + return weights; + } + + private double slope(double[] values) { + SimpleRegression regression = new SimpleRegression(); + for (int i = 0; i < values.length; i++) { + regression.addData(i, values[i]); + } + return regression.getSlope(); + } + + private static double independentTrialsPValue(double pValue, int nTrials) { + return pValue > 1e-10 ? 1.0 - Math.pow(1.0 - pValue, nTrials) : nTrials * pValue; + } + + private TestStats testTrendVs(TestStats H0, double[] values, double[] weights) { + LeastSquaresOnlineRegression allLeastSquares = new LeastSquaresOnlineRegression(2); + for (int i = 0; i < values.length; i++) { + allLeastSquares.add(i, values[i], weights[i]); + } + double vTrend = H0.dataStats().var() * (1.0 - allLeastSquares.rSquared()); + double pValue = fTestNestedPValue(H0.dataStats().nValues(), H0.var(), H0.nParams(), vTrend, 3.0); + return new TestStats(Type.NON_STATIONARY, pValue, vTrend, 3.0, H0.dataStats()); + } + + private TestStats testStepChangeVs(TestStats H0, double[] values, double[] weights, int[] candidateChangePoints) { + + double vStep = Double.MAX_VALUE; + int changePoint = -1; + + // Initialize running stats so that they are only missing the individual changepoint values + RunningStats lowerRange = new RunningStats(); + RunningStats upperRange = new RunningStats(); + upperRange.addValues(values, i -> weights[i], candidateChangePoints[0], values.length); + lowerRange.addValues(values, i -> weights[i], 0, candidateChangePoints[0]); + double mean = H0.dataStats().mean(); + int last = candidateChangePoints[0]; + for (int cp : candidateChangePoints) { + lowerRange.addValues(values, i -> weights[i], last, cp); + upperRange.removeValues(values, i -> weights[i], last, cp); + last = cp; + double nl = lowerRange.count(); + double nu = upperRange.count(); + double ml = lowerRange.mean(); + double mu = upperRange.mean(); + double vl = lowerRange.variance(); + double vu = upperRange.variance(); + double v = (nl * vl + nu * vu) / (nl + nu); + if (v < vStep) { + vStep = v; + changePoint = cp; + } + } + + double pValue = independentTrialsPValue( + fTestNestedPValue(H0.dataStats().nValues(), H0.var(), H0.nParams(), vStep, 2.0), + candidateChangePoints.length + ); + + return new TestStats(Type.STEP_CHANGE, pValue, vStep, 2.0, changePoint, H0.dataStats()); + } + + private TestStats testTrendChangeVs(TestStats H0, double[] values, double[] weights, int[] candidateChangePoints) { + + double vChange = Double.MAX_VALUE; + int changePoint = -1; + + // Initialize running stats so that they are only missing the individual changepoint values + RunningStats lowerRange = new RunningStats(); + RunningStats upperRange = new RunningStats(); + lowerRange.addValues(values, i -> weights[i], 0, candidateChangePoints[0]); + upperRange.addValues(values, i -> weights[i], candidateChangePoints[0], values.length); + LeastSquaresOnlineRegression lowerLeastSquares = new LeastSquaresOnlineRegression(2); + LeastSquaresOnlineRegression upperLeastSquares = new LeastSquaresOnlineRegression(2); + int first = candidateChangePoints[0]; + int last = candidateChangePoints[0]; + for (int i = 0; i < candidateChangePoints[0]; i++) { + lowerLeastSquares.add(i, values[i], weights[i]); + } + for (int i = candidateChangePoints[0]; i < values.length; i++) { + upperLeastSquares.add(i - first, values[i], weights[i]); + } + for (int cp : candidateChangePoints) { + for (int i = last; i < cp; i++) { + lowerRange.addValue(values[i], weights[i]); + upperRange.removeValue(values[i], weights[i]); + lowerLeastSquares.add(i, values[i], weights[i]); + upperLeastSquares.remove(i - first, values[i], weights[i]); + } + last = cp; + double nl = lowerRange.count(); + double nu = upperRange.count(); + double rl = lowerLeastSquares.rSquared(); + double ru = upperLeastSquares.rSquared(); + double vl = lowerRange.variance() * (1.0 - rl); + double vu = upperRange.variance() * (1.0 - ru); + double v = (nl * vl + nu * vu) / (nl + nu); + if (v < vChange) { + vChange = v; + changePoint = cp; + } + } + + double pValue = independentTrialsPValue( + fTestNestedPValue(H0.dataStats().nValues(), H0.var(), H0.nParams(), vChange, 6.0), + candidateChangePoints.length + ); + + return new TestStats(Type.TREND_CHANGE, pValue, vChange, 6.0, changePoint, H0.dataStats()); + } + + private TestStats testVsStepChange( + TestStats trendChange, + double[] values, + double[] weights, + int[] candidateChangePoints, + double pValueThreshold + ) { + DataStats dataStats = trendChange.dataStats(); + TestStats stationary = new TestStats(Type.STATIONARY, 1.0, dataStats.var(), 1.0, dataStats); + TestStats stepChange = testStepChangeVs(stationary, values, weights, candidateChangePoints); + double n = dataStats.nValues(); + double pValue = fTestNestedPValue(n, stepChange.var(), 2.0, trendChange.var(), 6.0); + return pValue < pValueThreshold ? trendChange : stepChange; + } + + private static double fTestNestedPValue(double n, double vNull, double pNull, double vAlt, double pAlt) { + if (vAlt == vNull) { + return 1.0; + } + if (vAlt == 0.0) { + return 0.0; + } + double F = (vNull - vAlt) / (pAlt - pNull) * (n - pAlt) / vAlt; + double sf = fDistribSf(pAlt - pNull, n - pAlt, F); + return Math.min(2 * sf, 1.0); + } + + private static int lowerBound(int[] x, int start, int end, int xs) { + int retVal = Arrays.binarySearch(x, start, end, xs); + if (retVal < 0) { + retVal = -1 - retVal; + } + return retVal; + } + + private SampleData sample(double[] values, double[] weights, Set changePoints) { + Integer[] adjChangePoints = changePoints.toArray(new Integer[changePoints.size()]); + if (values.length <= MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST) { + return new SampleData(values, weights, adjChangePoints); + } + + // Just want repeatable random numbers. + Random rng = new Random(126832678); + UniformRealDistribution uniform = new UniformRealDistribution(RandomGeneratorFactory.createRandomGenerator(rng), 0.0, 0.99999); + + // Fisher–Yates shuffle (why isn't this in Arrays?). + int[] choice = IntStream.range(0, values.length).toArray(); + for (int i = 0; i < MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST; ++i) { + int index = i + (int) Math.floor(uniform.sample() * (values.length - i)); + int tmp = choice[i]; + choice[i] = choice[index]; + choice[index] = tmp; + } + + double[] sample = new double[MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST]; + double[] sampleWeights = new double[MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST]; + Arrays.sort(choice, 0, MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST); + for (int i = 0; i < MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST; ++i) { + sample[i] = values[choice[i]]; + sampleWeights[i] = weights[choice[i]]; + } + for (int i = 0; i < adjChangePoints.length; ++i) { + adjChangePoints[i] = lowerBound(choice, 0, MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST, adjChangePoints[i].intValue()); + } + + return new SampleData(sample, sampleWeights, adjChangePoints); + } + + private TestStats testDistributionChange( + DataStats stats, + double[] values, + double[] weights, + int[] candidateChangePoints, + Set discoveredChangePoints + ) { + + double maxDiff = 0.0; + int changePoint = -1; + + // Initialize running stats so that they are only missing the individual changepoint values + RunningStats lowerRange = new RunningStats(); + RunningStats upperRange = new RunningStats(); + upperRange.addValues(values, i -> weights[i], candidateChangePoints[0], values.length); + lowerRange.addValues(values, i -> weights[i], 0, candidateChangePoints[0]); + int last = candidateChangePoints[0]; + for (int cp : candidateChangePoints) { + lowerRange.addValues(values, i -> weights[i], last, cp); + upperRange.removeValues(values, i -> weights[i], last, cp); + last = cp; + double scale = Math.min(cp, values.length - cp); + double meanDiff = Math.abs(lowerRange.mean() - upperRange.mean()); + double stdDiff = Math.abs(lowerRange.std() - upperRange.std()); + double diff = scale * (meanDiff + stdDiff); + if (diff >= maxDiff) { + maxDiff = diff; + changePoint = cp; + } + } + discoveredChangePoints.add(changePoint); + + // Note that statistical tests become increasingly powerful as the number of samples + // increases. We are not interested in detecting visually small distribution changes + // in splits of long windows so we randomly downsample the data if it is too large + // before we run the tests. + SampleData sampleData = sample(values, weights, discoveredChangePoints); + final double[] sampleValues = sampleData.values(); + final double[] sampleWeights = sampleData.weights(); + + double pValue = 1; + for (int cp : sampleData.changePoints()) { + double[] x = Arrays.copyOfRange(sampleValues, 0, cp); + double[] y = Arrays.copyOfRange(sampleValues, cp, sampleValues.length); + double statistic = KOLMOGOROV_SMIRNOV_TEST.kolmogorovSmirnovStatistic(x, y); + double ksTestPValue = KOLMOGOROV_SMIRNOV_TEST.exactP(statistic, x.length, y.length, false); + if (ksTestPValue < pValue) { + changePoint = cp; + pValue = ksTestPValue; + } + } + + // We start to get false positives if we have too many candidate change points. This + // is the classic p-value hacking problem. However, the Sidak style correction we use + // elsewhere is too conservative because test statistics for different split positions + // are strongly correlated. We assume that we have some effective number of independent + // trials equal to f * n for f < 1. Simulation shows the f = 1/50 yields low Type I + // error rates. + pValue = independentTrialsPValue(pValue, (sampleValues.length + 49) / 50); + logger.trace("distribution change p-value: [{}]", pValue); + + return new TestStats(Type.DISTRIBUTION_CHANGE, pValue, changePoint, stats); + } + + private static double fDistribSf(double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom, double x) { + if (x <= 0) { + return 1; + } + if (Double.isInfinite(x) || Double.isNaN(x)) { + return 0; + } + + return Beta.regularizedBeta( + denominatorDegreesOfFreedom / (denominatorDegreesOfFreedom + numeratorDegreesOfFreedom * x), + 0.5 * denominatorDegreesOfFreedom, + 0.5 * numeratorDegreesOfFreedom + ); + } + + private enum Type { + STATIONARY, + NON_STATIONARY, + STEP_CHANGE, + TREND_CHANGE, + DISTRIBUTION_CHANGE + } + + private record SampleData(double[] values, double[] weights, Integer[] changePoints) {} + + private record DataStats(double nValues, double mean, double var, int nCandidateChangePoints) { + boolean varianceZeroToWorkingPrecision() { + // Our variance calculation is only accurate to ulp(length * mean)^(1/2), + // i.e. we compute it using the difference of squares method and don't use + // the Kahan correction. We treat anything as zero to working precision as + // zero. We should at some point switch to a more numerically stable approach + // for computing data statistics. + return var < Math.sqrt(Math.ulp(2.0 * nValues * mean)); + } + + @Override + public String toString() { + return "DataStats{nValues=" + nValues + ", mean=" + mean + ", var=" + var + ", nCandidates=" + nCandidateChangePoints + "}"; + } + } + + private record TestStats(Type type, double pValue, double var, double nParams, int changePoint, DataStats dataStats) { + TestStats(Type type, double pValue, int changePoint, DataStats dataStats) { + this(type, pValue, 0.0, 0.0, changePoint, dataStats); + } + + TestStats(Type type, double pValue, double var, double nParams, DataStats dataStats) { + this(type, pValue, var, nParams, -1, dataStats); + } + + boolean accept(double pValueThreshold) { + // Check the change is: + // 1. Statistically significant. + // 2. That we explain enough of the data variance overall. + return pValue < pValueThreshold && rSquared() >= 0.5; + } + + double rSquared() { + return 1.0 - var / dataStats.var(); + } + + double pValueVsStationary() { + return independentTrialsPValue( + fTestNestedPValue(dataStats.nValues(), dataStats.var(), 1.0, var, nParams), + dataStats.nCandidateChangePoints() + ); + } + + ChangeType changeType(MlAggsHelper.DoubleBucketValues bucketValues, double slope) { + switch (type) { + case STATIONARY: + return new ChangeType.Stationary(); + case NON_STATIONARY: + return new ChangeType.NonStationary(pValueVsStationary(), rSquared(), slope < 0.0 ? "decreasing" : "increasing"); + case STEP_CHANGE: + return new ChangeType.StepChange(pValueVsStationary(), bucketValues.getBucketIndex(changePoint)); + case TREND_CHANGE: + return new ChangeType.TrendChange(pValueVsStationary(), rSquared(), bucketValues.getBucketIndex(changePoint)); + case DISTRIBUTION_CHANGE: + return new ChangeType.DistributionChange(pValue, bucketValues.getBucketIndex(changePoint)); + } + throw new RuntimeException("Unknown change type [" + type + "]."); + } + + @Override + public String toString() { + return "TestStats{" + + ("type=" + type) + + (", dataStats=" + dataStats) + + (", var=" + var) + + (", rSquared=" + rSquared()) + + (", pValue=" + pValue) + + (", nParams=" + nParams) + + (", changePoint=" + changePoint) + + '}'; + } + } + + private static class RunningStats { + double sumOfSqrs; + double sum; + double count; + + static RunningStats from(double[] values, IntToDoubleFunction weightFunction) { + return new RunningStats().addValues(values, weightFunction, 0, values.length); + } + + RunningStats() {} + + double count() { + return count; + } + + double mean() { + return sum / count; + } + + double variance() { + return Math.max((sumOfSqrs - ((sum * sum) / count)) / count, 0.0); + } + + double std() { + return Math.sqrt(variance()); + } + + RunningStats addValues(double[] value, IntToDoubleFunction weightFunction, int start, int end) { + for (int i = start; i < value.length && i < end; i++) { + addValue(value[i], weightFunction.applyAsDouble(i)); + } + return this; + } + + RunningStats addValue(double value, double weight) { + sumOfSqrs += (value * value * weight); + count += weight; + sum += (value * weight); + return this; + } + + RunningStats removeValue(double value, double weight) { + sumOfSqrs = Math.max(sumOfSqrs - value * value * weight, 0); + count = Math.max(count - weight, 0); + sum -= (value * weight); + return this; + } + + RunningStats removeValues(double[] value, IntToDoubleFunction weightFunction, int start, int end) { + for (int i = start; i < value.length && i < end; i++) { + removeValue(value[i], weightFunction.applyAsDouble(i)); + } + return this; + } + } +} diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregator.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregator.java index faef29ff6507..d643a937180a 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregator.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregator.java @@ -7,86 +7,21 @@ package org.elasticsearch.xpack.ml.aggs.changepoint; -import org.apache.commons.math3.distribution.UniformRealDistribution; -import org.apache.commons.math3.exception.NotStrictlyPositiveException; -import org.apache.commons.math3.random.RandomGeneratorFactory; -import org.apache.commons.math3.special.Beta; -import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; -import org.apache.commons.math3.stat.regression.SimpleRegression; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.search.aggregations.AggregationReduceContext; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.pipeline.BucketHelpers; import org.elasticsearch.search.aggregations.pipeline.SiblingPipelineAggregator; import org.elasticsearch.xpack.ml.aggs.MlAggsHelper; -import org.elasticsearch.xpack.ml.aggs.changepoint.ChangeType.Indeterminable; -import java.util.Arrays; import java.util.Map; import java.util.Optional; -import java.util.Random; -import java.util.Set; -import java.util.function.IntToDoubleFunction; -import java.util.stream.IntStream; import static org.elasticsearch.xpack.ml.aggs.MlAggsHelper.extractBucket; import static org.elasticsearch.xpack.ml.aggs.MlAggsHelper.extractDoubleBucketedValues; public class ChangePointAggregator extends SiblingPipelineAggregator { - private static final Logger logger = LogManager.getLogger(ChangePointAggregator.class); - - static final double P_VALUE_THRESHOLD = 0.01; - private static final int MINIMUM_BUCKETS = 10; - private static final int MAXIMUM_CANDIDATE_CHANGE_POINTS = 1000; - private static final int MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST = 500; - private static final KolmogorovSmirnovTest KOLMOGOROV_SMIRNOV_TEST = new KolmogorovSmirnovTest(); - - private static double changePValueThreshold(int nValues) { - // This was obtained by simulating the test power for a fixed size effect as a - // function of the bucket value count. - return P_VALUE_THRESHOLD * Math.exp(-0.04 * (double) (nValues - 2 * (MINIMUM_BUCKETS + 1))); - } - - private static int lowerBound(int[] x, int start, int end, int xs) { - int retVal = Arrays.binarySearch(x, start, end, xs); - if (retVal < 0) { - retVal = -1 - retVal; - } - return retVal; - } - - private record SampleData(double[] values, double[] weights, Integer[] changePoints) {} - - private record DataStats(double nValues, double mean, double var, int nCandidateChangePoints) { - boolean varianceZeroToWorkingPrecision() { - // Our variance calculation is only accurate to ulp(length * mean)^(1/2), - // i.e. we compute it using the difference of squares method and don't use - // the Kahan correction. We treat anything as zero to working precision as - // zero. We should at some point switch to a more numerically stable approach - // for computing data statistics. - return var < Math.sqrt(Math.ulp(2.0 * nValues * mean)); - } - - @Override - public String toString() { - return "DataStats{nValues=" + nValues + ", mean=" + mean + ", var=" + var + ", nCandidates=" + nCandidateChangePoints + "}"; - } - } - - static int[] computeCandidateChangePoints(double[] values) { - int minValues = Math.max((int) (0.1 * values.length + 0.5), MINIMUM_BUCKETS); - if (values.length - 2 * minValues <= MAXIMUM_CANDIDATE_CHANGE_POINTS) { - return IntStream.range(minValues, values.length - minValues).toArray(); - } else { - int step = (int) Math.ceil((double) (values.length - 2 * minValues) / MAXIMUM_CANDIDATE_CHANGE_POINTS); - return IntStream.range(minValues, values.length - minValues).filter(i -> i % step == 0).toArray(); - } - } - public ChangePointAggregator(String name, String bucketsPath, Map metadata) { super(name, new String[] { bucketsPath }, metadata); } @@ -108,30 +43,8 @@ public class ChangePointAggregator extends SiblingPipelineAggregator { ); } MlAggsHelper.DoubleBucketValues bucketValues = maybeBucketValues.get(); - if (bucketValues.getValues().length < (2 * MINIMUM_BUCKETS) + 2) { - return new InternalChangePointAggregation( - name(), - metadata(), - null, - new ChangeType.Indeterminable( - "not enough buckets to calculate change_point. Requires at least [" - + ((2 * MINIMUM_BUCKETS) + 2) - + "]; found [" - + bucketValues.getValues().length - + "]" - ) - ); - } - ChangeType spikeOrDip = testForSpikeOrDip(bucketValues, P_VALUE_THRESHOLD); - - // Test for change step, trend and distribution changes. - ChangeType change = testForChange(bucketValues, changePValueThreshold(bucketValues.getValues().length)); - logger.trace("change p-value: [{}]", change.pValue()); - - if (spikeOrDip.pValue() < change.pValue()) { - change = spikeOrDip; - } + ChangeType change = ChangePointDetector.getChangeType(bucketValues); ChangePointBucket changePointBucket = null; if (change.changePoint() >= 0) { @@ -142,503 +55,4 @@ public class ChangePointAggregator extends SiblingPipelineAggregator { return new InternalChangePointAggregation(name(), metadata(), changePointBucket, change); } - - static ChangeType testForSpikeOrDip(MlAggsHelper.DoubleBucketValues bucketValues, double pValueThreshold) { - try { - SpikeAndDipDetector detect = new SpikeAndDipDetector(bucketValues.getValues()); - ChangeType result = detect.at(pValueThreshold, bucketValues); - logger.trace("spike or dip p-value: [{}]", result.pValue()); - return result; - } catch (NotStrictlyPositiveException nspe) { - logger.debug("failure testing for dips and spikes", nspe); - } - return new Indeterminable("failure testing for dips and spikes"); - } - - static ChangeType testForChange(MlAggsHelper.DoubleBucketValues bucketValues, double pValueThreshold) { - double[] timeWindow = bucketValues.getValues(); - return testForChange(timeWindow, pValueThreshold).changeType(bucketValues, slope(timeWindow)); - } - - static TestStats testForChange(double[] timeWindow, double pValueThreshold) { - - int[] candidateChangePoints = computeCandidateChangePoints(timeWindow); - logger.trace("candidatePoints: [{}]", Arrays.toString(candidateChangePoints)); - - double[] timeWindowWeights = outlierWeights(timeWindow); - logger.trace("timeWindow: [{}]", Arrays.toString(timeWindow)); - logger.trace("timeWindowWeights: [{}]", Arrays.toString(timeWindowWeights)); - RunningStats dataRunningStats = RunningStats.from(timeWindow, i -> timeWindowWeights[i]); - DataStats dataStats = new DataStats( - dataRunningStats.count(), - dataRunningStats.mean(), - dataRunningStats.variance(), - candidateChangePoints.length - ); - logger.trace("dataStats: [{}]", dataStats); - TestStats stationary = new TestStats(Type.STATIONARY, 1.0, dataStats.var(), 1.0, dataStats); - - if (dataStats.varianceZeroToWorkingPrecision()) { - return stationary; - } - - TestStats trendVsStationary = testTrendVs(stationary, timeWindow, timeWindowWeights); - logger.trace("trend vs stationary: [{}]", trendVsStationary); - - TestStats best = stationary; - Set discoveredChangePoints = Sets.newHashSetWithExpectedSize(4); - if (trendVsStationary.accept(pValueThreshold)) { - // Check if there is a change in the trend. - TestStats trendChangeVsTrend = testTrendChangeVs(trendVsStationary, timeWindow, timeWindowWeights, candidateChangePoints); - discoveredChangePoints.add(trendChangeVsTrend.changePoint()); - logger.trace("trend change vs trend: [{}]", trendChangeVsTrend); - - if (trendChangeVsTrend.accept(pValueThreshold)) { - // Check if modeling a trend change adds much over modeling a step change. - best = testVsStepChange(trendChangeVsTrend, timeWindow, timeWindowWeights, candidateChangePoints, pValueThreshold); - } else { - best = trendVsStationary; - } - - } else { - // Check if there is a step change. - TestStats stepChangeVsStationary = testStepChangeVs(stationary, timeWindow, timeWindowWeights, candidateChangePoints); - discoveredChangePoints.add(stepChangeVsStationary.changePoint()); - logger.trace("step change vs stationary: [{}]", stepChangeVsStationary); - - if (stepChangeVsStationary.accept(pValueThreshold)) { - // Check if modeling a trend change adds much over modeling a step change. - TestStats trendChangeVsStepChange = testTrendChangeVs( - stepChangeVsStationary, - timeWindow, - timeWindowWeights, - candidateChangePoints - ); - discoveredChangePoints.add(stepChangeVsStationary.changePoint()); - logger.trace("trend change vs step change: [{}]", trendChangeVsStepChange); - if (trendChangeVsStepChange.accept(pValueThreshold)) { - best = trendChangeVsStepChange; - } else { - best = stepChangeVsStationary; - } - - } else { - // Check if there is a trend change. - TestStats trendChangeVsStationary = testTrendChangeVs(stationary, timeWindow, timeWindowWeights, candidateChangePoints); - discoveredChangePoints.add(stepChangeVsStationary.changePoint()); - logger.trace("trend change vs stationary: [{}]", trendChangeVsStationary); - if (trendChangeVsStationary.accept(pValueThreshold)) { - best = trendChangeVsStationary; - } - } - } - - logger.trace("best: [{}]", best.pValueVsStationary()); - - // We're not very confident in the change point, so check if a distribution change - // fits the data better. - if (best.pValueVsStationary() > 1e-5) { - TestStats distChange = testDistributionChange( - dataStats, - timeWindow, - timeWindowWeights, - candidateChangePoints, - discoveredChangePoints - ); - logger.trace("distribution change: [{}]", distChange); - if (distChange.pValue() < Math.min(pValueThreshold, 0.1 * best.pValueVsStationary())) { - best = distChange; - } - } - - return best; - } - - static double[] outlierWeights(double[] values) { - int i = (int) Math.ceil(0.025 * values.length); - double[] weights = Arrays.copyOf(values, values.length); - Arrays.sort(weights); - // We have to be careful here if we have a lot of duplicate values. To avoid marking - // runs of duplicates as outliers we define outliers to be the smallest (largest) - // value strictly less (greater) than the value at i (values.length - i - 1). This - // means if i lands in a run of duplicates the entire run will be marked as inliers. - double a = weights[i]; - double b = weights[values.length - i - 1]; - for (int j = 0; j < values.length; j++) { - if (values[j] <= b && values[j] >= a) { - weights[j] = 1.0; - } else { - weights[j] = 0.01; - } - } - return weights; - } - - static double slope(double[] values) { - SimpleRegression regression = new SimpleRegression(); - for (int i = 0; i < values.length; i++) { - regression.addData(i, values[i]); - } - return regression.getSlope(); - } - - static double independentTrialsPValue(double pValue, int nTrials) { - return pValue > 1e-10 ? 1.0 - Math.pow(1.0 - pValue, nTrials) : nTrials * pValue; - } - - static TestStats testTrendVs(TestStats H0, double[] values, double[] weights) { - LeastSquaresOnlineRegression allLeastSquares = new LeastSquaresOnlineRegression(2); - for (int i = 0; i < values.length; i++) { - allLeastSquares.add(i, values[i], weights[i]); - } - double vTrend = H0.dataStats().var() * (1.0 - allLeastSquares.rSquared()); - double pValue = fTestNestedPValue(H0.dataStats().nValues(), H0.var(), H0.nParams(), vTrend, 3.0); - return new TestStats(Type.NON_STATIONARY, pValue, vTrend, 3.0, H0.dataStats()); - } - - static TestStats testStepChangeVs(TestStats H0, double[] values, double[] weights, int[] candidateChangePoints) { - - double vStep = Double.MAX_VALUE; - int changePoint = -1; - - // Initialize running stats so that they are only missing the individual changepoint values - RunningStats lowerRange = new RunningStats(); - RunningStats upperRange = new RunningStats(); - upperRange.addValues(values, i -> weights[i], candidateChangePoints[0], values.length); - lowerRange.addValues(values, i -> weights[i], 0, candidateChangePoints[0]); - double mean = H0.dataStats().mean(); - int last = candidateChangePoints[0]; - for (int cp : candidateChangePoints) { - lowerRange.addValues(values, i -> weights[i], last, cp); - upperRange.removeValues(values, i -> weights[i], last, cp); - last = cp; - double nl = lowerRange.count(); - double nu = upperRange.count(); - double ml = lowerRange.mean(); - double mu = upperRange.mean(); - double vl = lowerRange.variance(); - double vu = upperRange.variance(); - double v = (nl * vl + nu * vu) / (nl + nu); - if (v < vStep) { - vStep = v; - changePoint = cp; - } - } - - double pValue = independentTrialsPValue( - fTestNestedPValue(H0.dataStats().nValues(), H0.var(), H0.nParams(), vStep, 2.0), - candidateChangePoints.length - ); - - return new TestStats(Type.STEP_CHANGE, pValue, vStep, 2.0, changePoint, H0.dataStats()); - } - - static TestStats testTrendChangeVs(TestStats H0, double[] values, double[] weights, int[] candidateChangePoints) { - - double vChange = Double.MAX_VALUE; - int changePoint = -1; - - // Initialize running stats so that they are only missing the individual changepoint values - RunningStats lowerRange = new RunningStats(); - RunningStats upperRange = new RunningStats(); - lowerRange.addValues(values, i -> weights[i], 0, candidateChangePoints[0]); - upperRange.addValues(values, i -> weights[i], candidateChangePoints[0], values.length); - LeastSquaresOnlineRegression lowerLeastSquares = new LeastSquaresOnlineRegression(2); - LeastSquaresOnlineRegression upperLeastSquares = new LeastSquaresOnlineRegression(2); - int first = candidateChangePoints[0]; - int last = candidateChangePoints[0]; - for (int i = 0; i < candidateChangePoints[0]; i++) { - lowerLeastSquares.add(i, values[i], weights[i]); - } - for (int i = candidateChangePoints[0]; i < values.length; i++) { - upperLeastSquares.add(i - first, values[i], weights[i]); - } - for (int cp : candidateChangePoints) { - for (int i = last; i < cp; i++) { - lowerRange.addValue(values[i], weights[i]); - upperRange.removeValue(values[i], weights[i]); - lowerLeastSquares.add(i, values[i], weights[i]); - upperLeastSquares.remove(i - first, values[i], weights[i]); - } - last = cp; - double nl = lowerRange.count(); - double nu = upperRange.count(); - double rl = lowerLeastSquares.rSquared(); - double ru = upperLeastSquares.rSquared(); - double vl = lowerRange.variance() * (1.0 - rl); - double vu = upperRange.variance() * (1.0 - ru); - double v = (nl * vl + nu * vu) / (nl + nu); - if (v < vChange) { - vChange = v; - changePoint = cp; - } - } - - double pValue = independentTrialsPValue( - fTestNestedPValue(H0.dataStats().nValues(), H0.var(), H0.nParams(), vChange, 6.0), - candidateChangePoints.length - ); - - return new TestStats(Type.TREND_CHANGE, pValue, vChange, 6.0, changePoint, H0.dataStats()); - } - - static TestStats testVsStepChange( - TestStats trendChange, - double[] values, - double[] weights, - int[] candidateChangePoints, - double pValueThreshold - ) { - DataStats dataStats = trendChange.dataStats(); - TestStats stationary = new TestStats(Type.STATIONARY, 1.0, dataStats.var(), 1.0, dataStats); - TestStats stepChange = testStepChangeVs(stationary, values, weights, candidateChangePoints); - double n = dataStats.nValues(); - double pValue = fTestNestedPValue(n, stepChange.var(), 2.0, trendChange.var(), 6.0); - return pValue < pValueThreshold ? trendChange : stepChange; - } - - static double fTestNestedPValue(double n, double vNull, double pNull, double vAlt, double pAlt) { - if (vAlt == vNull) { - return 1.0; - } - if (vAlt == 0.0) { - return 0.0; - } - double F = (vNull - vAlt) / (pAlt - pNull) * (n - pAlt) / vAlt; - double sf = fDistribSf(pAlt - pNull, n - pAlt, F); - return Math.min(2 * sf, 1.0); - } - - static SampleData sample(double[] values, double[] weights, Set changePoints) { - Integer[] adjChangePoints = changePoints.toArray(new Integer[changePoints.size()]); - if (values.length <= MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST) { - return new SampleData(values, weights, adjChangePoints); - } - - // Just want repeatable random numbers. - Random rng = new Random(126832678); - UniformRealDistribution uniform = new UniformRealDistribution(RandomGeneratorFactory.createRandomGenerator(rng), 0.0, 0.99999); - - // Fisher–Yates shuffle (why isn't this in Arrays?). - int[] choice = IntStream.range(0, values.length).toArray(); - for (int i = 0; i < MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST; ++i) { - int index = i + (int) Math.floor(uniform.sample() * (values.length - i)); - int tmp = choice[i]; - choice[i] = choice[index]; - choice[index] = tmp; - } - - double[] sample = new double[MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST]; - double[] sampleWeights = new double[MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST]; - Arrays.sort(choice, 0, MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST); - for (int i = 0; i < MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST; ++i) { - sample[i] = values[choice[i]]; - sampleWeights[i] = weights[choice[i]]; - } - for (int i = 0; i < adjChangePoints.length; ++i) { - adjChangePoints[i] = lowerBound(choice, 0, MAXIMUM_SAMPLE_SIZE_FOR_KS_TEST, adjChangePoints[i].intValue()); - } - - return new SampleData(sample, sampleWeights, adjChangePoints); - } - - static TestStats testDistributionChange( - DataStats stats, - double[] values, - double[] weights, - int[] candidateChangePoints, - Set discoveredChangePoints - ) { - - double maxDiff = 0.0; - int changePoint = -1; - - // Initialize running stats so that they are only missing the individual changepoint values - RunningStats lowerRange = new RunningStats(); - RunningStats upperRange = new RunningStats(); - upperRange.addValues(values, i -> weights[i], candidateChangePoints[0], values.length); - lowerRange.addValues(values, i -> weights[i], 0, candidateChangePoints[0]); - int last = candidateChangePoints[0]; - for (int cp : candidateChangePoints) { - lowerRange.addValues(values, i -> weights[i], last, cp); - upperRange.removeValues(values, i -> weights[i], last, cp); - last = cp; - double scale = Math.min(cp, values.length - cp); - double meanDiff = Math.abs(lowerRange.mean() - upperRange.mean()); - double stdDiff = Math.abs(lowerRange.std() - upperRange.std()); - double diff = scale * (meanDiff + stdDiff); - if (diff >= maxDiff) { - maxDiff = diff; - changePoint = cp; - } - } - discoveredChangePoints.add(changePoint); - - // Note that statistical tests become increasingly powerful as the number of samples - // increases. We are not interested in detecting visually small distribution changes - // in splits of long windows so we randomly downsample the data if it is too large - // before we run the tests. - SampleData sampleData = sample(values, weights, discoveredChangePoints); - final double[] sampleValues = sampleData.values(); - final double[] sampleWeights = sampleData.weights(); - - double pValue = 1; - for (int cp : sampleData.changePoints()) { - double[] x = Arrays.copyOfRange(sampleValues, 0, cp); - double[] y = Arrays.copyOfRange(sampleValues, cp, sampleValues.length); - double statistic = KOLMOGOROV_SMIRNOV_TEST.kolmogorovSmirnovStatistic(x, y); - double ksTestPValue = KOLMOGOROV_SMIRNOV_TEST.exactP(statistic, x.length, y.length, false); - if (ksTestPValue < pValue) { - changePoint = cp; - pValue = ksTestPValue; - } - } - - // We start to get false positives if we have too many candidate change points. This - // is the classic p-value hacking problem. However, the Sidak style correction we use - // elsewhere is too conservative because test statistics for different split positions - // are strongly correlated. We assume that we have some effective number of independent - // trials equal to f * n for f < 1. Simulation shows the f = 1/50 yields low Type I - // error rates. - pValue = independentTrialsPValue(pValue, (sampleValues.length + 49) / 50); - logger.trace("distribution change p-value: [{}]", pValue); - - return new TestStats(Type.DISTRIBUTION_CHANGE, pValue, changePoint, stats); - } - - enum Type { - STATIONARY, - NON_STATIONARY, - STEP_CHANGE, - TREND_CHANGE, - DISTRIBUTION_CHANGE - } - - record TestStats(Type type, double pValue, double var, double nParams, int changePoint, DataStats dataStats) { - TestStats(Type type, double pValue, int changePoint, DataStats dataStats) { - this(type, pValue, 0.0, 0.0, changePoint, dataStats); - } - - TestStats(Type type, double pValue, double var, double nParams, DataStats dataStats) { - this(type, pValue, var, nParams, -1, dataStats); - } - - boolean accept(double pValueThreshold) { - // Check the change is: - // 1. Statistically significant. - // 2. That we explain enough of the data variance overall. - return pValue < pValueThreshold && rSquared() >= 0.5; - } - - double rSquared() { - return 1.0 - var / dataStats.var(); - } - - double pValueVsStationary() { - return independentTrialsPValue( - fTestNestedPValue(dataStats.nValues(), dataStats.var(), 1.0, var, nParams), - dataStats.nCandidateChangePoints() - ); - } - - ChangeType changeType(MlAggsHelper.DoubleBucketValues bucketValues, double slope) { - switch (type) { - case STATIONARY: - return new ChangeType.Stationary(); - case NON_STATIONARY: - return new ChangeType.NonStationary(pValueVsStationary(), rSquared(), slope < 0.0 ? "decreasing" : "increasing"); - case STEP_CHANGE: - return new ChangeType.StepChange(pValueVsStationary(), bucketValues.getBucketIndex(changePoint)); - case TREND_CHANGE: - return new ChangeType.TrendChange(pValueVsStationary(), rSquared(), bucketValues.getBucketIndex(changePoint)); - case DISTRIBUTION_CHANGE: - return new ChangeType.DistributionChange(pValue, bucketValues.getBucketIndex(changePoint)); - } - throw new RuntimeException("Unknown change type [" + type + "]."); - } - - @Override - public String toString() { - return "TestStats{" - + ("type=" + type) - + (", dataStats=" + dataStats) - + (", var=" + var) - + (", rSquared=" + rSquared()) - + (", pValue=" + pValue) - + (", nParams=" + nParams) - + (", changePoint=" + changePoint) - + '}'; - } - } - - static class RunningStats { - double sumOfSqrs; - double sum; - double count; - - static RunningStats from(double[] values, IntToDoubleFunction weightFunction) { - return new RunningStats().addValues(values, weightFunction, 0, values.length); - } - - RunningStats() {} - - double count() { - return count; - } - - double mean() { - return sum / count; - } - - double variance() { - return Math.max((sumOfSqrs - ((sum * sum) / count)) / count, 0.0); - } - - double std() { - return Math.sqrt(variance()); - } - - RunningStats addValues(double[] value, IntToDoubleFunction weightFunction, int start, int end) { - for (int i = start; i < value.length && i < end; i++) { - addValue(value[i], weightFunction.applyAsDouble(i)); - } - return this; - } - - RunningStats addValue(double value, double weight) { - sumOfSqrs += (value * value * weight); - count += weight; - sum += (value * weight); - return this; - } - - RunningStats removeValue(double value, double weight) { - sumOfSqrs = Math.max(sumOfSqrs - value * value * weight, 0); - count = Math.max(count - weight, 0); - sum -= (value * weight); - return this; - } - - RunningStats removeValues(double[] value, IntToDoubleFunction weightFunction, int start, int end) { - for (int i = start; i < value.length && i < end; i++) { - removeValue(value[i], weightFunction.applyAsDouble(i)); - } - return this; - } - } - - static double fDistribSf(double numeratorDegreesOfFreedom, double denominatorDegreesOfFreedom, double x) { - if (x <= 0) { - return 1; - } - if (Double.isInfinite(x) || Double.isNaN(x)) { - return 0; - } - - return Beta.regularizedBeta( - denominatorDegreesOfFreedom / (denominatorDegreesOfFreedom + numeratorDegreesOfFreedom * x), - 0.5 * denominatorDegreesOfFreedom, - 0.5 * numeratorDegreesOfFreedom - ); - } } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointDetector.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointDetector.java new file mode 100644 index 000000000000..d7708420994b --- /dev/null +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointDetector.java @@ -0,0 +1,59 @@ +/* + * 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.xpack.ml.aggs.changepoint; + +import org.apache.commons.math3.exception.NotStrictlyPositiveException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.xpack.ml.aggs.MlAggsHelper; + +/** + * Detects whether a series of values has a change point, by running both + * ChangeDetector and SpikeAndDipDetector on it. This is the main entrypoint + * of change point detection. + */ +public class ChangePointDetector { + + private static final Logger logger = LogManager.getLogger(ChangePointDetector.class); + + static final double P_VALUE_THRESHOLD = 0.01; + static final int MINIMUM_BUCKETS = 10; + + /** + * Returns the ChangeType of a series of values. + */ + public static ChangeType getChangeType(MlAggsHelper.DoubleBucketValues bucketValues) { + if (bucketValues.getValues().length < (2 * MINIMUM_BUCKETS) + 2) { + return new ChangeType.Indeterminable( + "not enough buckets to calculate change_point. Requires at least [" + + ((2 * MINIMUM_BUCKETS) + 2) + + "]; found [" + + bucketValues.getValues().length + + "]" + ); + } + + ChangeType spikeOrDip; + try { + SpikeAndDipDetector detect = new SpikeAndDipDetector(bucketValues); + spikeOrDip = detect.detect(P_VALUE_THRESHOLD); + logger.trace("spike or dip p-value: [{}]", spikeOrDip.pValue()); + } catch (NotStrictlyPositiveException nspe) { + logger.debug("failure testing for dips and spikes", nspe); + spikeOrDip = new ChangeType.Indeterminable("failure testing for dips and spikes"); + } + + ChangeType change = new ChangeDetector(bucketValues).detect(P_VALUE_THRESHOLD); + logger.trace("change p-value: [{}]", change.pValue()); + + if (spikeOrDip.pValue() < change.pValue()) { + change = spikeOrDip; + } + return change; + } +} diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetector.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetector.java index b628ea3324cf..365ebe8562d6 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetector.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetector.java @@ -92,6 +92,7 @@ final class SpikeAndDipDetector { return newValues; } + private final MlAggsHelper.DoubleBucketValues bucketValues; private final int numValues; private final int dipIndex; private final int spikeIndex; @@ -100,7 +101,9 @@ final class SpikeAndDipDetector { private final KDE spikeTestKDE; private final KDE dipTestKDE; - SpikeAndDipDetector(double[] values) { + SpikeAndDipDetector(MlAggsHelper.DoubleBucketValues bucketValues) { + this.bucketValues = bucketValues; + double[] values = bucketValues.getValues(); numValues = values.length; @@ -135,7 +138,7 @@ final class SpikeAndDipDetector { spikeTestKDE = new KDE(spikeKDEValues, 1.36); } - ChangeType at(double pValueThreshold, MlAggsHelper.DoubleBucketValues bucketValues) { + ChangeType detect(double pValueThreshold) { if (dipIndex == -1 || spikeIndex == -1) { return new ChangeType.Indeterminable( "not enough buckets to check for dip or spike. Requires at least [3]; found [" + numValues + "]" diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetectorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetectorTests.java new file mode 100644 index 000000000000..75f668a96e77 --- /dev/null +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangeDetectorTests.java @@ -0,0 +1,246 @@ +/* + * 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.xpack.ml.aggs.changepoint; + +import org.apache.commons.math3.distribution.GammaDistribution; +import org.apache.commons.math3.distribution.NormalDistribution; +import org.apache.commons.math3.random.RandomGeneratorFactory; +import org.elasticsearch.common.Randomness; +import org.elasticsearch.search.aggregations.AggregatorTestCase; +import org.elasticsearch.xpack.ml.aggs.MlAggsHelper; + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.DoubleStream; + +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.lessThan; + +public class ChangeDetectorTests extends AggregatorTestCase { + + public void testStationaryFalsePositiveRate() { + NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); + int fp = 0; + for (int i = 0; i < 100; i++) { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.generate(() -> 10 + normal.sample()).limit(40).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(1e-4); + fp += type instanceof ChangeType.Stationary ? 0 : 1; + } + assertThat(fp, lessThan(10)); + + fp = 0; + GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); + for (int i = 0; i < 100; i++) { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.generate(gamma::sample).limit(40).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(1e-4); + fp += type instanceof ChangeType.Stationary ? 0 : 1; + } + assertThat(fp, lessThan(10)); + } + + public void testSampledDistributionTestFalsePositiveRate() { + NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0.0, 1.0); + int fp = 0; + for (int i = 0; i < 100; i++) { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.generate(() -> 10 + normal.sample()).limit(5000).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(1e-4); + fp += type instanceof ChangeType.Stationary ? 0 : 1; + } + assertThat(fp, lessThan(10)); + } + + public void testNonStationaryFalsePositiveRate() { + NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); + int fp = 0; + for (int i = 0; i < 100; i++) { + AtomicInteger j = new AtomicInteger(); + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.generate(() -> j.incrementAndGet() + normal.sample()).limit(40).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(1e-4); + fp += type instanceof ChangeType.NonStationary ? 0 : 1; + } + assertThat(fp, lessThan(10)); + + fp = 0; + GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); + for (int i = 0; i < 100; i++) { + AtomicInteger j = new AtomicInteger(); + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.generate(() -> j.incrementAndGet() + gamma.sample()).limit(40).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(1e-4); + fp += type instanceof ChangeType.NonStationary ? 0 : 1; + } + assertThat(fp, lessThan(10)); + } + + public void testStepChangePower() { + NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); + int tp = 0; + for (int i = 0; i < 100; i++) { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.concat( + DoubleStream.generate(() -> normal.sample()).limit(20), + DoubleStream.generate(() -> 10 + normal.sample()).limit(20) + ).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(0.05); + tp += type instanceof ChangeType.StepChange ? 1 : 0; + } + assertThat(tp, greaterThan(80)); + + tp = 0; + GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); + for (int i = 0; i < 100; i++) { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.concat( + DoubleStream.generate(() -> gamma.sample()).limit(20), + DoubleStream.generate(() -> 10 + gamma.sample()).limit(20) + ).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(0.05); + tp += type instanceof ChangeType.StepChange ? 1 : 0; + } + assertThat(tp, greaterThan(80)); + } + + public void testTrendChangePower() { + NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); + int tp = 0; + for (int i = 0; i < 100; i++) { + AtomicInteger j = new AtomicInteger(); + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.concat( + DoubleStream.generate(() -> j.incrementAndGet() + normal.sample()).limit(20), + DoubleStream.generate(() -> 2.0 * j.incrementAndGet() + normal.sample()).limit(20) + ).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(0.05); + tp += type instanceof ChangeType.TrendChange ? 1 : 0; + } + assertThat(tp, greaterThan(80)); + + tp = 0; + GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); + for (int i = 0; i < 100; i++) { + AtomicInteger j = new AtomicInteger(); + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.concat( + DoubleStream.generate(() -> j.incrementAndGet() + gamma.sample()).limit(20), + DoubleStream.generate(() -> 2.0 * j.incrementAndGet() + gamma.sample()).limit(20) + ).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(0.05); + tp += type instanceof ChangeType.TrendChange ? 1 : 0; + } + assertThat(tp, greaterThan(80)); + } + + public void testDistributionChangeTestPower() { + NormalDistribution normal1 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0.0, 1.0); + NormalDistribution normal2 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0.0, 10.0); + int tp = 0; + for (int i = 0; i < 100; i++) { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.concat( + DoubleStream.generate(() -> 10 + normal1.sample()).limit(50), + DoubleStream.generate(() -> 10 + normal2.sample()).limit(50) + ).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(0.05); + tp += type instanceof ChangeType.DistributionChange ? 1 : 0; + } + assertThat(tp, greaterThan(90)); + } + + public void testMultipleChanges() { + NormalDistribution normal1 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 78.0, 3.0); + NormalDistribution normal2 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 40.0, 6.0); + NormalDistribution normal3 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1.0, 0.3); + int tp = 0; + for (int i = 0; i < 100; i++) { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + DoubleStream.concat( + DoubleStream.concat(DoubleStream.generate(normal1::sample).limit(7), DoubleStream.generate(normal2::sample).limit(6)), + DoubleStream.generate(normal3::sample).limit(23) + ).toArray() + ); + ChangeType type = new ChangeDetector(bucketValues).detect(0.05); + tp += type instanceof ChangeType.TrendChange ? 1 : 0; + } + assertThat(tp, greaterThan(90)); + } + + public void testProblemDistributionChange() { + MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues( + null, + new double[] { + 546.3651753325270, + 550.872738079514, + 551.1312487618040, + 550.3323904749380, + 549.2652495378930, + 548.9761274963630, + 549.3433969743010, + 549.0935313531350, + 551.1762550747600, + 551.3772184469220, + 548.6163495094490, + 548.5866591594080, + 546.9364791288570, + 548.1167839989470, + 549.3484016149320, + 550.4242803917040, + 551.2316023050940, + 548.4713993534340, + 546.0254901960780, + 548.4376996805110, + 561.1920529801320, + 557.3930041152260, + 565.8497217068650, + 566.787072243346, + 546.6094890510950, + 530.5905797101450, + 556.7340823970040, + 557.3857677902620, + 543.0754716981130, + 574.3297101449280, + 559.2962962962960, + 549.5202952029520, + 531.7217741935480, + 551.4333333333330, + 557.637168141593, + 545.1880733944950, + 564.6893203883500, + 543.0204081632650, + 571.820809248555, + 541.2589928057550, + 520.4387755102040 } + ); + ChangeType type = new ChangeDetector(bucketValues).detect(0.05); + assertThat(type, instanceOf(ChangeType.DistributionChange.class)); + } +} diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregatorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregatorTests.java index 73131efbbcf4..5cb66aaa5a58 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregatorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/ChangePointAggregatorTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.ml.aggs.changepoint; -import org.apache.commons.math3.distribution.GammaDistribution; import org.apache.commons.math3.distribution.NormalDistribution; import org.apache.commons.math3.random.RandomGeneratorFactory; import org.apache.logging.log4j.LogManager; @@ -37,10 +36,7 @@ import java.util.stream.DoubleStream; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; public class ChangePointAggregatorTests extends AggregatorTestCase { @@ -55,194 +51,6 @@ public class ChangePointAggregatorTests extends AggregatorTestCase { private static final String NUMERIC_FIELD_NAME = "value"; private static final String TIME_FIELD_NAME = "timestamp"; - public void testStationaryFalsePositiveRate() throws IOException { - NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); - int fp = 0; - for (int i = 0; i < 100; i++) { - double[] bucketValues = DoubleStream.generate(() -> 10 + normal.sample()).limit(40).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 1e-4); - fp += test.type() == ChangePointAggregator.Type.STATIONARY ? 0 : 1; - } - assertThat(fp, lessThan(10)); - - fp = 0; - GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); - for (int i = 0; i < 100; i++) { - double[] bucketValues = DoubleStream.generate(() -> gamma.sample()).limit(40).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 1e-4); - fp += test.type() == ChangePointAggregator.Type.STATIONARY ? 0 : 1; - } - assertThat(fp, lessThan(10)); - } - - public void testSampledDistributionTestFalsePositiveRate() throws IOException { - NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0.0, 1.0); - int fp = 0; - for (int i = 0; i < 100; i++) { - double[] bucketValues = DoubleStream.generate(() -> 10 + normal.sample()).limit(5000).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 1e-4); - fp += test.type() == ChangePointAggregator.Type.STATIONARY ? 0 : 1; - } - assertThat(fp, lessThan(10)); - } - - public void testNonStationaryFalsePositiveRate() throws IOException { - NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); - int fp = 0; - for (int i = 0; i < 100; i++) { - AtomicInteger j = new AtomicInteger(); - double[] bucketValues = DoubleStream.generate(() -> j.incrementAndGet() + normal.sample()).limit(40).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 1e-4); - fp += test.type() == ChangePointAggregator.Type.NON_STATIONARY ? 0 : 1; - } - assertThat(fp, lessThan(10)); - - fp = 0; - GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); - for (int i = 0; i < 100; i++) { - AtomicInteger j = new AtomicInteger(); - double[] bucketValues = DoubleStream.generate(() -> j.incrementAndGet() + gamma.sample()).limit(40).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 1e-4); - fp += test.type() == ChangePointAggregator.Type.NON_STATIONARY ? 0 : 1; - } - assertThat(fp, lessThan(10)); - } - - public void testStepChangePower() throws IOException { - NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); - int tp = 0; - for (int i = 0; i < 100; i++) { - double[] bucketValues = DoubleStream.concat( - DoubleStream.generate(() -> normal.sample()).limit(20), - DoubleStream.generate(() -> 10 + normal.sample()).limit(20) - ).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 0.05); - tp += test.type() == ChangePointAggregator.Type.STEP_CHANGE ? 1 : 0; - } - assertThat(tp, greaterThan(80)); - - tp = 0; - GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); - for (int i = 0; i < 100; i++) { - double[] bucketValues = DoubleStream.concat( - DoubleStream.generate(() -> gamma.sample()).limit(20), - DoubleStream.generate(() -> 10 + gamma.sample()).limit(20) - ).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 0.05); - tp += test.type() == ChangePointAggregator.Type.STEP_CHANGE ? 1 : 0; - } - assertThat(tp, greaterThan(80)); - } - - public void testTrendChangePower() throws IOException { - NormalDistribution normal = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0, 2); - int tp = 0; - for (int i = 0; i < 100; i++) { - AtomicInteger j = new AtomicInteger(); - double[] bucketValues = DoubleStream.concat( - DoubleStream.generate(() -> j.incrementAndGet() + normal.sample()).limit(20), - DoubleStream.generate(() -> 2.0 * j.incrementAndGet() + normal.sample()).limit(20) - ).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 0.05); - tp += test.type() == ChangePointAggregator.Type.TREND_CHANGE ? 1 : 0; - } - assertThat(tp, greaterThan(80)); - - tp = 0; - GammaDistribution gamma = new GammaDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1, 2); - for (int i = 0; i < 100; i++) { - AtomicInteger j = new AtomicInteger(); - double[] bucketValues = DoubleStream.concat( - DoubleStream.generate(() -> j.incrementAndGet() + gamma.sample()).limit(20), - DoubleStream.generate(() -> 2.0 * j.incrementAndGet() + gamma.sample()).limit(20) - ).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 0.05); - tp += test.type() == ChangePointAggregator.Type.TREND_CHANGE ? 1 : 0; - } - assertThat(tp, greaterThan(80)); - } - - public void testDistributionChangeTestPower() throws IOException { - NormalDistribution normal1 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0.0, 1.0); - NormalDistribution normal2 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 0.0, 10.0); - int tp = 0; - for (int i = 0; i < 100; i++) { - double[] bucketValues = DoubleStream.concat( - DoubleStream.generate(() -> 10 + normal1.sample()).limit(50), - DoubleStream.generate(() -> 10 + normal2.sample()).limit(50) - ).toArray(); - ChangePointAggregator.TestStats test = ChangePointAggregator.testForChange(bucketValues, 0.05); - tp += test.type() == ChangePointAggregator.Type.DISTRIBUTION_CHANGE ? 1 : 0; - } - assertThat(tp, greaterThan(90)); - } - - public void testMultipleChanges() throws IOException { - NormalDistribution normal1 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 78.0, 3.0); - NormalDistribution normal2 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 40.0, 6.0); - NormalDistribution normal3 = new NormalDistribution(RandomGeneratorFactory.createRandomGenerator(Randomness.get()), 1.0, 0.3); - int tp = 0; - for (int i = 0; i < 100; i++) { - double[] bucketValues = DoubleStream.concat( - DoubleStream.concat( - DoubleStream.generate(() -> normal1.sample()).limit(7), - DoubleStream.generate(() -> normal2.sample()).limit(6) - ), - DoubleStream.generate(() -> normal3.sample()).limit(23) - ).toArray(); - ChangePointAggregator.TestStats result = ChangePointAggregator.testForChange(bucketValues, 0.05); - tp += result.type() == ChangePointAggregator.Type.TREND_CHANGE ? 1 : 0; - } - assertThat(tp, greaterThan(90)); - } - - public void testProblemDistributionChange() throws IOException { - double[] bucketValues = new double[] { - 546.3651753325270, - 550.872738079514, - 551.1312487618040, - 550.3323904749380, - 549.2652495378930, - 548.9761274963630, - 549.3433969743010, - 549.0935313531350, - 551.1762550747600, - 551.3772184469220, - 548.6163495094490, - 548.5866591594080, - 546.9364791288570, - 548.1167839989470, - 549.3484016149320, - 550.4242803917040, - 551.2316023050940, - 548.4713993534340, - 546.0254901960780, - 548.4376996805110, - 561.1920529801320, - 557.3930041152260, - 565.8497217068650, - 566.787072243346, - 546.6094890510950, - 530.5905797101450, - 556.7340823970040, - 557.3857677902620, - 543.0754716981130, - 574.3297101449280, - 559.2962962962960, - 549.5202952029520, - 531.7217741935480, - 551.4333333333330, - 557.637168141593, - 545.1880733944950, - 564.6893203883500, - 543.0204081632650, - 571.820809248555, - 541.2589928057550, - 520.4387755102040 }; - ChangePointAggregator.TestStats result = ChangePointAggregator.testForChange(bucketValues, 0.05); - assertThat(result.type(), equalTo(ChangePointAggregator.Type.DISTRIBUTION_CHANGE)); - } - public void testConstant() throws IOException { double[] bucketValues = DoubleStream.generate(() -> 10).limit(100).toArray(); testChangeType( @@ -262,7 +70,6 @@ public class ChangePointAggregatorTests extends AggregatorTestCase { // Handle infrequent false positives. assertThat(changeType, instanceOf(ChangeType.TrendChange.class)); } - }); } @@ -600,5 +407,4 @@ public class ChangePointAggregatorTests extends AggregatorTestCase { epoch_timestamp += INTERVAL.estimateMillis(); } } - } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetectorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetectorTests.java index fe91aa3e6a60..b21a7c4625e8 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetectorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/aggs/changepoint/SpikeAndDipDetectorTests.java @@ -25,14 +25,14 @@ public class SpikeAndDipDetectorTests extends ESTestCase { Arrays.fill(docCounts, 1); Arrays.fill(values, 1.0); MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues(docCounts, values); - SpikeAndDipDetector detect = new SpikeAndDipDetector(values); - assertThat(detect.at(0.01, bucketValues), instanceOf(ChangeType.Indeterminable.class)); + SpikeAndDipDetector detect = new SpikeAndDipDetector(bucketValues); + assertThat(detect.detect(0.01), instanceOf(ChangeType.Indeterminable.class)); } } public void testSpikeAndDipValues() { double[] values = new double[] { 2.0, 1.0, 3.0, 5.0, 4.0 }; - SpikeAndDipDetector detector = new SpikeAndDipDetector(values); + SpikeAndDipDetector detector = new SpikeAndDipDetector(new MlAggsHelper.DoubleBucketValues(null, values)); assertThat(detector.spikeValue(), equalTo(5.0)); assertThat(detector.dipValue(), equalTo(1.0)); } @@ -133,7 +133,7 @@ public class SpikeAndDipDetectorTests extends ESTestCase { Arrays.sort(expectedSpikeKDEValues); Arrays.sort(expectedDipKDEValues); - SpikeAndDipDetector detector = new SpikeAndDipDetector(values); + SpikeAndDipDetector detector = new SpikeAndDipDetector(new MlAggsHelper.DoubleBucketValues(null, values)); assertThat(detector.spikeValue(), equalTo(10.0)); assertThat(detector.dipValue(), equalTo(-2.0)); @@ -150,9 +150,9 @@ public class SpikeAndDipDetectorTests extends ESTestCase { double[] values = new double[] { 0.1, 3.1, 1.2, 1.7, 0.9, 2.3, -0.8, 3.2, 1.2, 1.3, 1.1, 1.0, 8.5, 0.5, 2.6, 0.7 }; MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues(docCounts, values); - SpikeAndDipDetector detect = new SpikeAndDipDetector(values); + SpikeAndDipDetector detect = new SpikeAndDipDetector(bucketValues); - ChangeType change = detect.at(0.05, bucketValues); + ChangeType change = detect.detect(0.05); assertThat(change, instanceOf(ChangeType.Spike.class)); assertThat(change.pValue(), closeTo(3.0465e-12, 1e-15)); @@ -162,9 +162,9 @@ public class SpikeAndDipDetectorTests extends ESTestCase { double[] values = new double[] { 0.1, 3.1, 1.2, 1.7, 0.9, 2.3, -4.2, 3.2, 1.2, 1.3, 1.1, 1.0, 3.5, 0.5, 2.6, 0.7 }; MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues(docCounts, values); - SpikeAndDipDetector detect = new SpikeAndDipDetector(values); + SpikeAndDipDetector detect = new SpikeAndDipDetector(bucketValues); - ChangeType change = detect.at(0.05, bucketValues); + ChangeType change = detect.detect(0.05); assertThat(change, instanceOf(ChangeType.Dip.class)); assertThat(change.pValue(), closeTo(1.2589e-08, 1e-11)); @@ -177,9 +177,9 @@ public class SpikeAndDipDetectorTests extends ESTestCase { int[] buckets = new int[] { 0, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20 }; MlAggsHelper.DoubleBucketValues bucketValues = new MlAggsHelper.DoubleBucketValues(docCounts, values, buckets); - SpikeAndDipDetector detect = new SpikeAndDipDetector(values); + SpikeAndDipDetector detect = new SpikeAndDipDetector(bucketValues); - ChangeType change = detect.at(0.01, bucketValues); + ChangeType change = detect.detect(0.01); assertThat(change, instanceOf(ChangeType.Spike.class)); assertThat(change.changePoint(), equalTo(10)); From 73c69b53209aa9fbf0b120535cfb7e02fbba4596 Mon Sep 17 00:00:00 2001 From: Carlos Delgado <6339205+carlosdelest@users.noreply.github.com> Date: Thu, 10 Oct 2024 10:40:36 +0200 Subject: [PATCH 32/43] Fix synonyms CI tests timeout (#114476) * Use synonym index alias, add timeout * Unmute tests --- muted-tests.yml | 9 --------- .../rest-api-spec/test/synonyms/60_synonym_rule_get.yml | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 18e179c0c063..4185af139bb6 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -351,15 +351,6 @@ tests: - class: org.elasticsearch.xpack.inference.services.cohere.CohereServiceTests method: testInfer_StreamRequest issue: https://github.com/elastic/elasticsearch/issues/114385 -- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT - method: test {p0=synonyms/60_synonym_rule_get/Synonym set not found} - issue: https://github.com/elastic/elasticsearch/issues/114432 -- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT - method: test {p0=synonyms/60_synonym_rule_get/Get a synonym rule} - issue: https://github.com/elastic/elasticsearch/issues/114443 -- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT - method: test {p0=synonyms/60_synonym_rule_get/Synonym rule not found} - issue: https://github.com/elastic/elasticsearch/issues/114444 - class: org.elasticsearch.xpack.inference.InferenceRestIT method: test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint} issue: https://github.com/elastic/elasticsearch/issues/114412 diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/60_synonym_rule_get.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/60_synonym_rule_get.yml index 0a4a32448666..2a7c8aff89d8 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/60_synonym_rule_get.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/60_synonym_rule_get.yml @@ -15,7 +15,8 @@ setup: id: "test-id-3" - do: cluster.health: - index: .synonyms-2 + index: .synonyms + timeout: 1m wait_for_status: green --- From 0d032074771f5b434bb6158bbc435ceeeac7bea3 Mon Sep 17 00:00:00 2001 From: Mary Gouseti Date: Thu, 10 Oct 2024 11:45:46 +0300 Subject: [PATCH 33/43] Clean up factory retention settings from elasticsearch (#114396) This removes the possibility for a plugin to provide factory retention settings. Factory retention settings have been deprecated and completely replaced by #111972. Note: this feature is not in use. If someone wants to set global retention they can use the cluster settings as defined in #111972. --- .../MetadataIndexTemplateServiceTests.java | 6 +- .../TransportGetDataStreamsActionTests.java | 7 +- .../DataStreamLifecycleServiceTests.java | 4 +- server/src/main/java/module-info.java | 1 - .../metadata/DataStreamFactoryRetention.java | 79 ------------------- .../DataStreamGlobalRetentionSettings.java | 21 ++--- .../elasticsearch/node/NodeConstruction.java | 4 +- ...vedComposableIndexTemplateActionTests.java | 6 +- ...ataStreamGlobalRetentionSettingsTests.java | 41 +--------- ...amLifecycleWithRetentionWarningsTests.java | 10 +-- .../MetadataDataStreamsServiceTests.java | 5 +- .../MetadataIndexTemplateServiceTests.java | 10 +-- 12 files changed, 21 insertions(+), 173 deletions(-) delete mode 100644 server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/MetadataIndexTemplateServiceTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/MetadataIndexTemplateServiceTests.java index 199611d6b85e..29e49c8ddfa1 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/MetadataIndexTemplateServiceTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/MetadataIndexTemplateServiceTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.action.downsample.DownsampleConfig; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.metadata.DataStreamFactoryRetention; import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionSettings; import org.elasticsearch.cluster.metadata.DataStreamLifecycle; import org.elasticsearch.cluster.metadata.MetadataCreateIndexService; @@ -217,10 +216,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase { xContentRegistry(), EmptySystemIndices.INSTANCE, indexSettingProviders, - DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() - ) + DataStreamGlobalRetentionSettings.create(ClusterSettings.createBuiltInClusterSettings()) ); } diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/action/TransportGetDataStreamsActionTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/action/TransportGetDataStreamsActionTests.java index a9ebd04d30f7..2efe881266c1 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/action/TransportGetDataStreamsActionTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/action/TransportGetDataStreamsActionTests.java @@ -12,7 +12,6 @@ import org.elasticsearch.action.datastreams.GetDataStreamAction; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.DataStream; -import org.elasticsearch.cluster.metadata.DataStreamFactoryRetention; import org.elasticsearch.cluster.metadata.DataStreamGlobalRetention; import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionSettings; import org.elasticsearch.cluster.metadata.DataStreamTestHelper; @@ -47,8 +46,7 @@ public class TransportGetDataStreamsActionTests extends ESTestCase { private final IndexNameExpressionResolver resolver = TestIndexNameExpressionResolver.newInstance(); private final SystemIndices systemIndices = new SystemIndices(List.of()); private final DataStreamGlobalRetentionSettings dataStreamGlobalRetentionSettings = DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() + ClusterSettings.createBuiltInClusterSettings() ); public void testGetDataStream() { @@ -356,8 +354,7 @@ public class TransportGetDataStreamsActionTests extends ESTestCase { ) .put(DataStreamGlobalRetentionSettings.DATA_STREAMS_MAX_RETENTION_SETTING.getKey(), globalRetention.maxRetention()) .build() - ), - DataStreamFactoryRetention.emptyFactoryRetention() + ) ); response = TransportGetDataStreamsAction.innerOperation( state, diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java index 05128e164e86..0d5ce54c44b5 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java @@ -37,7 +37,6 @@ import org.elasticsearch.cluster.TestShardRoutingRoleStrategies; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.DataStream; -import org.elasticsearch.cluster.metadata.DataStreamFactoryRetention; import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionSettings; import org.elasticsearch.cluster.metadata.DataStreamLifecycle; import org.elasticsearch.cluster.metadata.DataStreamLifecycle.Downsampling; @@ -142,8 +141,7 @@ public class DataStreamLifecycleServiceTests extends ESTestCase { private DoExecuteDelegate clientDelegate; private ClusterService clusterService; private final DataStreamGlobalRetentionSettings globalRetentionSettings = DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() + ClusterSettings.createBuiltInClusterSettings() ); @Before diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index 11965abf1dcd..70b748c86ec9 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -416,7 +416,6 @@ module org.elasticsearch.server { uses org.elasticsearch.internal.BuildExtension; uses org.elasticsearch.features.FeatureSpecification; uses org.elasticsearch.plugins.internal.LoggingDataProvider; - uses org.elasticsearch.cluster.metadata.DataStreamFactoryRetention; provides org.elasticsearch.features.FeatureSpecification with diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java deleted file mode 100644 index 656c63889a79..000000000000 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamFactoryRetention.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -package org.elasticsearch.cluster.metadata; - -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.core.Nullable; -import org.elasticsearch.core.TimeValue; -import org.elasticsearch.plugins.PluginsService; - -/** - * Holds the factory retention configuration. Factory retention is the global retention configuration meant to be - * used if a user hasn't provided other retention configuration via {@link DataStreamGlobalRetention} metadata in the - * cluster state. - * @deprecated This interface is deprecated, please use {@link DataStreamGlobalRetentionSettings}. - */ -@Deprecated -public interface DataStreamFactoryRetention { - - @Nullable - TimeValue getMaxRetention(); - - @Nullable - TimeValue getDefaultRetention(); - - /** - * @return true, if at least one of the two settings is not null, false otherwise. - */ - default boolean isDefined() { - return getMaxRetention() != null || getDefaultRetention() != null; - } - - /** - * Applies any post constructor initialisation, for example, listening to cluster setting changes. - */ - void init(ClusterSettings clusterSettings); - - /** - * Loads a single instance of a DataStreamFactoryRetention from the {@link PluginsService} and finalises the - * initialisation by calling {@link DataStreamFactoryRetention#init(ClusterSettings)} - */ - static DataStreamFactoryRetention load(PluginsService pluginsService, ClusterSettings clusterSettings) { - DataStreamFactoryRetention factoryRetention = pluginsService.loadSingletonServiceProvider( - DataStreamFactoryRetention.class, - DataStreamFactoryRetention::emptyFactoryRetention - ); - factoryRetention.init(clusterSettings); - return factoryRetention; - } - - /** - * Returns empty factory global retention settings. - */ - static DataStreamFactoryRetention emptyFactoryRetention() { - return new DataStreamFactoryRetention() { - - @Override - public TimeValue getMaxRetention() { - return null; - } - - @Override - public TimeValue getDefaultRetention() { - return null; - } - - @Override - public void init(ClusterSettings clusterSettings) { - - } - }; - } -} diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettings.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettings.java index fd4df18551c3..9e7256d6818b 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettings.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettings.java @@ -26,8 +26,6 @@ import java.util.Map; * The global retention settings apply to non-system data streams that are managed by the data stream lifecycle. They consist of: * - The default retention which applies to data streams that do not have a retention defined. * - The max retention which applies to all data streams that do not have retention or their retention has exceeded this value. - *

    - * Temporarily, we fall back to {@link DataStreamFactoryRetention} to facilitate a smooth transition to these settings. */ public class DataStreamGlobalRetentionSettings { @@ -84,42 +82,35 @@ public class DataStreamGlobalRetentionSettings { Setting.Property.Dynamic ); - private final DataStreamFactoryRetention factoryRetention; - @Nullable private volatile TimeValue defaultRetention; @Nullable private volatile TimeValue maxRetention; - private DataStreamGlobalRetentionSettings(DataStreamFactoryRetention factoryRetention) { - this.factoryRetention = factoryRetention; + private DataStreamGlobalRetentionSettings() { + } @Nullable public TimeValue getMaxRetention() { - return shouldFallbackToFactorySettings() ? factoryRetention.getMaxRetention() : maxRetention; + return maxRetention; } @Nullable public TimeValue getDefaultRetention() { - return shouldFallbackToFactorySettings() ? factoryRetention.getDefaultRetention() : defaultRetention; + return defaultRetention; } public boolean areDefined() { return getDefaultRetention() != null || getMaxRetention() != null; } - private boolean shouldFallbackToFactorySettings() { - return defaultRetention == null && maxRetention == null; - } - /** * Creates an instance and initialises the cluster settings listeners * @param clusterSettings it will register the cluster settings listeners to monitor for changes - * @param factoryRetention for migration purposes, it will be removed shortly */ - public static DataStreamGlobalRetentionSettings create(ClusterSettings clusterSettings, DataStreamFactoryRetention factoryRetention) { - DataStreamGlobalRetentionSettings dataStreamGlobalRetentionSettings = new DataStreamGlobalRetentionSettings(factoryRetention); + public static DataStreamGlobalRetentionSettings create(ClusterSettings clusterSettings) { + DataStreamGlobalRetentionSettings dataStreamGlobalRetentionSettings = new DataStreamGlobalRetentionSettings(); clusterSettings.initializeAndWatch(DATA_STREAMS_DEFAULT_RETENTION_SETTING, dataStreamGlobalRetentionSettings::setDefaultRetention); clusterSettings.initializeAndWatch(DATA_STREAMS_MAX_RETENTION_SETTING, dataStreamGlobalRetentionSettings::setMaxRetention); return dataStreamGlobalRetentionSettings; diff --git a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java index 16b180a82acc..16dcdf00fbbe 100644 --- a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java +++ b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java @@ -44,7 +44,6 @@ import org.elasticsearch.cluster.coordination.Coordinator; import org.elasticsearch.cluster.coordination.MasterHistoryService; import org.elasticsearch.cluster.coordination.StableMasterHealthIndicatorService; import org.elasticsearch.cluster.features.NodeFeaturesFixupListener; -import org.elasticsearch.cluster.metadata.DataStreamFactoryRetention; import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionSettings; import org.elasticsearch.cluster.metadata.IndexMetadataVerifier; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -621,8 +620,7 @@ class NodeConstruction { MetadataCreateIndexService metadataCreateIndexService ) { DataStreamGlobalRetentionSettings dataStreamGlobalRetentionSettings = DataStreamGlobalRetentionSettings.create( - clusterService.getClusterSettings(), - DataStreamFactoryRetention.load(pluginsService, clusterService.getClusterSettings()) + clusterService.getClusterSettings() ); modules.bindToInstance(DataStreamGlobalRetentionSettings.class, dataStreamGlobalRetentionSettings); modules.bindToInstance( diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/template/reservedstate/ReservedComposableIndexTemplateActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/template/reservedstate/ReservedComposableIndexTemplateActionTests.java index f0f4e37f31c1..3e49cbe774ee 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/template/reservedstate/ReservedComposableIndexTemplateActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/template/reservedstate/ReservedComposableIndexTemplateActionTests.java @@ -18,7 +18,6 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.metadata.DataStreamFactoryRetention; import org.elasticsearch.cluster.metadata.DataStreamGlobalRetentionSettings; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; @@ -94,10 +93,7 @@ public class ReservedComposableIndexTemplateActionTests extends ESTestCase { doReturn(mapperService).when(indexService).mapperService(); doReturn(indexService).when(indicesService).createIndex(any(), any(), anyBoolean()); - globalRetentionSettings = DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() - ); + globalRetentionSettings = DataStreamGlobalRetentionSettings.create(ClusterSettings.createBuiltInClusterSettings()); templateService = new MetadataIndexTemplateService( clusterService, mock(MetadataCreateIndexService.class), diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettingsTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettingsTests.java index 9de653d29e68..17fa520ad1c4 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamGlobalRetentionSettingsTests.java @@ -22,46 +22,16 @@ public class DataStreamGlobalRetentionSettingsTests extends ESTestCase { public void testDefaults() { DataStreamGlobalRetentionSettings globalRetentionSettings = DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() + ClusterSettings.createBuiltInClusterSettings() ); assertThat(globalRetentionSettings.getDefaultRetention(), nullValue()); assertThat(globalRetentionSettings.getMaxRetention(), nullValue()); - - // Fallback to factory settings - TimeValue maxFactoryValue = randomPositiveTimeValue(); - TimeValue defaultFactoryValue = randomPositiveTimeValue(); - DataStreamGlobalRetentionSettings withFactorySettings = DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - new DataStreamFactoryRetention() { - @Override - public TimeValue getMaxRetention() { - return maxFactoryValue; - } - - @Override - public TimeValue getDefaultRetention() { - return defaultFactoryValue; - } - - @Override - public void init(ClusterSettings clusterSettings) { - - } - } - ); - - assertThat(withFactorySettings.getDefaultRetention(), equalTo(defaultFactoryValue)); - assertThat(withFactorySettings.getMaxRetention(), equalTo(maxFactoryValue)); } public void testMonitorsDefaultRetention() { ClusterSettings clusterSettings = ClusterSettings.createBuiltInClusterSettings(); - DataStreamGlobalRetentionSettings globalRetentionSettings = DataStreamGlobalRetentionSettings.create( - clusterSettings, - DataStreamFactoryRetention.emptyFactoryRetention() - ); + DataStreamGlobalRetentionSettings globalRetentionSettings = DataStreamGlobalRetentionSettings.create(clusterSettings); // Test valid update TimeValue newDefaultRetention = TimeValue.timeValueDays(randomIntBetween(1, 10)); @@ -91,10 +61,7 @@ public class DataStreamGlobalRetentionSettingsTests extends ESTestCase { public void testMonitorsMaxRetention() { ClusterSettings clusterSettings = ClusterSettings.createBuiltInClusterSettings(); - DataStreamGlobalRetentionSettings globalRetentionSettings = DataStreamGlobalRetentionSettings.create( - clusterSettings, - DataStreamFactoryRetention.emptyFactoryRetention() - ); + DataStreamGlobalRetentionSettings globalRetentionSettings = DataStreamGlobalRetentionSettings.create(clusterSettings); // Test valid update TimeValue newMaxRetention = TimeValue.timeValueDays(randomIntBetween(10, 30)); @@ -121,7 +88,7 @@ public class DataStreamGlobalRetentionSettingsTests extends ESTestCase { public void testCombinationValidation() { ClusterSettings clusterSettings = ClusterSettings.createBuiltInClusterSettings(); - DataStreamGlobalRetentionSettings.create(clusterSettings, DataStreamFactoryRetention.emptyFactoryRetention()); + DataStreamGlobalRetentionSettings.create(clusterSettings); // Test invalid update Settings newInvalidSettings = Settings.builder() diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java index d7f10f484165..27198f51ed97 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleWithRetentionWarningsTests.java @@ -141,10 +141,7 @@ public class DataStreamLifecycleWithRetentionWarningsTests extends ESTestCase { MetadataDataStreamsService metadataDataStreamsService = new MetadataDataStreamsService( mock(ClusterService.class), mock(IndicesService.class), - DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(settingsWithDefaultRetention), - DataStreamFactoryRetention.emptyFactoryRetention() - ) + DataStreamGlobalRetentionSettings.create(ClusterSettings.createBuiltInClusterSettings(settingsWithDefaultRetention)) ); ClusterState after = metadataDataStreamsService.updateDataLifecycle(before, List.of(dataStream), DataStreamLifecycle.DEFAULT); @@ -281,10 +278,7 @@ public class DataStreamLifecycleWithRetentionWarningsTests extends ESTestCase { xContentRegistry(), EmptySystemIndices.INSTANCE, new IndexSettingProviders(Set.of()), - DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(settingsWithDefaultRetention), - DataStreamFactoryRetention.emptyFactoryRetention() - ) + DataStreamGlobalRetentionSettings.create(ClusterSettings.createBuiltInClusterSettings(settingsWithDefaultRetention)) ); ThreadContext threadContext = new ThreadContext(Settings.EMPTY); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java index 6ef516f67014..92c1103c950c 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java @@ -402,10 +402,7 @@ public class MetadataDataStreamsServiceTests extends MapperServiceTestCase { MetadataDataStreamsService service = new MetadataDataStreamsService( mock(ClusterService.class), mock(IndicesService.class), - DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() - ) + DataStreamGlobalRetentionSettings.create(ClusterSettings.createBuiltInClusterSettings()) ); { // Remove lifecycle diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java index 8d4b04746e7a..873b185e6be2 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java @@ -2496,10 +2496,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase { xContentRegistry, EmptySystemIndices.INSTANCE, new IndexSettingProviders(Set.of()), - DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() - ) + DataStreamGlobalRetentionSettings.create(ClusterSettings.createBuiltInClusterSettings()) ); final List throwables = new ArrayList<>(); @@ -2563,10 +2560,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase { xContentRegistry(), EmptySystemIndices.INSTANCE, new IndexSettingProviders(Set.of()), - DataStreamGlobalRetentionSettings.create( - ClusterSettings.createBuiltInClusterSettings(), - DataStreamFactoryRetention.emptyFactoryRetention() - ) + DataStreamGlobalRetentionSettings.create(ClusterSettings.createBuiltInClusterSettings()) ); } From 5e6541cd59397c88f76e7ed36dee263dc369f526 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:52:08 +1100 Subject: [PATCH 34/43] Mute org.elasticsearch.packaging.test.DockerTests test022InstallPluginsFromLocalArchive #111063 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 4185af139bb6..64515166542f 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -365,6 +365,9 @@ tests: issue: https://github.com/elastic/elasticsearch/issues/114467 - class: org.elasticsearch.xpack.logsdb.LogsdbTestSuiteIT issue: https://github.com/elastic/elasticsearch/issues/114471 +- class: org.elasticsearch.packaging.test.DockerTests + method: test022InstallPluginsFromLocalArchive + issue: https://github.com/elastic/elasticsearch/issues/111063 # Examples: # From 4d6f1952f53b92bb941ff503816baa261447f099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Cea=20Fontenla?= Date: Thu, 10 Oct 2024 11:02:05 +0200 Subject: [PATCH 35/43] Reduce double and float precision requirements on rest CSV tests (#114313) Fixes https://github.com/elastic/elasticsearch-serverless/issues/2837 The failing value is `5.801464200000001`, which rounds to `5.8014642`. However, `5.8014642` is roudned to `5.801464199`. With a precision of 7, both are truncated to `5.801464`. Not the most elegant solution, but it works for this case, which may be a quite edgy one. --- .../elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java index 1543ba039dc6..319e67512c7a 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java @@ -279,9 +279,9 @@ public abstract class EsqlSpecTestCase extends ESRestTestCase { } return values; } else if (value instanceof Double d) { - return new BigDecimal(d).round(new MathContext(10, RoundingMode.DOWN)).doubleValue(); + return new BigDecimal(d).round(new MathContext(7, RoundingMode.DOWN)).doubleValue(); } else if (value instanceof String s) { - return new BigDecimal(s).round(new MathContext(10, RoundingMode.DOWN)).doubleValue(); + return new BigDecimal(s).round(new MathContext(7, RoundingMode.DOWN)).doubleValue(); } } return value.toString(); From 430ec3b1506c7d4223c4a24cfdb417ef726c1d87 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Thu, 10 Oct 2024 10:03:22 +0100 Subject: [PATCH 36/43] Fix standard retriever rewrite (#114480) Closes #114466 --- muted-tests.yml | 3 --- .../retriever/StandardRetrieverBuilder.java | 20 +++++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 64515166542f..a0db8f072d03 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -357,9 +357,6 @@ tests: - class: org.elasticsearch.xpack.inference.InferenceRestIT method: test {p0=inference/40_semantic_text_query/Query a field that uses the default ELSER 2 endpoint} issue: https://github.com/elastic/elasticsearch/issues/114376 -- class: org.elasticsearch.search.retriever.StandardRetrieverBuilderParsingTests - method: testRewrite - issue: https://github.com/elastic/elasticsearch/issues/114466 - class: org.elasticsearch.search.retriever.RankDocsRetrieverBuilderTests method: testRewrite issue: https://github.com/elastic/elasticsearch/issues/114467 diff --git a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java index 22439e5c996a..4e875a97fdfc 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java @@ -113,29 +113,29 @@ public final class StandardRetrieverBuilder extends RetrieverBuilder implements @Override public RetrieverBuilder rewrite(QueryRewriteContext ctx) throws IOException { boolean changed = false; - List> newSortBuilders = null; + List> rewrittenSortBuilders = null; if (sortBuilders != null) { - newSortBuilders = new ArrayList<>(sortBuilders.size()); + rewrittenSortBuilders = new ArrayList<>(sortBuilders.size()); for (var sort : sortBuilders) { var newSort = sort.rewrite(ctx); - newSortBuilders.add(newSort); - changed = newSort != sort; + rewrittenSortBuilders.add(newSort); + changed |= newSort != sort; } } var rewrittenFilters = rewritePreFilters(ctx); changed |= rewrittenFilters != preFilterQueryBuilders; - QueryBuilder queryBuilderRewrite = null; + QueryBuilder rewrittenQuery = null; if (queryBuilder != null) { - queryBuilderRewrite = queryBuilder.rewrite(ctx); - changed |= queryBuilderRewrite != queryBuilder; + rewrittenQuery = queryBuilder.rewrite(ctx); + changed |= rewrittenQuery != queryBuilder; } if (changed) { var rewritten = new StandardRetrieverBuilder(this); - rewritten.sortBuilders = newSortBuilders; - rewritten.preFilterQueryBuilders = preFilterQueryBuilders; - rewritten.queryBuilder = queryBuilderRewrite; + rewritten.sortBuilders = rewrittenSortBuilders; + rewritten.preFilterQueryBuilders = rewrittenFilters; + rewritten.queryBuilder = rewrittenQuery; return rewritten; } return this; From 0c3e52c11d836f8832e66aece55547c1e2acb962 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Thu, 10 Oct 2024 11:25:00 +0200 Subject: [PATCH 37/43] [Build] Add AGPL license to open source poms (#114403) Aftermath of coming back to open source licensing --- .../internal/conventions/GitInfoPlugin.java | 2 +- .../internal/conventions/LicensingPlugin.java | 10 +++++--- .../internal/PublishPluginFuncTest.groovy | 25 +++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java index 8a1e3cabf890..28b90714508b 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java @@ -44,7 +44,7 @@ class GitInfoPlugin implements Plugin { gitInfo.disallowChanges(); gitInfo.finalizeValueOnRead(); - revision = gitInfo.map(info -> info.getRevision() == null ? info.getRevision() : "master"); + revision = gitInfo.map(info -> info.getRevision() == null ? info.getRevision() : "main"); } public Property getGitInfo() { diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java index 92ce2a3658a0..ba170d083c88 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java @@ -21,6 +21,7 @@ import java.util.Map; public class LicensingPlugin implements Plugin { static final String ELASTIC_LICENSE_URL_PREFIX = "https://raw.githubusercontent.com/elastic/elasticsearch/"; static final String ELASTIC_LICENSE_URL_POSTFIX = "/licenses/ELASTIC-LICENSE-2.0.txt"; + static final String AGPL_ELASTIC_LICENSE_URL_POSTFIX = "/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt"; private ProviderFactory providerFactory; @@ -36,15 +37,18 @@ public class LicensingPlugin implements Plugin { isSnapshotVersion(project) ? revision.get() : "v" + project.getVersion() ); - Provider projectLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX + + Provider elasticLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX + licenseCommit + ELASTIC_LICENSE_URL_POSTFIX); + Provider agplLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX + + licenseCommit + AGPL_ELASTIC_LICENSE_URL_POSTFIX); // But stick the Elastic license url in project.ext so we can get it if we need to switch to it - project.getExtensions().getExtraProperties().set("elasticLicenseUrl", projectLicenseURL); + project.getExtensions().getExtraProperties().set("elasticLicenseUrl", elasticLicenseURL); MapProperty licensesProperty = project.getObjects().mapProperty(String.class, String.class).convention( providerFactory.provider(() -> Map.of( "Server Side Public License, v 1", "https://www.mongodb.com/licensing/server-side-public-license", - "Elastic License 2.0", projectLicenseURL.get()) + "Elastic License 2.0", elasticLicenseURL.get(), + "GNU Affero General Public License Version 3", agplLicenseURL.get()) ) ); diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy index e275a56682c0..c0b85ed7450f 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy @@ -74,6 +74,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { https://www.mongodb.com/licensing/server-side-public-license repo + + The OSI-approved Open Source license Version 3.0 + https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt + repo + @@ -149,6 +154,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { https://www.mongodb.com/licensing/server-side-public-license repo + + The OSI-approved Open Source license Version 3.0 + https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt + repo + @@ -233,6 +243,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { https://www.mongodb.com/licensing/server-side-public-license repo + + The OSI-approved Open Source license Version 3.0 + https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt + repo + @@ -326,6 +341,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { https://www.mongodb.com/licensing/server-side-public-license repo + + The OSI-approved Open Source license Version 3.0 + https://raw.githubusercontent.com/elastic/elasticsearch/v1.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt + repo + @@ -399,6 +419,11 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { https://www.mongodb.com/licensing/server-side-public-license repo + + The OSI-approved Open Source license Version 3.0 + https://raw.githubusercontent.com/elastic/elasticsearch/v2.0/licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt + repo + From cbd3613dbf6b1a3731090117f736cb1cec5e1967 Mon Sep 17 00:00:00 2001 From: Mark Hopkin Date: Thu, 10 Oct 2024 10:34:22 +0100 Subject: [PATCH 38/43] Give the kibana system user permission to read security entities (#114363) * Give the kibana system user .entities read permissions * Update docs/changelog/114363.yaml --------- Co-authored-by: Elastic Machine --- docs/changelog/114363.yaml | 5 +++++ .../authz/store/KibanaOwnedReservedRoleDescriptors.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 docs/changelog/114363.yaml diff --git a/docs/changelog/114363.yaml b/docs/changelog/114363.yaml new file mode 100644 index 000000000000..51ca9ed34a7c --- /dev/null +++ b/docs/changelog/114363.yaml @@ -0,0 +1,5 @@ +pr: 114363 +summary: Give the kibana system user permission to read security entities +area: Infra/Core +type: enhancement +issues: [] diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java index 6c28c6f3053a..0028508e87f3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java @@ -458,13 +458,13 @@ class KibanaOwnedReservedRoleDescriptors { TransportUpdateSettingsAction.TYPE.name() ) .build(), - + // security entity analytics indices RoleDescriptor.IndicesPrivileges.builder().indices("risk-score.risk-*").privileges("all").build(), RoleDescriptor.IndicesPrivileges.builder() .indices(".asset-criticality.asset-criticality-*") .privileges("create_index", "manage", "read", "write") .build(), - + RoleDescriptor.IndicesPrivileges.builder().indices(".entities.v1.latest.security*").privileges("read").build(), // For cloud_defend usageCollection RoleDescriptor.IndicesPrivileges.builder() .indices("logs-cloud_defend.*", "metrics-cloud_defend.*") From 69e63ab57f92e5d029a285b8805b68f83cc314f0 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:36:03 +1100 Subject: [PATCH 39/43] Mute org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT test {yaml=reference/esql/esql-across-clusters/line_196} #114488 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index a0db8f072d03..1f9d118aec5e 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -365,6 +365,9 @@ tests: - class: org.elasticsearch.packaging.test.DockerTests method: test022InstallPluginsFromLocalArchive issue: https://github.com/elastic/elasticsearch/issues/111063 +- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT + method: test {yaml=reference/esql/esql-across-clusters/line_196} + issue: https://github.com/elastic/elasticsearch/issues/114488 # Examples: # From 27ac1b4bf2106a6b0bc936c60d950d10a8dc14a9 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Thu, 10 Oct 2024 21:25:41 +1100 Subject: [PATCH 40/43] Mute org.elasticsearch.gradle.internal.PublishPluginFuncTest org.elasticsearch.gradle.internal.PublishPluginFuncTest #114492 --- muted-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index 1f9d118aec5e..7adc65d00240 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -368,6 +368,8 @@ tests: - class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT method: test {yaml=reference/esql/esql-across-clusters/line_196} issue: https://github.com/elastic/elasticsearch/issues/114488 +- class: org.elasticsearch.gradle.internal.PublishPluginFuncTest + issue: https://github.com/elastic/elasticsearch/issues/114492 # Examples: # From c27bc086770b12a71c335e5537318f54cce53a65 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 10 Oct 2024 21:25:58 +1100 Subject: [PATCH 41/43] Handle InternalSendException inline for non-forking handlers (#114375) When TransportService fails to send a transport action, it can complete the listener's `onFailure` with the `generic` executor. If the listener is a `PlainActionFuture` and also waits to be completed with a `generic` thread, it will trip the `assertCompleteAllowed` assertion. https://github.com/elastic/elasticsearch/blob/fb482f863d5430702b19bd3dd23e9d8652f12ddd/server/src/main/java/org/elasticsearch/transport/TransportService.java#L1062-L1064 With this PR, we no longer fork to the generic thread pool and instead just handle the exeption inline with the current thread. The expectation is that the downstream handler should take care potential stack overflow issues. This is similar to what is done in #109236 --- docs/changelog/114375.yaml | 5 +++ .../transport/TransportService.java | 5 +-- .../TransportServiceLifecycleTests.java | 36 +++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 docs/changelog/114375.yaml diff --git a/docs/changelog/114375.yaml b/docs/changelog/114375.yaml new file mode 100644 index 000000000000..7ff7cc60b34b --- /dev/null +++ b/docs/changelog/114375.yaml @@ -0,0 +1,5 @@ +pr: 114375 +summary: Handle `InternalSendException` inline for non-forking handlers +area: Distributed +type: bug +issues: [] diff --git a/server/src/main/java/org/elasticsearch/transport/TransportService.java b/server/src/main/java/org/elasticsearch/transport/TransportService.java index 27db07878850..0fb767c5789f 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportService.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportService.java @@ -1059,8 +1059,9 @@ public class TransportService extends AbstractLifecycleComponent if (lifecycle.stoppedOrClosed()) { // too late to try and dispatch anywhere else, let's just use the calling thread return EsExecutors.DIRECT_EXECUTOR_SERVICE; - } else if (handlerExecutor == EsExecutors.DIRECT_EXECUTOR_SERVICE) { - // if the handler is non-forking then dispatch to GENERIC to avoid a possible stack overflow + } else if (handlerExecutor == EsExecutors.DIRECT_EXECUTOR_SERVICE && enableStackOverflowAvoidance) { + // If the handler is non-forking and stack overflow protection is enabled then dispatch to GENERIC + // Otherwise we let the handler deal with any potential stack overflow (this is the default) return threadPool.generic(); } else { return handlerExecutor; diff --git a/server/src/test/java/org/elasticsearch/transport/TransportServiceLifecycleTests.java b/server/src/test/java/org/elasticsearch/transport/TransportServiceLifecycleTests.java index a4a6ef6c5c5f..b631eddc5173 100644 --- a/server/src/test/java/org/elasticsearch/transport/TransportServiceLifecycleTests.java +++ b/server/src/test/java/org/elasticsearch/transport/TransportServiceLifecycleTests.java @@ -149,8 +149,13 @@ public class TransportServiceLifecycleTests extends ESTestCase { } } - public void testInternalSendExceptionForksToGenericIfHandlerDoesNotFork() { - try (var nodeA = new TestNode("node-A")) { + public void testInternalSendExceptionForksToGenericIfHandlerDoesNotForkAndStackOverflowProtectionEnabled() { + try ( + var nodeA = new TestNode( + "node-A", + Settings.builder().put(TransportService.ENABLE_STACK_OVERFLOW_AVOIDANCE.getKey(), true).build() + ) + ) { final var future = new PlainActionFuture(); nodeA.transportService.sendRequest( nodeA.getThrowingConnection(), @@ -165,6 +170,33 @@ public class TransportServiceLifecycleTests extends ESTestCase { assertEquals("simulated exception in sendRequest", getSendRequestException(future, IOException.class).getMessage()); } + assertWarnings( + "[transport.enable_stack_protection] setting was deprecated in Elasticsearch and will be removed in a future release." + ); + } + + public void testInternalSendExceptionWithNonForkingResponseHandlerCompletesListenerInline() { + try (var nodeA = new TestNode("node-A")) { + final Thread callingThread = Thread.currentThread(); + assertEquals( + "simulated exception in sendRequest", + safeAwaitAndUnwrapFailure( + IOException.class, + TransportResponse.Empty.class, + l -> nodeA.transportService.sendRequest( + nodeA.getThrowingConnection(), + TestNode.randomActionName(random()), + new EmptyRequest(), + TransportRequestOptions.EMPTY, + new ActionListenerResponseHandler<>( + ActionListener.runBefore(l, () -> assertSame(callingThread, Thread.currentThread())), + unusedReader(), + EsExecutors.DIRECT_EXECUTOR_SERVICE + ) + ) + ).getMessage() + ); + } } public void testInternalSendExceptionForcesExecutionOnHandlerExecutor() { From 924205f605a021a05472d0007c441bbe9a0a02ee Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 10 Oct 2024 08:06:15 -0400 Subject: [PATCH 42/43] ESQL: Use less memory in listener (#114358) Use less memory in the top level listener by fetching the output attributes from the plan before starting rather than after finishing. The plan *can* be very large so let's not hold on to it longer than we have to. --- docs/changelog/114358.yaml | 5 +++++ .../elasticsearch/xpack/esql/plugin/ComputeService.java | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 docs/changelog/114358.yaml diff --git a/docs/changelog/114358.yaml b/docs/changelog/114358.yaml new file mode 100644 index 000000000000..972bc5bfdbe1 --- /dev/null +++ b/docs/changelog/114358.yaml @@ -0,0 +1,5 @@ +pr: 114358 +summary: "ESQL: Use less memory in listener" +area: ES|QL +type: enhancement +issues: [] diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java index 3ec39d1b0ac4..ce2a1d7a5f66 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java @@ -60,6 +60,7 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.esql.action.EsqlExecutionInfo; import org.elasticsearch.xpack.esql.action.EsqlQueryAction; import org.elasticsearch.xpack.esql.action.EsqlSearchShardsAction; +import org.elasticsearch.xpack.esql.core.expression.Attribute; import org.elasticsearch.xpack.esql.enrich.EnrichLookupService; import org.elasticsearch.xpack.esql.plan.physical.ExchangeSinkExec; import org.elasticsearch.xpack.esql.plan.physical.ExchangeSourceExec; @@ -206,13 +207,19 @@ public class ComputeService { ); long start = configuration.getQueryStartTimeNanos(); String local = RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY; + /* + * Grab the output attributes here, so we can pass them to + * the listener without holding on to a reference to the + * entire plan. + */ + List outputAttributes = physicalPlan.output(); try ( Releasable ignored = exchangeSource.addEmptySink(); // this is the top level ComputeListener called once at the end (e.g., once all clusters have finished for a CCS) var computeListener = ComputeListener.create(local, transportService, rootTask, execInfo, start, listener.map(r -> { long tookTimeNanos = System.nanoTime() - configuration.getQueryStartTimeNanos(); execInfo.overallTook(new TimeValue(tookTimeNanos, TimeUnit.NANOSECONDS)); - return new Result(physicalPlan.output(), collectedPages, r.getProfiles(), execInfo); + return new Result(outputAttributes, collectedPages, r.getProfiles(), execInfo); })) ) { // run compute on the coordinator From e2c314eec8bd7190a56f85c52342521491a5098e Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 10 Oct 2024 08:09:02 -0400 Subject: [PATCH 43/43] Speed up XPackRestIT a little (#114425) This speeds up all of the `profiling` tests in `XPackRestIT` by replacing a "wait for refresh" with a "refresh as fast as you can". It'll only be a few seconds of speed up, but it's something. While I'm here I'm reenabling one of our tests that doesn't seem to be causing the slow down. Closes #113340 --- .../resources/rest-api-spec/test/profiling/10_basic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml index 325e6ca8bda7..4a9212b8a715 100644 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml +++ b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/profiling/10_basic.yml @@ -29,7 +29,7 @@ setup: - do: bulk: - refresh: wait_for + refresh: true body: - {"create": {"_index": "profiling-events-all"}} - {"Stacktrace.count": [1], "profiling.project.id": ["100"], "os.kernel": ["9.9.9-0"], "tags": ["environment:qa", "region:eu-west-1"], "host.ip": ["192.168.1.2"], "@timestamp": ["1700504427"], "container.name": ["instance-0000000010"], "ecs.version": ["1.12.0"], "Stacktrace.id": ["S07KmaoGhvNte78xwwRbZQ"], "agent.version": ["head-be593ef3-1688111067"], "host.name": ["ip-192-168-1-2"], "host.id": ["8457605156473051743"], "process.thread.name": ["497295213074376"]}