From e851b303d07fa9bff034313e1f033ba6bd5c7987 Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Fri, 3 Nov 2023 13:57:47 +0000 Subject: [PATCH 01/14] Migrate desirednode processors version checks to features (#101706) --- .../upgrades/DesiredNodesUpgradeIT.java | 8 +++--- server/src/main/java/module-info.java | 1 + .../TransportUpdateDesiredNodesAction.java | 12 ++++++--- .../UpdateDesiredNodesRequest.java | 12 ++++----- .../cluster/metadata/DesiredNode.java | 15 ++++++----- .../cluster/metadata/MetadataFeatures.java | 27 +++++++++++++++++++ .../elasticsearch/common/unit/Processors.java | 13 +-------- ...lasticsearch.features.FeatureSpecification | 1 + ...ransportUpdateDesiredNodesActionTests.java | 3 +++ .../cluster/metadata/DesiredNodeTests.java | 14 +++++----- 10 files changed, 66 insertions(+), 40 deletions(-) create mode 100644 server/src/main/java/org/elasticsearch/cluster/metadata/MetadataFeatures.java diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java index 15fc1e68196e1..230ab39610b1e 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java @@ -16,10 +16,10 @@ import org.elasticsearch.client.ResponseException; import org.elasticsearch.cluster.metadata.DesiredNode; import org.elasticsearch.cluster.metadata.DesiredNodeWithStatus; +import org.elasticsearch.cluster.metadata.MetadataFeatures; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.unit.Processors; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.xcontent.json.JsonXContent; @@ -50,9 +50,11 @@ private enum ProcessorsPrecision { public void testUpgradeDesiredNodes() throws Exception { assumeTrue("Desired nodes was introduced in 8.1", getOldClusterVersion().onOrAfter(Version.V_8_1_0)); - if (getOldClusterVersion().onOrAfter(Processors.DOUBLE_PROCESSORS_SUPPORT_VERSION)) { + var featureVersions = new MetadataFeatures().getHistoricalFeatures(); + + if (getOldClusterVersion().onOrAfter(featureVersions.get(DesiredNode.DOUBLE_PROCESSORS_SUPPORTED))) { assertUpgradedNodesCanReadDesiredNodes(); - } else if (getOldClusterVersion().onOrAfter(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) { + } else if (getOldClusterVersion().onOrAfter(featureVersions.get(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED))) { assertDesiredNodesUpdatedWithRoundedUpFloatsAreIdempotent(); } else { assertDesiredNodesWithFloatProcessorsAreRejectedInOlderVersions(); diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index 5898a9bdbfb53..d8b45adbebb1f 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -407,6 +407,7 @@ with org.elasticsearch.features.FeatureInfrastructureFeatures, org.elasticsearch.health.HealthFeatures, + org.elasticsearch.cluster.metadata.MetadataFeatures, org.elasticsearch.rest.RestFeatures; uses org.elasticsearch.plugins.internal.SettingsExtension; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesAction.java index 0120718361877..ef04198c7374b 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesAction.java @@ -20,6 +20,7 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.desirednodes.DesiredNodesSettingsValidator; import org.elasticsearch.cluster.desirednodes.VersionConflictException; +import org.elasticsearch.cluster.metadata.DesiredNode; import org.elasticsearch.cluster.metadata.DesiredNodes; import org.elasticsearch.cluster.metadata.DesiredNodesMetadata; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -30,6 +31,7 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.features.FeatureService; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -41,6 +43,7 @@ public class TransportUpdateDesiredNodesAction extends TransportMasterNodeAction { private static final Logger logger = LogManager.getLogger(TransportUpdateDesiredNodesAction.class); + private final FeatureService featureService; private final DesiredNodesSettingsValidator settingsValidator; private final MasterServiceTaskQueue taskQueue; @@ -48,6 +51,7 @@ public class TransportUpdateDesiredNodesAction extends TransportMasterNodeAction public TransportUpdateDesiredNodesAction( TransportService transportService, ClusterService clusterService, + FeatureService featureService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, @@ -66,6 +70,7 @@ public TransportUpdateDesiredNodesAction( UpdateDesiredNodesResponse::new, EsExecutors.DIRECT_EXECUTOR_SERVICE ); + this.featureService = featureService; this.settingsValidator = settingsValidator; this.taskQueue = clusterService.createTaskQueue( "update-desired-nodes", @@ -94,13 +99,12 @@ protected void masterOperation( @Override protected void doExecute(Task task, UpdateDesiredNodesRequest request, ActionListener listener) { - final var minNodeVersion = clusterService.state().nodes().getMinNodeVersion(); - if (request.isCompatibleWithVersion(minNodeVersion) == false) { + if (request.clusterHasRequiredFeatures(nf -> featureService.clusterHasFeature(clusterService.state(), nf)) == false) { listener.onFailure( new IllegalArgumentException( "Unable to use processor ranges, floating-point (with greater precision) processors " - + "in mixed-clusters with nodes in version: " - + minNodeVersion + + "in mixed-clusters with nodes that do not support feature " + + DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED.id() ) ); return; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java index 4b33a12d68b1f..c7c2b9a290a2e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java @@ -10,13 +10,13 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.TransportVersions; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ValidateActions; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.cluster.metadata.DesiredNode; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.features.NodeFeature; import org.elasticsearch.xcontent.ConstructingObjectParser; import org.elasticsearch.xcontent.ParseField; import org.elasticsearch.xcontent.XContentParser; @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.List; import java.util.Objects; +import java.util.function.Predicate; public class UpdateDesiredNodesRequest extends AcknowledgedRequest { private static final TransportVersion DRY_RUN_VERSION = TransportVersions.V_8_4_0; @@ -100,12 +101,9 @@ public boolean isDryRun() { return dryRun; } - public boolean isCompatibleWithVersion(Version version) { - if (version.onOrAfter(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) { - return true; - } - - return nodes.stream().allMatch(desiredNode -> desiredNode.isCompatibleWithVersion(version)); + public boolean clusterHasRequiredFeatures(Predicate clusterHasFeature) { + return clusterHasFeature.test(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED) + || nodes.stream().allMatch(n -> n.clusterHasRequiredFeatures(clusterHasFeature)); } @Override diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java index de46e04ea6215..27beffe56b97a 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java @@ -20,6 +20,7 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.Processors; import org.elasticsearch.core.Nullable; +import org.elasticsearch.features.NodeFeature; import org.elasticsearch.xcontent.ConstructingObjectParser; import org.elasticsearch.xcontent.ObjectParser; import org.elasticsearch.xcontent.ParseField; @@ -33,6 +34,7 @@ import java.util.Objects; import java.util.Set; import java.util.TreeSet; +import java.util.function.Predicate; import static java.lang.String.format; import static org.elasticsearch.node.Node.NODE_EXTERNAL_ID_SETTING; @@ -40,7 +42,10 @@ import static org.elasticsearch.node.NodeRoleSettings.NODE_ROLES_SETTING; public final class DesiredNode implements Writeable, ToXContentObject, Comparable { - public static final Version RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION = Version.V_8_3_0; + + public static final NodeFeature RANGE_FLOAT_PROCESSORS_SUPPORTED = new NodeFeature("desired_node.range_float_processors"); + public static final NodeFeature DOUBLE_PROCESSORS_SUPPORTED = new NodeFeature("desired_node.double_processors"); + public static final TransportVersion RANGE_FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersions.V_8_3_0; private static final ParseField SETTINGS_FIELD = new ParseField("settings"); @@ -299,12 +304,8 @@ public Set getRoles() { return roles; } - public boolean isCompatibleWithVersion(Version version) { - if (version.onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) { - return true; - } - - return processorsRange == null && processors.isCompatibleWithVersion(version); + public boolean clusterHasRequiredFeatures(Predicate clusterHasFeature) { + return (processorsRange == null && processors.hasDecimals() == false) || clusterHasFeature.test(RANGE_FLOAT_PROCESSORS_SUPPORTED); } @Override diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataFeatures.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataFeatures.java new file mode 100644 index 0000000000000..b24e7fbcfefab --- /dev/null +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataFeatures.java @@ -0,0 +1,27 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.cluster.metadata; + +import org.elasticsearch.Version; +import org.elasticsearch.features.FeatureSpecification; +import org.elasticsearch.features.NodeFeature; + +import java.util.Map; + +public class MetadataFeatures implements FeatureSpecification { + @Override + public Map getHistoricalFeatures() { + return Map.of( + DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED, + Version.V_8_3_0, + DesiredNode.DOUBLE_PROCESSORS_SUPPORTED, + Version.V_8_5_0 + ); + } +} diff --git a/server/src/main/java/org/elasticsearch/common/unit/Processors.java b/server/src/main/java/org/elasticsearch/common/unit/Processors.java index d5421e1475655..c71005678fc0d 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/Processors.java +++ b/server/src/main/java/org/elasticsearch/common/unit/Processors.java @@ -10,7 +10,6 @@ import org.elasticsearch.TransportVersion; import org.elasticsearch.TransportVersions; -import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; @@ -31,9 +30,7 @@ public class Processors implements Writeable, Comparable, ToXContent public static final Processors ZERO = new Processors(0.0); public static final Processors MAX_PROCESSORS = new Processors(Double.MAX_VALUE); - public static final Version FLOAT_PROCESSORS_SUPPORT_VERSION = Version.V_8_3_0; public static final TransportVersion FLOAT_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersions.V_8_3_0; - public static final Version DOUBLE_PROCESSORS_SUPPORT_VERSION = Version.V_8_5_0; public static final TransportVersion DOUBLE_PROCESSORS_SUPPORT_TRANSPORT_VERSION = TransportVersions.V_8_5_0; static final int NUMBER_OF_DECIMAL_PLACES = 5; private static final double MIN_REPRESENTABLE_PROCESSORS = 1E-5; @@ -143,18 +140,10 @@ private static boolean validNumberOfProcessors(double processors) { return Double.isFinite(processors) && processors > 0.0; } - private boolean hasDecimals() { + public boolean hasDecimals() { return ((int) count) != Math.ceil(count); } - public boolean isCompatibleWithVersion(Version version) { - if (version.onOrAfter(FLOAT_PROCESSORS_SUPPORT_VERSION)) { - return true; - } - - return hasDecimals() == false; - } - @Override public int compareTo(Processors o) { return Double.compare(count, o.count); diff --git a/server/src/main/resources/META-INF/services/org.elasticsearch.features.FeatureSpecification b/server/src/main/resources/META-INF/services/org.elasticsearch.features.FeatureSpecification index 14a42aae05358..c94606f289c9e 100644 --- a/server/src/main/resources/META-INF/services/org.elasticsearch.features.FeatureSpecification +++ b/server/src/main/resources/META-INF/services/org.elasticsearch.features.FeatureSpecification @@ -8,4 +8,5 @@ org.elasticsearch.features.FeatureInfrastructureFeatures org.elasticsearch.health.HealthFeatures +org.elasticsearch.cluster.metadata.MetadataFeatures org.elasticsearch.rest.RestFeatures diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesActionTests.java index b2c2b49c90eb2..b018b6c47ed4d 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/desirednodes/TransportUpdateDesiredNodesActionTests.java @@ -25,6 +25,7 @@ import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.features.FeatureService; import org.elasticsearch.test.MockUtils; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -55,6 +56,7 @@ public void testWriteBlocks() { final TransportUpdateDesiredNodesAction action = new TransportUpdateDesiredNodesAction( transportService, mock(ClusterService.class), + mock(FeatureService.class), threadPool, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), @@ -82,6 +84,7 @@ public void testNoBlocks() { final TransportUpdateDesiredNodesAction action = new TransportUpdateDesiredNodesAction( transportService, mock(ClusterService.class), + mock(FeatureService.class), threadPool, mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DesiredNodeTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DesiredNodeTests.java index 1a0301d4a7d47..6e26fa26fc041 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DesiredNodeTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DesiredNodeTests.java @@ -190,7 +190,7 @@ public void testNodeCPUsRoundUp() { } } - public void testDesiredNodeIsCompatible() { + public void testDesiredNodeHasRangeFloatProcessors() { final var settings = Settings.builder().put(NODE_NAME_SETTING.getKey(), randomAlphaOfLength(10)).build(); { @@ -201,8 +201,8 @@ public void testDesiredNodeIsCompatible() { ByteSizeValue.ofGb(1), Version.CURRENT ); - assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_2_0), is(equalTo(false))); - assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_3_0), is(equalTo(true))); + assertThat(desiredNode.clusterHasRequiredFeatures(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED::equals), is(true)); + assertThat(desiredNode.clusterHasRequiredFeatures(nf -> false), is(false)); } { @@ -213,14 +213,14 @@ public void testDesiredNodeIsCompatible() { ByteSizeValue.ofGb(1), Version.CURRENT ); - assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_2_0), is(equalTo(false))); - assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_3_0), is(equalTo(true))); + assertThat(desiredNode.clusterHasRequiredFeatures(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED::equals), is(true)); + assertThat(desiredNode.clusterHasRequiredFeatures(nf -> false), is(false)); } { final var desiredNode = new DesiredNode(settings, 2.0f, ByteSizeValue.ofGb(1), ByteSizeValue.ofGb(1), Version.CURRENT); - assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_2_0), is(equalTo(true))); - assertThat(desiredNode.isCompatibleWithVersion(Version.V_8_3_0), is(equalTo(true))); + assertThat(desiredNode.clusterHasRequiredFeatures(DesiredNode.RANGE_FLOAT_PROCESSORS_SUPPORTED::equals), is(true)); + assertThat(desiredNode.clusterHasRequiredFeatures(nf -> false), is(true)); } } From 4fc58af0bc35666fb8832969243d081596f22a0b Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Fri, 3 Nov 2023 13:59:20 +0000 Subject: [PATCH 02/14] Start peeling off methods from the top of the NodeConstructor construct method (#101119) Create separate methods for initial object creation --- .../elasticsearch/node/NodeConstruction.java | 114 +++++++++++------- 1 file changed, 71 insertions(+), 43 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java index 20c8529935867..bd33a747b36fd 100644 --- a/server/src/main/java/org/elasticsearch/node/NodeConstruction.java +++ b/server/src/main/java/org/elasticsearch/node/NodeConstruction.java @@ -245,7 +245,12 @@ static NodeConstruction prepareConstruction( List closeables = new ArrayList<>(); try { NodeConstruction constructor = new NodeConstruction(closeables); - constructor.construct(initialEnvironment, serviceProvider, forbidPrivateIndexSettings); + Settings settings = constructor.createEnvironment(initialEnvironment, serviceProvider); + ThreadPool threadPool = constructor.createThreadPool(settings); + SettingsModule settingsModule = constructor.validateSettings(initialEnvironment.settings(), settings, threadPool); + + constructor.construct(threadPool, settingsModule, serviceProvider, forbidPrivateIndexSettings); + return constructor; } catch (IOException e) { IOUtils.closeWhileHandlingException(closeables); @@ -345,13 +350,12 @@ private Optional getSinglePlugin(Stream plugins, Class pluginClass) return Optional.of(plugin); } - private void construct(Environment initialEnvironment, NodeServiceProvider serviceProvider, boolean forbidPrivateIndexSettings) - throws IOException { + private Settings createEnvironment(Environment initialEnvironment, NodeServiceProvider serviceProvider) { // Pass the node settings to the DeprecationLogger class so that it can have the deprecation.skip_deprecated_settings setting: - DeprecationLogger.initialize(initialEnvironment.settings()); - Settings environmentSettings = initialEnvironment.settings(); + Settings envSettings = initialEnvironment.settings(); + DeprecationLogger.initialize(envSettings); - final JvmInfo jvmInfo = JvmInfo.jvmInfo(); + JvmInfo jvmInfo = JvmInfo.jvmInfo(); logger.info( "version[{}], pid[{}], build[{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", Build.current().qualifiedVersion(), @@ -375,7 +379,7 @@ private void construct(Environment initialEnvironment, NodeServiceProvider servi Build.current().qualifiedVersion() ); } - if (Environment.PATH_SHARED_DATA_SETTING.exists(environmentSettings)) { + if (Environment.PATH_SHARED_DATA_SETTING.exists(envSettings)) { // NOTE: this must be done with an explicit check here because the deprecation property on a path setting will // cause ES to fail to start since logging is not yet initialized on first read of the setting deprecationLogger.warn( @@ -394,7 +398,7 @@ private void construct(Environment initialEnvironment, NodeServiceProvider servi + "multiple disks. This feature will be removed in a future release." ); } - if (Environment.dataPathUsesList(environmentSettings)) { + if (Environment.dataPathUsesList(envSettings)) { // already checked for multiple values above, so if this is a list it is a single valued list deprecationLogger.warn( DeprecationCategory.SETTINGS, @@ -418,8 +422,8 @@ private void construct(Environment initialEnvironment, NodeServiceProvider servi (e, apmConfig) -> logger.error("failed to delete temporary APM config file [{}], reason: [{}]", apmConfig, e.getMessage()) ); - pluginsService = serviceProvider.newPluginService(initialEnvironment, environmentSettings); - final Settings settings = Node.mergePluginSettings(pluginsService.pluginMap(), environmentSettings); + pluginsService = serviceProvider.newPluginService(initialEnvironment, envSettings); + Settings settings = Node.mergePluginSettings(pluginsService.pluginMap(), envSettings); /* * Create the environment based on the finalized view of the settings. This is to ensure that components get the same setting @@ -428,16 +432,69 @@ private void construct(Environment initialEnvironment, NodeServiceProvider servi environment = new Environment(settings, initialEnvironment.configFile()); Environment.assertEquivalent(initialEnvironment, environment); - final List> executorBuilders = pluginsService.flatMap(p -> p.getExecutorBuilders(settings)).toList(); + return settings; + } - final ThreadPool threadPool = new ThreadPool(settings, executorBuilders.toArray(new ExecutorBuilder[0])); + private ThreadPool createThreadPool(Settings settings) throws IOException { + ThreadPool threadPool = new ThreadPool( + settings, + pluginsService.flatMap(p -> p.getExecutorBuilders(settings)).toArray(ExecutorBuilder[]::new) + ); resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS)); - final ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, threadPool); - resourcesToClose.add(resourceWatcherService); + // adds the context to the DeprecationLogger so that it does not need to be injected everywhere HeaderWarning.setThreadContext(threadPool.getThreadContext()); resourcesToClose.add(() -> HeaderWarning.removeThreadContext(threadPool.getThreadContext())); + return threadPool; + } + + private SettingsModule validateSettings(Settings envSettings, Settings settings, ThreadPool threadPool) throws IOException { + // register the node.data, node.ingest, node.master, node.remote_cluster_client settings here so we can mark them private + List> additionalSettings = new ArrayList<>(pluginsService.flatMap(Plugin::getSettings).toList()); + for (final ExecutorBuilder builder : threadPool.builders()) { + additionalSettings.addAll(builder.getRegisteredSettings()); + } + SettingsExtension.load().forEach(e -> additionalSettings.addAll(e.getSettings())); + + // this is as early as we can validate settings at this point. we already pass them to ScriptModule as well as ThreadPool + // so we might be late here already + SettingsModule settingsModule = new SettingsModule( + settings, + additionalSettings, + pluginsService.flatMap(Plugin::getSettingsFilter).toList() + ); + + // creating `NodeEnvironment` breaks the ability to rollback to 7.x on an 8.0 upgrade (`upgradeLegacyNodeFolders`) so do this + // after settings validation. + nodeEnvironment = new NodeEnvironment(envSettings, environment); + logger.info( + "node name [{}], node ID [{}], cluster name [{}], roles {}", + Node.NODE_NAME_SETTING.get(envSettings), + nodeEnvironment.nodeId(), + ClusterName.CLUSTER_NAME_SETTING.get(envSettings).value(), + DiscoveryNode.getRolesFromSettings(settings) + .stream() + .map(DiscoveryNodeRole::roleName) + .collect(Collectors.toCollection(LinkedHashSet::new)) + ); + resourcesToClose.add(nodeEnvironment); + + return settingsModule; + } + + private void construct( + ThreadPool threadPool, + SettingsModule settingsModule, + NodeServiceProvider serviceProvider, + boolean forbidPrivateIndexSettings + ) throws IOException { + + Settings settings = settingsModule.getSettings(); + + final ResourceWatcherService resourceWatcherService = new ResourceWatcherService(settings, threadPool); + resourcesToClose.add(resourceWatcherService); + final Set taskHeaders = Stream.concat( pluginsService.filterPlugins(ActionPlugin.class).flatMap(p -> p.getTaskHeaders().stream()), Task.HEADERS_TO_COPY.stream() @@ -450,12 +507,6 @@ private void construct(Environment initialEnvironment, NodeServiceProvider servi final TaskManager taskManager = new TaskManager(settings, threadPool, taskHeaders, tracer); - // register the node.data, node.ingest, node.master, node.remote_cluster_client settings here so we can mark them private - final List> additionalSettings = new ArrayList<>(pluginsService.flatMap(Plugin::getSettings).toList()); - for (final ExecutorBuilder builder : threadPool.builders()) { - additionalSettings.addAll(builder.getRegisteredSettings()); - } - SettingsExtension.load().forEach(e -> additionalSettings.addAll(e.getSettings())); client = new NodeClient(settings, threadPool); final ScriptModule scriptModule = new ScriptModule(settings, pluginsService.filterPlugins(ScriptPlugin.class).toList()); @@ -471,29 +522,6 @@ private void construct(Environment initialEnvironment, NodeServiceProvider servi pluginsService.filterPlugins(AnalysisPlugin.class).toList(), pluginsService.getStablePluginRegistry() ); - // this is as early as we can validate settings at this point. we already pass them to ScriptModule as well as ThreadPool - // so we might be late here already - - final SettingsModule settingsModule = new SettingsModule( - settings, - additionalSettings, - pluginsService.flatMap(Plugin::getSettingsFilter).toList() - ); - - // creating `NodeEnvironment` breaks the ability to rollback to 7.x on an 8.0 upgrade (`upgradeLegacyNodeFolders`) so do this - // after settings validation. - nodeEnvironment = new NodeEnvironment(environmentSettings, environment); - logger.info( - "node name [{}], node ID [{}], cluster name [{}], roles {}", - Node.NODE_NAME_SETTING.get(environmentSettings), - nodeEnvironment.nodeId(), - ClusterName.CLUSTER_NAME_SETTING.get(environmentSettings).value(), - DiscoveryNode.getRolesFromSettings(settings) - .stream() - .map(DiscoveryNodeRole::roleName) - .collect(Collectors.toCollection(LinkedHashSet::new)) - ); - resourcesToClose.add(nodeEnvironment); localNodeFactory = new Node.LocalNodeFactory(settings, nodeEnvironment.nodeId()); ScriptModule.registerClusterSettingsListeners(scriptService, settingsModule.getClusterSettings()); From b0aca36a111dbdd9235530889c5feb205c24bdcf Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Fri, 3 Nov 2023 15:33:03 +0100 Subject: [PATCH 03/14] Fix SearchCancellationIT failures (#101777) We need at least two data nodes in this test, otherwise we are not guaranteed to get two concurrently executing shard query requests because max concurrency could be 1. closes #101739 #99929 --- .../org/elasticsearch/search/SearchCancellationIT.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/SearchCancellationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/SearchCancellationIT.java index 345504582305a..ec01e34976058 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/SearchCancellationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/SearchCancellationIT.java @@ -8,7 +8,6 @@ package org.elasticsearch.search; -import org.apache.lucene.tests.util.LuceneTestCase; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.search.MultiSearchAction; @@ -33,7 +32,6 @@ import org.elasticsearch.tasks.TaskCancelledException; import org.elasticsearch.test.AbstractSearchCancellationTestCase; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.junit.annotations.TestIssueLogging; import org.elasticsearch.transport.TransportService; import java.util.ArrayList; @@ -51,7 +49,6 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.notNullValue; -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/101739") @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE) public class SearchCancellationIT extends AbstractSearchCancellationTestCase { @@ -230,11 +227,10 @@ public void testCancelMultiSearch() throws Exception { } } - @TestIssueLogging( - value = "org.elasticsearch.action.search:TRACE,org.elasticsearch.search:TRACE," + "org.elasticsearch.tasks:TRACE", - issueUrl = "https://github.com/elastic/elasticsearch/issues/99929" - ) public void testCancelFailedSearchWhenPartialResultDisallowed() throws Exception { + // Have at least two nodes so that we have parallel execution of two request guaranteed even if max concurrent requests per node + // are limited to 1 + internalCluster().ensureAtLeastNumDataNodes(2); int numberOfShards = between(2, 5); createIndex("test", numberOfShards, 0); indexTestData(); From a36156e1e64a9237c390b195be447dbdcb47e0d8 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Fri, 3 Nov 2023 10:56:56 -0400 Subject: [PATCH 04/14] [ci] Add rocky-9 to matrix in packaging and platform jobs (#101653) --- .../pipelines/periodic-packaging.template.yml | 1 + .buildkite/pipelines/periodic-packaging.yml | 1 + .../pipelines/periodic-platform-support.yml | 1 + .../pull-request/packaging-tests-unix.yml | 71 ++++++++++++++++--- 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/.buildkite/pipelines/periodic-packaging.template.yml b/.buildkite/pipelines/periodic-packaging.template.yml index 1c626ffc53bfe..a5fe3a6c9e3d0 100644 --- a/.buildkite/pipelines/periodic-packaging.template.yml +++ b/.buildkite/pipelines/periodic-packaging.template.yml @@ -19,6 +19,7 @@ steps: - ubuntu-2004 - ubuntu-2204 - rocky-8 + - rocky-9 - rhel-7 - rhel-8 - rhel-9 diff --git a/.buildkite/pipelines/periodic-packaging.yml b/.buildkite/pipelines/periodic-packaging.yml index dcf220c32ce9a..476a59eca58e5 100644 --- a/.buildkite/pipelines/periodic-packaging.yml +++ b/.buildkite/pipelines/periodic-packaging.yml @@ -20,6 +20,7 @@ steps: - ubuntu-2004 - ubuntu-2204 - rocky-8 + - rocky-9 - rhel-7 - rhel-8 - rhel-9 diff --git a/.buildkite/pipelines/periodic-platform-support.yml b/.buildkite/pipelines/periodic-platform-support.yml index 8e43bd4ad5a12..b52f8506885c9 100644 --- a/.buildkite/pipelines/periodic-platform-support.yml +++ b/.buildkite/pipelines/periodic-platform-support.yml @@ -19,6 +19,7 @@ steps: - ubuntu-2004 - ubuntu-2204 - rocky-8 + - rocky-9 - rhel-7 - rhel-8 - rhel-9 diff --git a/.buildkite/pipelines/pull-request/packaging-tests-unix.yml b/.buildkite/pipelines/pull-request/packaging-tests-unix.yml index ec2e29b284781..d5c937aa4b5a2 100644 --- a/.buildkite/pipelines/pull-request/packaging-tests-unix.yml +++ b/.buildkite/pipelines/pull-request/packaging-tests-unix.yml @@ -3,9 +3,9 @@ config: steps: - group: packaging-tests-unix steps: - - label: "{{matrix.image}} / {{matrix.PACKAGING_TASK}} / packaging-tests-unix" - key: "packaging-tests-unix" - command: ./.ci/scripts/packaging-test.sh $$PACKAGING_TASK + - label: "{{matrix.image}} / docker / packaging-tests-unix" + key: "packaging-tests-unix-docker" + command: ./.ci/scripts/packaging-test.sh destructiveDistroTest.docker timeout_in_minutes: 300 matrix: setup: @@ -22,18 +22,71 @@ steps: - ubuntu-2004 - ubuntu-2204 - rocky-8 + - rocky-9 + - rhel-7 + - rhel-8 + - rhel-9 + - almalinux-8 + agents: + provider: gcp + image: family/elasticsearch-{{matrix.image}} + diskSizeGb: 350 + machineType: custom-16-32768 + - label: "{{matrix.image}} / packages / packaging-tests-unix" + key: "packaging-tests-unix-packages" + command: ./.ci/scripts/packaging-test.sh destructiveDistroTest.packages + timeout_in_minutes: 300 + matrix: + setup: + image: + - centos-7 + - debian-10 + - debian-11 + - opensuse-leap-15 + - oraclelinux-7 + - oraclelinux-8 + - sles-12 + - sles-15 + - ubuntu-1804 + - ubuntu-2004 + - ubuntu-2204 + - rocky-8 + - rocky-9 + - rhel-7 + - rhel-8 + - rhel-9 + - almalinux-8 + agents: + provider: gcp + image: family/elasticsearch-{{matrix.image}} + diskSizeGb: 350 + machineType: custom-16-32768 + - label: "{{matrix.image}} / archives / packaging-tests-unix" + key: "packaging-tests-unix-archives" + command: ./.ci/scripts/packaging-test.sh destructiveDistroTest.archives + timeout_in_minutes: 300 + matrix: + setup: + image: + - centos-7 + - debian-10 + - debian-11 + - opensuse-leap-15 + - oraclelinux-7 + - oraclelinux-8 + - sles-12 + - sles-15 + - ubuntu-1804 + - ubuntu-2004 + - ubuntu-2204 + - rocky-8 + - rocky-9 - rhel-7 - rhel-8 - rhel-9 - almalinux-8 - PACKAGING_TASK: - - destructiveDistroTest.docker - - destructiveDistroTest.packages - - destructiveDistroTest.archives agents: provider: gcp image: family/elasticsearch-{{matrix.image}} diskSizeGb: 350 machineType: custom-16-32768 - env: - PACKAGING_TASK: "{{matrix.PACKAGING_TASK}}" From 6e8d798e4b6e9fd97ccd1b389298866245f12241 Mon Sep 17 00:00:00 2001 From: Stuart Tettemer Date: Fri, 3 Nov 2023 11:00:54 -0500 Subject: [PATCH 05/14] Metrics test: testLockingWhenRegistering wait for threads to join (#101751) The test was checking for the wrong meter instance, it should be checking for the updated meter, `noopMeter`. Removed the assertBusy(() -> assertThat...) which was hiding the problem. The goal of the test is that we serialize access to registration and the provider. A nice way to do this is wait for the contending threads to join (with the added benefit of avoiding thread leaks). After the threads join, we check that we have the expected state. Fixes: #101725 --- .../telemetry/apm/MeterRegistryConcurrencyTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/MeterRegistryConcurrencyTests.java b/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/MeterRegistryConcurrencyTests.java index d1c74681c2bd7..e8dafd996f5b0 100644 --- a/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/MeterRegistryConcurrencyTests.java +++ b/modules/apm/src/test/java/org/elasticsearch/telemetry/apm/MeterRegistryConcurrencyTests.java @@ -90,7 +90,6 @@ public ObservableLongCounter buildWithCallback(Consumer assertThat(setProviderThread.getState(), equalTo(Thread.State.WAITING))); // assert that the old lockingMeter is still in place - assertBusy(() -> assertThat(meterRegistrar.getMeter(), sameInstance(lockingMeter))); + assertThat(meterRegistrar.getMeter(), sameInstance(lockingMeter)); // finish long-running registration registerLatch.countDown(); + // wait for everything to quiesce, registerLatch.countDown() doesn't ensure lock has been released + setProviderThread.join(); + registerThread.join(); // assert that a meter was overriden - assertBusy(() -> assertThat(meterRegistrar.getMeter(), sameInstance(lockingMeter))); - + assertThat(meterRegistrar.getMeter(), sameInstance(noopMeter)); } } From 534d80540f9e8e38cb82a2c6db8868cc24aa0c74 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 3 Nov 2023 11:21:58 -0600 Subject: [PATCH 06/14] Move master file watcher to make it available to other modules (#101754) This commit moves the new master node file watcher to the o.e.common.file package so that it can be accessible to existing uses of AbstractFileWatchingService. --- .../service => common/file}/MasterNodeFileWatchingService.java | 3 +-- .../reservedstate/service/FileSettingsService.java | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) rename server/src/main/java/org/elasticsearch/{reservedstate/service => common/file}/MasterNodeFileWatchingService.java (97%) diff --git a/server/src/main/java/org/elasticsearch/reservedstate/service/MasterNodeFileWatchingService.java b/server/src/main/java/org/elasticsearch/common/file/MasterNodeFileWatchingService.java similarity index 97% rename from server/src/main/java/org/elasticsearch/reservedstate/service/MasterNodeFileWatchingService.java rename to server/src/main/java/org/elasticsearch/common/file/MasterNodeFileWatchingService.java index 444cde45d6961..6da0845a7c7ba 100644 --- a/server/src/main/java/org/elasticsearch/reservedstate/service/MasterNodeFileWatchingService.java +++ b/server/src/main/java/org/elasticsearch/common/file/MasterNodeFileWatchingService.java @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -package org.elasticsearch.reservedstate.service; +package org.elasticsearch.common.file; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,7 +15,6 @@ import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.file.AbstractFileWatchingService; import java.io.IOException; import java.nio.file.Files; diff --git a/server/src/main/java/org/elasticsearch/reservedstate/service/FileSettingsService.java b/server/src/main/java/org/elasticsearch/reservedstate/service/FileSettingsService.java index 2d13af0248a73..83676925a3ae7 100644 --- a/server/src/main/java/org/elasticsearch/reservedstate/service/FileSettingsService.java +++ b/server/src/main/java/org/elasticsearch/reservedstate/service/FileSettingsService.java @@ -16,6 +16,7 @@ import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.ReservedStateMetadata; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.file.MasterNodeFileWatchingService; import org.elasticsearch.env.Environment; import org.elasticsearch.xcontent.XContentParserConfiguration; From becbc71d357fc928d3d9fad6c2b33a7c63468b30 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 3 Nov 2023 14:30:26 -0400 Subject: [PATCH 07/14] ESQL: Narrow catch in convert functions (#101788) This narrows the `catch` parameters in `to_` functions so we don't accidentally catch things that aren't conversion failures. We super don't want to catch `CircuitBreakingException`, for example. Closes #100820 --- docs/changelog/101788.yaml | 6 ++ .../compute/ann/ConvertEvaluator.java | 5 ++ .../gen/ConvertEvaluatorImplementer.java | 70 ++++++++++--------- .../compute/gen/EvaluatorProcessor.java | 8 ++- .../convert/ToBooleanFromDoubleEvaluator.java | 30 +++----- .../convert/ToBooleanFromIntEvaluator.java | 30 +++----- .../convert/ToBooleanFromLongEvaluator.java | 30 +++----- .../convert/ToBooleanFromStringEvaluator.java | 30 +++----- .../ToBooleanFromUnsignedLongEvaluator.java | 30 +++----- .../ToDatetimeFromStringEvaluator.java | 7 +- .../scalar/convert/ToDegreesEvaluator.java | 30 +++----- .../convert/ToDoubleFromBooleanEvaluator.java | 30 +++----- .../convert/ToDoubleFromIntEvaluator.java | 30 +++----- .../convert/ToDoubleFromLongEvaluator.java | 30 +++----- .../convert/ToDoubleFromStringEvaluator.java | 7 +- .../ToDoubleFromUnsignedLongEvaluator.java | 30 +++----- .../convert/ToIPFromStringEvaluator.java | 7 +- .../ToIntegerFromBooleanEvaluator.java | 30 +++----- .../convert/ToIntegerFromDoubleEvaluator.java | 8 ++- .../convert/ToIntegerFromLongEvaluator.java | 8 ++- .../convert/ToIntegerFromStringEvaluator.java | 7 +- .../ToIntegerFromUnsignedLongEvaluator.java | 8 ++- .../convert/ToLongFromBooleanEvaluator.java | 30 +++----- .../convert/ToLongFromDoubleEvaluator.java | 8 ++- .../convert/ToLongFromIntEvaluator.java | 30 +++----- .../convert/ToLongFromStringEvaluator.java | 7 +- .../ToLongFromUnsignedLongEvaluator.java | 8 ++- .../scalar/convert/ToRadiansEvaluator.java | 30 +++----- .../convert/ToStringFromBooleanEvaluator.java | 30 +++----- .../ToStringFromDatetimeEvaluator.java | 30 +++----- .../convert/ToStringFromDoubleEvaluator.java | 30 +++----- .../convert/ToStringFromIPEvaluator.java | 30 +++----- .../convert/ToStringFromIntEvaluator.java | 30 +++----- .../convert/ToStringFromLongEvaluator.java | 30 +++----- .../ToStringFromUnsignedLongEvaluator.java | 30 +++----- .../convert/ToStringFromVersionEvaluator.java | 30 +++----- .../ToUnsignedLongFromBooleanEvaluator.java | 30 +++----- .../ToUnsignedLongFromDoubleEvaluator.java | 8 ++- .../ToUnsignedLongFromIntEvaluator.java | 30 +++----- .../ToUnsignedLongFromLongEvaluator.java | 30 +++----- .../ToUnsignedLongFromStringEvaluator.java | 7 +- .../convert/ToVersionFromStringEvaluator.java | 30 +++----- .../function/scalar/convert/ToDatetime.java | 2 +- .../function/scalar/convert/ToDouble.java | 2 +- .../function/scalar/convert/ToIP.java | 2 +- .../function/scalar/convert/ToInteger.java | 10 +-- .../function/scalar/convert/ToLong.java | 8 ++- .../scalar/convert/ToUnsignedLong.java | 6 +- .../function/AbstractFunctionTestCase.java | 1 - 49 files changed, 334 insertions(+), 656 deletions(-) create mode 100644 docs/changelog/101788.yaml diff --git a/docs/changelog/101788.yaml b/docs/changelog/101788.yaml new file mode 100644 index 0000000000000..b7cc1e20663e8 --- /dev/null +++ b/docs/changelog/101788.yaml @@ -0,0 +1,6 @@ +pr: 101788 +summary: "ESQL: Narrow catch in convert functions" +area: ES|QL +type: bug +issues: + - 100820 diff --git a/x-pack/plugin/esql/compute/ann/src/main/java/org/elasticsearch/compute/ann/ConvertEvaluator.java b/x-pack/plugin/esql/compute/ann/src/main/java/org/elasticsearch/compute/ann/ConvertEvaluator.java index 69a015b8d5ae9..f09d876cfb90c 100644 --- a/x-pack/plugin/esql/compute/ann/src/main/java/org/elasticsearch/compute/ann/ConvertEvaluator.java +++ b/x-pack/plugin/esql/compute/ann/src/main/java/org/elasticsearch/compute/ann/ConvertEvaluator.java @@ -25,4 +25,9 @@ */ String extraName() default ""; + /** + * Exceptions thrown by the process method to catch and convert + * into a warning and turn into a null value. + */ + Class[] warnExceptions() default {}; } diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/ConvertEvaluatorImplementer.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/ConvertEvaluatorImplementer.java index 002806f11dd4b..f875cd7e6480e 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/ConvertEvaluatorImplementer.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/ConvertEvaluatorImplementer.java @@ -20,6 +20,7 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; import static org.elasticsearch.compute.gen.Methods.appendMethod; @@ -45,8 +46,14 @@ public class ConvertEvaluatorImplementer { private final ClassName implementation; private final TypeName argumentType; private final TypeName resultType; - - public ConvertEvaluatorImplementer(Elements elements, ExecutableElement processFunction, String extraName) { + private final List warnExceptions; + + public ConvertEvaluatorImplementer( + Elements elements, + ExecutableElement processFunction, + String extraName, + List warnExceptions + ) { this.declarationType = (TypeElement) processFunction.getEnclosingElement(); this.processFunction = processFunction; if (processFunction.getParameters().size() != 1) { @@ -55,6 +62,7 @@ public ConvertEvaluatorImplementer(Elements elements, ExecutableElement processF this.extraName = extraName; this.argumentType = TypeName.get(processFunction.getParameters().get(0).asType()); this.resultType = TypeName.get(processFunction.getReturnType()); + this.warnExceptions = warnExceptions; this.implementation = ClassName.get( elements.getPackageOf(declarationType).toString(), @@ -113,29 +121,21 @@ private MethodSpec evalVector() { builder.addStatement("$T vector = ($T) v", vectorType, vectorType); builder.addStatement("int positionCount = v.getPositionCount()"); - String scratchPadName = null; + String scratchPadName = argumentType.equals(BYTES_REF) ? "scratchPad" : null; if (argumentType.equals(BYTES_REF)) { - scratchPadName = "scratchPad"; builder.addStatement("BytesRef $N = new BytesRef()", scratchPadName); } builder.beginControlFlow("if (vector.isConstant())"); { - builder.beginControlFlow("try"); - { + catchingWarnExceptions(builder, () -> { var constVectType = blockType(resultType); builder.addStatement( "return driverContext.blockFactory().newConstant$TWith($N, positionCount)", constVectType, evalValueCall("vector", "0", scratchPadName) ); - } - builder.nextControlFlow("catch (Exception e)"); - { - builder.addStatement("registerException(e)"); - builder.addStatement("return driverContext.blockFactory().newConstantNullBlock(positionCount)"); - } - builder.endControlFlow(); + }, () -> builder.addStatement("return driverContext.blockFactory().newConstantNullBlock(positionCount)")); } builder.endControlFlow(); @@ -148,16 +148,11 @@ private MethodSpec evalVector() { { builder.beginControlFlow("for (int p = 0; p < positionCount; p++)"); { - builder.beginControlFlow("try"); - { - builder.addStatement("builder.$L($N)", appendMethod(resultType), evalValueCall("vector", "p", scratchPadName)); - } - builder.nextControlFlow("catch (Exception e)"); - { - builder.addStatement("registerException(e)"); - builder.addStatement("builder.appendNull()"); - } - builder.endControlFlow(); + catchingWarnExceptions( + builder, + () -> builder.addStatement("builder.$L($N)", appendMethod(resultType), evalValueCall("vector", "p", scratchPadName)), + () -> builder.addStatement("builder.appendNull()") + ); } builder.endControlFlow(); builder.addStatement("return builder.build()"); @@ -167,6 +162,22 @@ private MethodSpec evalVector() { return builder.build(); } + private void catchingWarnExceptions(MethodSpec.Builder builder, Runnable whileCatching, Runnable ifCaught) { + if (warnExceptions.isEmpty()) { + whileCatching.run(); + return; + } + builder.beginControlFlow("try"); + whileCatching.run(); + builder.nextControlFlow( + "catch (" + warnExceptions.stream().map(m -> "$T").collect(Collectors.joining(" | ")) + " e)", + warnExceptions.stream().map(m -> TypeName.get(m)).toArray() + ); + builder.addStatement("registerException(e)"); + ifCaught.run(); + builder.endControlFlow(); + } + private MethodSpec evalBlock() { MethodSpec.Builder builder = MethodSpec.methodBuilder("evalBlock").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC); builder.addParameter(BLOCK, "b").returns(BLOCK); @@ -180,9 +191,8 @@ private MethodSpec evalBlock() { resultBuilderType, buildFromFactory(resultBuilderType) ); - String scratchPadName = null; + String scratchPadName = argumentType.equals(BYTES_REF) ? "scratchPad" : null; if (argumentType.equals(BYTES_REF)) { - scratchPadName = "scratchPad"; builder.addStatement("BytesRef $N = new BytesRef()", scratchPadName); } @@ -197,8 +207,7 @@ private MethodSpec evalBlock() { // builder.addStatement("builder.beginPositionEntry()"); builder.beginControlFlow("for (int i = start; i < end; i++)"); { - builder.beginControlFlow("try"); - { + catchingWarnExceptions(builder, () -> { builder.addStatement("$T value = $N", resultType, evalValueCall("block", "i", scratchPadName)); builder.beginControlFlow("if (positionOpened == false && valueCount > 1)"); { @@ -208,12 +217,7 @@ private MethodSpec evalBlock() { builder.endControlFlow(); builder.addStatement("builder.$N(value)", appendMethod); builder.addStatement("valuesAppended = true"); - } - builder.nextControlFlow("catch (Exception e)"); - { - builder.addStatement("registerException(e)"); - } - builder.endControlFlow(); + }, () -> {}); } builder.endControlFlow(); builder.beginControlFlow("if (valuesAppended == false)"); diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorProcessor.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorProcessor.java index a6668795c592a..ea3ee938298de 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorProcessor.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/EvaluatorProcessor.java @@ -120,7 +120,8 @@ public boolean process(Set set, RoundEnvironment roundEnv new ConvertEvaluatorImplementer( env.getElementUtils(), (ExecutableElement) evaluatorMethod, - convertEvaluatorAnn.extraName() + convertEvaluatorAnn.extraName(), + warnExceptions(evaluatorMethod) ).sourceFile(), env ); @@ -138,7 +139,10 @@ private static List warnExceptions(Element evaluatorMethod) { List result = new ArrayList<>(); for (var mirror : evaluatorMethod.getAnnotationMirrors()) { String annotationType = mirror.getAnnotationType().toString(); - if (annotationType.equals(Evaluator.class.getName()) || annotationType.equals(MvEvaluator.class.getName())) { + if (annotationType.equals(Evaluator.class.getName()) + || annotationType.equals(MvEvaluator.class.getName()) + || annotationType.equals(ConvertEvaluator.class.getName())) { + for (var e : mirror.getElementValues().entrySet()) { if (false == e.getKey().getSimpleName().toString().equals("warnExceptions")) { continue; diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromDoubleEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromDoubleEvaluator.java index 4463883b611d4..c64568251feec 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromDoubleEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { DoubleVector vector = (DoubleVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); } try (BooleanBlock.Builder builder = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBoolean(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBoolean(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - boolean value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBoolean(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + boolean value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBoolean(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromIntEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromIntEvaluator.java index 22c07e6e10f21..daac34639c66a 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromIntEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { IntVector vector = (IntVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); } try (BooleanBlock.Builder builder = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBoolean(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBoolean(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - boolean value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBoolean(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + boolean value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBoolean(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromLongEvaluator.java index c9264d1ec5017..1e6b2aefce9f3 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromLongEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); } try (BooleanBlock.Builder builder = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBoolean(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBoolean(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - boolean value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBoolean(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + boolean value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBoolean(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromStringEvaluator.java index 5e68501d13418..ce573a3b8d2d3 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromStringEvaluator.java @@ -37,21 +37,11 @@ public Block evalVector(Vector v) { int positionCount = v.getPositionCount(); BytesRef scratchPad = new BytesRef(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0, scratchPad), positionCount); } try (BooleanBlock.Builder builder = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBoolean(evalValue(vector, p, scratchPad)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBoolean(evalValue(vector, p, scratchPad)); } return builder.build(); } @@ -75,17 +65,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - boolean value = evalValue(block, i, scratchPad); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBoolean(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + boolean value = evalValue(block, i, scratchPad); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBoolean(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromUnsignedLongEvaluator.java index 2924994f894b9..5ec75f10c2ecb 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToBooleanFromUnsignedLongEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBooleanBlockWith(evalValue(vector, 0), positionCount); } try (BooleanBlock.Builder builder = driverContext.blockFactory().newBooleanBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBoolean(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBoolean(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - boolean value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBoolean(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + boolean value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBoolean(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetimeFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetimeFromStringEvaluator.java index fb663b0f20b4d..b868fe9b950c8 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetimeFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetimeFromStringEvaluator.java @@ -4,6 +4,7 @@ // 2.0. package org.elasticsearch.xpack.esql.expression.function.scalar.convert; +import java.lang.IllegalArgumentException; import java.lang.Override; import java.lang.String; import org.apache.lucene.util.BytesRef; @@ -39,7 +40,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { + } catch (IllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -48,7 +49,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendLong(evalValue(vector, p, scratchPad)); - } catch (Exception e) { + } catch (IllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -83,7 +84,7 @@ public Block evalBlock(Block b) { } builder.appendLong(value); valuesAppended = true; - } catch (Exception e) { + } catch (IllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDegreesEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDegreesEvaluator.java index 8185f2a6e89b9..bdf1fd8616559 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDegreesEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDegreesEvaluator.java @@ -34,21 +34,11 @@ public Block evalVector(Vector v) { DoubleVector vector = (DoubleVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); } try (DoubleBlock.Builder builder = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendDouble(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendDouble(evalValue(vector, p)); } return builder.build(); } @@ -71,17 +61,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - double value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendDouble(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + double value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendDouble(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromBooleanEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromBooleanEvaluator.java index 163cd82c5943d..c831e1b0a314a 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromBooleanEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { BooleanVector vector = (BooleanVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); } try (DoubleBlock.Builder builder = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendDouble(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendDouble(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - double value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendDouble(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + double value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendDouble(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromIntEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromIntEvaluator.java index 4493b2ffabe50..ef1081f4ebd6a 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromIntEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { IntVector vector = (IntVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); } try (DoubleBlock.Builder builder = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendDouble(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendDouble(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - double value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendDouble(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + double value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendDouble(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromLongEvaluator.java index d8d6a6499a623..fc78d9cfebc01 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromLongEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); } try (DoubleBlock.Builder builder = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendDouble(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendDouble(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - double value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendDouble(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + double value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendDouble(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromStringEvaluator.java index 39e8d505bb4d7..b1fc80b9260ad 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromStringEvaluator.java @@ -4,6 +4,7 @@ // 2.0. package org.elasticsearch.xpack.esql.expression.function.scalar.convert; +import java.lang.NumberFormatException; import java.lang.Override; import java.lang.String; import org.apache.lucene.util.BytesRef; @@ -39,7 +40,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -48,7 +49,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendDouble(evalValue(vector, p, scratchPad)); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); builder.appendNull(); } @@ -83,7 +84,7 @@ public Block evalBlock(Block b) { } builder.appendDouble(value); valuesAppended = true; - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromUnsignedLongEvaluator.java index a5ff443f7e7f6..b2e4e5137543a 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDoubleFromUnsignedLongEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); } try (DoubleBlock.Builder builder = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendDouble(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendDouble(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - double value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendDouble(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + double value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendDouble(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIPFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIPFromStringEvaluator.java index 8ed666bacc190..bd6e883a6e89e 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIPFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIPFromStringEvaluator.java @@ -4,6 +4,7 @@ // 2.0. package org.elasticsearch.xpack.esql.expression.function.scalar.convert; +import java.lang.IllegalArgumentException; import java.lang.Override; import java.lang.String; import org.apache.lucene.util.BytesRef; @@ -38,7 +39,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { + } catch (IllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -47,7 +48,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendBytesRef(evalValue(vector, p, scratchPad)); - } catch (Exception e) { + } catch (IllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -82,7 +83,7 @@ public Block evalBlock(Block b) { } builder.appendBytesRef(value); valuesAppended = true; - } catch (Exception e) { + } catch (IllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromBooleanEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromBooleanEvaluator.java index b4e36bd28a51b..f778deb32865f 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromBooleanEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { BooleanVector vector = (BooleanVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantIntBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantIntBlockWith(evalValue(vector, 0), positionCount); } try (IntBlock.Builder builder = driverContext.blockFactory().newIntBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendInt(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendInt(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - int value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendInt(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + int value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendInt(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromDoubleEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromDoubleEvaluator.java index 10820c83ac0c8..b7ff410d07c15 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromDoubleEvaluator.java @@ -13,6 +13,8 @@ import org.elasticsearch.compute.data.Vector; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.tree.Source; /** @@ -37,7 +39,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantIntBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -46,7 +48,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendInt(evalValue(vector, p)); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -80,7 +82,7 @@ public Block evalBlock(Block b) { } builder.appendInt(value); valuesAppended = true; - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromLongEvaluator.java index bb713a5e7f483..742b057c06799 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromLongEvaluator.java @@ -13,6 +13,8 @@ import org.elasticsearch.compute.data.Vector; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.tree.Source; /** @@ -37,7 +39,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantIntBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -46,7 +48,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendInt(evalValue(vector, p)); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -80,7 +82,7 @@ public Block evalBlock(Block b) { } builder.appendInt(value); valuesAppended = true; - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromStringEvaluator.java index d6d577711db4e..bff4d46b09dff 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromStringEvaluator.java @@ -4,6 +4,7 @@ // 2.0. package org.elasticsearch.xpack.esql.expression.function.scalar.convert; +import java.lang.NumberFormatException; import java.lang.Override; import java.lang.String; import org.apache.lucene.util.BytesRef; @@ -39,7 +40,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantIntBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -48,7 +49,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendInt(evalValue(vector, p, scratchPad)); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); builder.appendNull(); } @@ -83,7 +84,7 @@ public Block evalBlock(Block b) { } builder.appendInt(value); valuesAppended = true; - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromUnsignedLongEvaluator.java index c4f26c73c352b..ccd1edc4aa6c2 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIntegerFromUnsignedLongEvaluator.java @@ -13,6 +13,8 @@ import org.elasticsearch.compute.data.Vector; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.tree.Source; /** @@ -37,7 +39,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantIntBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -46,7 +48,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendInt(evalValue(vector, p)); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -80,7 +82,7 @@ public Block evalBlock(Block b) { } builder.appendInt(value); valuesAppended = true; - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromBooleanEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromBooleanEvaluator.java index 54cc1234ad737..7d6c145405e56 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromBooleanEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { BooleanVector vector = (BooleanVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); } try (LongBlock.Builder builder = driverContext.blockFactory().newLongBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendLong(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - long value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendLong(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + long value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendLong(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromDoubleEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromDoubleEvaluator.java index a78267bc8b4b0..b8b86f1d6cbf1 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromDoubleEvaluator.java @@ -13,6 +13,8 @@ import org.elasticsearch.compute.data.Vector; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.tree.Source; /** @@ -37,7 +39,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -46,7 +48,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -80,7 +82,7 @@ public Block evalBlock(Block b) { } builder.appendLong(value); valuesAppended = true; - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromIntEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromIntEvaluator.java index 0009214b8ee88..dc3a9578ffd9b 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromIntEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { IntVector vector = (IntVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); } try (LongBlock.Builder builder = driverContext.blockFactory().newLongBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendLong(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - long value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendLong(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + long value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendLong(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromStringEvaluator.java index b7007d88a4995..e0eca6b6bcbff 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromStringEvaluator.java @@ -4,6 +4,7 @@ // 2.0. package org.elasticsearch.xpack.esql.expression.function.scalar.convert; +import java.lang.NumberFormatException; import java.lang.Override; import java.lang.String; import org.apache.lucene.util.BytesRef; @@ -39,7 +40,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -48,7 +49,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendLong(evalValue(vector, p, scratchPad)); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); builder.appendNull(); } @@ -83,7 +84,7 @@ public Block evalBlock(Block b) { } builder.appendLong(value); valuesAppended = true; - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromUnsignedLongEvaluator.java index 0d548ff9feff9..41f8980581073 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongFromUnsignedLongEvaluator.java @@ -12,6 +12,8 @@ import org.elasticsearch.compute.data.Vector; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.tree.Source; /** @@ -36,7 +38,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -45,7 +47,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -79,7 +81,7 @@ public Block evalBlock(Block b) { } builder.appendLong(value); valuesAppended = true; - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToRadiansEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToRadiansEvaluator.java index 35c712a3c0b40..3bd997d0b1d38 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToRadiansEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToRadiansEvaluator.java @@ -34,21 +34,11 @@ public Block evalVector(Vector v) { DoubleVector vector = (DoubleVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantDoubleBlockWith(evalValue(vector, 0), positionCount); } try (DoubleBlock.Builder builder = driverContext.blockFactory().newDoubleBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendDouble(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendDouble(evalValue(vector, p)); } return builder.build(); } @@ -71,17 +61,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - double value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendDouble(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + double value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendDouble(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromBooleanEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromBooleanEvaluator.java index f2b423e351f8e..a68cd61a8c470 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromBooleanEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { BooleanVector vector = (BooleanVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p)); } return builder.build(); } @@ -73,17 +63,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDatetimeEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDatetimeEvaluator.java index c978ae8e1d6a4..569881ad30b61 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDatetimeEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDatetimeEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p)); } return builder.build(); } @@ -73,17 +63,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDoubleEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDoubleEvaluator.java index c6fd0435bc96f..69c33e07c1650 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromDoubleEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { DoubleVector vector = (DoubleVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p)); } return builder.build(); } @@ -73,17 +63,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIPEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIPEvaluator.java index 96d7ab6601b4c..00fb269699fe3 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIPEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIPEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { int positionCount = v.getPositionCount(); BytesRef scratchPad = new BytesRef(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0, scratchPad), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p, scratchPad)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p, scratchPad)); } return builder.build(); } @@ -74,17 +64,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i, scratchPad); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i, scratchPad); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIntEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIntEvaluator.java index 95b9cd70fba2b..6e371c90adb28 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromIntEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { IntVector vector = (IntVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p)); } return builder.build(); } @@ -73,17 +63,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromLongEvaluator.java index 1a5f2fecdecf4..3dc8f738d7b1d 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromLongEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p)); } return builder.build(); } @@ -73,17 +63,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromUnsignedLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromUnsignedLongEvaluator.java index 9650dbb5e47fd..4bce2c1fec40f 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromUnsignedLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromUnsignedLongEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p)); } return builder.build(); } @@ -73,17 +63,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromVersionEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromVersionEvaluator.java index 1c2a5a7a80b46..a37696e149d4c 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromVersionEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringFromVersionEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { int positionCount = v.getPositionCount(); BytesRef scratchPad = new BytesRef(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0, scratchPad), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p, scratchPad)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p, scratchPad)); } return builder.build(); } @@ -74,17 +64,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i, scratchPad); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i, scratchPad); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromBooleanEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromBooleanEvaluator.java index 3386bbd4d808d..619a4ec09d60b 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromBooleanEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromBooleanEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { BooleanVector vector = (BooleanVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); } try (LongBlock.Builder builder = driverContext.blockFactory().newLongBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendLong(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - long value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendLong(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + long value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendLong(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromDoubleEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromDoubleEvaluator.java index d85fc923f0e5b..6d57bbd978370 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromDoubleEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromDoubleEvaluator.java @@ -13,6 +13,8 @@ import org.elasticsearch.compute.data.Vector; import org.elasticsearch.compute.operator.DriverContext; import org.elasticsearch.compute.operator.EvalOperator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.tree.Source; /** @@ -37,7 +39,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -46,7 +48,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); builder.appendNull(); } @@ -80,7 +82,7 @@ public Block evalBlock(Block b) { } builder.appendLong(value); valuesAppended = true; - } catch (Exception e) { + } catch (InvalidArgumentException | QlIllegalArgumentException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromIntEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromIntEvaluator.java index 595ed38f4f90e..d3ccf82f2cb05 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromIntEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromIntEvaluator.java @@ -35,21 +35,11 @@ public Block evalVector(Vector v) { IntVector vector = (IntVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); } try (LongBlock.Builder builder = driverContext.blockFactory().newLongBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendLong(evalValue(vector, p)); } return builder.build(); } @@ -72,17 +62,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - long value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendLong(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + long value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendLong(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromLongEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromLongEvaluator.java index ec91840e2dbd0..2f01aef20edde 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromLongEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromLongEvaluator.java @@ -34,21 +34,11 @@ public Block evalVector(Vector v) { LongVector vector = (LongVector) v; int positionCount = v.getPositionCount(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0), positionCount); } try (LongBlock.Builder builder = driverContext.blockFactory().newLongBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendLong(evalValue(vector, p)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendLong(evalValue(vector, p)); } return builder.build(); } @@ -71,17 +61,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - long value = evalValue(block, i); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendLong(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + long value = evalValue(block, i); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendLong(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromStringEvaluator.java index 1d53f0cde4936..4552154560421 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLongFromStringEvaluator.java @@ -4,6 +4,7 @@ // 2.0. package org.elasticsearch.xpack.esql.expression.function.scalar.convert; +import java.lang.NumberFormatException; import java.lang.Override; import java.lang.String; import org.apache.lucene.util.BytesRef; @@ -39,7 +40,7 @@ public Block evalVector(Vector v) { if (vector.isConstant()) { try { return driverContext.blockFactory().newConstantLongBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); return driverContext.blockFactory().newConstantNullBlock(positionCount); } @@ -48,7 +49,7 @@ public Block evalVector(Vector v) { for (int p = 0; p < positionCount; p++) { try { builder.appendLong(evalValue(vector, p, scratchPad)); - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); builder.appendNull(); } @@ -83,7 +84,7 @@ public Block evalBlock(Block b) { } builder.appendLong(value); valuesAppended = true; - } catch (Exception e) { + } catch (NumberFormatException e) { registerException(e); } } diff --git a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToVersionFromStringEvaluator.java b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToVersionFromStringEvaluator.java index 14057b0010d93..5945129a8ae05 100644 --- a/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToVersionFromStringEvaluator.java +++ b/x-pack/plugin/esql/src/main/java/generated/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToVersionFromStringEvaluator.java @@ -36,21 +36,11 @@ public Block evalVector(Vector v) { int positionCount = v.getPositionCount(); BytesRef scratchPad = new BytesRef(); if (vector.isConstant()) { - try { - return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0, scratchPad), positionCount); - } catch (Exception e) { - registerException(e); - return driverContext.blockFactory().newConstantNullBlock(positionCount); - } + return driverContext.blockFactory().newConstantBytesRefBlockWith(evalValue(vector, 0, scratchPad), positionCount); } try (BytesRefBlock.Builder builder = driverContext.blockFactory().newBytesRefBlockBuilder(positionCount)) { for (int p = 0; p < positionCount; p++) { - try { - builder.appendBytesRef(evalValue(vector, p, scratchPad)); - } catch (Exception e) { - registerException(e); - builder.appendNull(); - } + builder.appendBytesRef(evalValue(vector, p, scratchPad)); } return builder.build(); } @@ -74,17 +64,13 @@ public Block evalBlock(Block b) { boolean positionOpened = false; boolean valuesAppended = false; for (int i = start; i < end; i++) { - try { - BytesRef value = evalValue(block, i, scratchPad); - if (positionOpened == false && valueCount > 1) { - builder.beginPositionEntry(); - positionOpened = true; - } - builder.appendBytesRef(value); - valuesAppended = true; - } catch (Exception e) { - registerException(e); + BytesRef value = evalValue(block, i, scratchPad); + if (positionOpened == false && valueCount > 1) { + builder.beginPositionEntry(); + positionOpened = true; } + builder.appendBytesRef(value); + valuesAppended = true; } if (valuesAppended == false) { builder.appendNull(); diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetime.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetime.java index d73cb59308be7..9910447708b44 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetime.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDatetime.java @@ -60,7 +60,7 @@ protected NodeInfo info() { return NodeInfo.create(this, ToDatetime::new, field()); } - @ConvertEvaluator(extraName = "FromString") + @ConvertEvaluator(extraName = "FromString", warnExceptions = { IllegalArgumentException.class }) static long fromKeyword(BytesRef in) { return DateParse.process(in, DateParse.DEFAULT_FORMATTER); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDouble.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDouble.java index 9972ae1d3dd81..e83a0eae8d7a8 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDouble.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToDouble.java @@ -67,7 +67,7 @@ static double fromBoolean(boolean bool) { return bool ? 1d : 0d; } - @ConvertEvaluator(extraName = "FromString") + @ConvertEvaluator(extraName = "FromString", warnExceptions = { NumberFormatException.class }) static double fromKeyword(BytesRef in) { return Double.parseDouble(in.utf8ToString()); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIP.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIP.java index 07c0bfedb98c9..4829d39b09d65 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIP.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToIP.java @@ -52,7 +52,7 @@ protected NodeInfo info() { return NodeInfo.create(this, ToIP::new, field()); } - @ConvertEvaluator(extraName = "FromString") + @ConvertEvaluator(extraName = "FromString", warnExceptions = { IllegalArgumentException.class }) static BytesRef fromKeyword(BytesRef asString) { return parseIP(asString.utf8ToString()); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToInteger.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToInteger.java index 3f3b492095949..480962ca27f86 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToInteger.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToInteger.java @@ -9,6 +9,8 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.compute.ann.ConvertEvaluator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; @@ -68,7 +70,7 @@ static int fromBoolean(boolean bool) { return bool ? 1 : 0; } - @ConvertEvaluator(extraName = "FromString") + @ConvertEvaluator(extraName = "FromString", warnExceptions = { NumberFormatException.class }) static int fromKeyword(BytesRef in) { String asString = in.utf8ToString(); try { @@ -82,17 +84,17 @@ static int fromKeyword(BytesRef in) { } } - @ConvertEvaluator(extraName = "FromDouble") + @ConvertEvaluator(extraName = "FromDouble", warnExceptions = { InvalidArgumentException.class, QlIllegalArgumentException.class }) static int fromDouble(double dbl) { return fromLong(safeDoubleToLong(dbl)); } - @ConvertEvaluator(extraName = "FromUnsignedLong") + @ConvertEvaluator(extraName = "FromUnsignedLong", warnExceptions = { InvalidArgumentException.class, QlIllegalArgumentException.class }) static int fromUnsignedLong(long lng) { return fromLong(ToLong.fromUnsignedLong(lng)); } - @ConvertEvaluator(extraName = "FromLong") + @ConvertEvaluator(extraName = "FromLong", warnExceptions = { InvalidArgumentException.class, QlIllegalArgumentException.class }) static int fromLong(long lng) { return safeToInt(lng); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLong.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLong.java index e7f60abc6c3d4..8907ba930024e 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLong.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLong.java @@ -9,6 +9,8 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.compute.ann.ConvertEvaluator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; @@ -69,7 +71,7 @@ static long fromBoolean(boolean bool) { return bool ? 1L : 0L; } - @ConvertEvaluator(extraName = "FromString") + @ConvertEvaluator(extraName = "FromString", warnExceptions = { NumberFormatException.class }) static long fromKeyword(BytesRef in) { String asString = in.utf8ToString(); try { @@ -83,12 +85,12 @@ static long fromKeyword(BytesRef in) { } } - @ConvertEvaluator(extraName = "FromDouble") + @ConvertEvaluator(extraName = "FromDouble", warnExceptions = { InvalidArgumentException.class, QlIllegalArgumentException.class }) static long fromDouble(double dbl) { return safeDoubleToLong(dbl); } - @ConvertEvaluator(extraName = "FromUnsignedLong") + @ConvertEvaluator(extraName = "FromUnsignedLong", warnExceptions = { InvalidArgumentException.class, QlIllegalArgumentException.class }) static long fromUnsignedLong(long ul) { return safeToLong(unsignedLongAsNumber(ul)); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLong.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLong.java index be96fdb7139d1..1b7ee01e50c54 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLong.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToUnsignedLong.java @@ -9,6 +9,8 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.compute.ann.ConvertEvaluator; +import org.elasticsearch.xpack.ql.InvalidArgumentException; +import org.elasticsearch.xpack.ql.QlIllegalArgumentException; import org.elasticsearch.xpack.ql.expression.Expression; import org.elasticsearch.xpack.ql.tree.NodeInfo; import org.elasticsearch.xpack.ql.tree.Source; @@ -70,13 +72,13 @@ static long fromBoolean(boolean bool) { return bool ? ONE_AS_UNSIGNED_LONG : ZERO_AS_UNSIGNED_LONG; } - @ConvertEvaluator(extraName = "FromString") + @ConvertEvaluator(extraName = "FromString", warnExceptions = { NumberFormatException.class }) static long fromKeyword(BytesRef in) { String asString = in.utf8ToString(); return asLongUnsigned(safeToUnsignedLong(asString)); } - @ConvertEvaluator(extraName = "FromDouble") + @ConvertEvaluator(extraName = "FromDouble", warnExceptions = { InvalidArgumentException.class, QlIllegalArgumentException.class }) static long fromDouble(double dbl) { return asLongUnsigned(safeToUnsignedLong(dbl)); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java index a4c5638ae815f..094ecc9bfe569 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java @@ -297,7 +297,6 @@ public final void testCrankyEvaluateBlockWithoutNulls() { * input pattern contained only a single value. *

*/ - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100820") public final void testCrankyEvaluateBlockWithoutNullsFloating() { assumeTrue("sometimes the cranky breaker silences warnings, just skip these cases", testCase.getExpectedWarnings() == null); try { From d13368404d32354214d7b46b161762174fd3b1ca Mon Sep 17 00:00:00 2001 From: William Brafford Date: Fri, 3 Nov 2023 15:09:30 -0400 Subject: [PATCH 08/14] Don't update system index mappings in mixed clusters (#101778) * Don't update system index mappings in mixed clusters #99668 seems to have introduced a bug where SystemIndexMappingUpdateService updates system index mappings even in mixed clusters. This PR restores the old version-based check in order to be sure that there's no update until the cluster is fully upgraded. The timing of the mapping update seems to be causing worse problems, corrupting persisted cluster state. Fixes #99778, #101331 * Remove broken assertion The compatibility versions objects are not showing up correctly, so we shouldn't assert on them. --- docs/changelog/101778.yaml | 7 +++++++ .../test/java/org/elasticsearch/upgrades/RecoveryIT.java | 2 -- .../indices/SystemIndexMappingUpdateService.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 docs/changelog/101778.yaml diff --git a/docs/changelog/101778.yaml b/docs/changelog/101778.yaml new file mode 100644 index 0000000000000..9ad2f0c9154c3 --- /dev/null +++ b/docs/changelog/101778.yaml @@ -0,0 +1,7 @@ +pr: 101778 +summary: Don't update system index mappings in mixed clusters +area: Infra/Core +type: bug +issues: + - 101331 + - 99778 diff --git a/qa/rolling-upgrade-legacy/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade-legacy/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java index eb05d331af033..7af6ad49fb001 100644 --- a/qa/rolling-upgrade-legacy/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade-legacy/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java @@ -8,7 +8,6 @@ package org.elasticsearch.upgrades; import org.apache.http.util.EntityUtils; -import org.apache.lucene.tests.util.LuceneTestCase; import org.elasticsearch.Version; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Request; @@ -54,7 +53,6 @@ /** * In depth testing of the recovery mechanism during a rolling restart. */ -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/99778") public class RecoveryIT extends AbstractRollingTestCase { private static String CLUSTER_NAME = System.getProperty("tests.clustername"); diff --git a/server/src/main/java/org/elasticsearch/indices/SystemIndexMappingUpdateService.java b/server/src/main/java/org/elasticsearch/indices/SystemIndexMappingUpdateService.java index a0667db91daf6..6f272d29efee2 100644 --- a/server/src/main/java/org/elasticsearch/indices/SystemIndexMappingUpdateService.java +++ b/server/src/main/java/org/elasticsearch/indices/SystemIndexMappingUpdateService.java @@ -92,7 +92,7 @@ public void clusterChanged(ClusterChangedEvent event) { } // if we're in a mixed-version cluster, exit - if (state.hasMixedSystemIndexVersions()) { + if (state.nodes().getMaxNodeVersion().after(state.nodes().getSmallestNonClientNodeVersion())) { logger.debug("Skipping system indices up-to-date check as cluster has mixed versions"); return; } From 4952f986ce9dc3ead98f09de5e27f3ef0310b236 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 3 Nov 2023 15:59:09 -0600 Subject: [PATCH 09/14] Modularize shard availability service (#101796) * Modularize shard availability service This commit moves the `ShardsAvailabilityHealthIndicatorService` to a package and modularizes it with exports so that Serverless can make use of it as a superclass. Relates to #101394 --- benchmarks/build.gradle | 3 +- ...sAvailabilityHealthIndicatorBenchmark.java | 2 +- .../src/main/java/module-info.java | 12 ++++ .../plugin/ShardsAvailabilityPlugin.java | 2 +- ...sAvailabilityHealthIndicatorServiceIT.java | 3 +- server/src/main/java/module-info.java | 2 + ...rdsAvailabilityHealthIndicatorService.java | 35 ++++++----- .../ShardsAvailabilityActionGuideTests.java | 42 ++++++------- ...ailabilityHealthIndicatorServiceTests.java | 59 +++++++++++-------- ...ierShardAvailabilityHealthIndicatorIT.java | 4 +- 10 files changed, 97 insertions(+), 67 deletions(-) create mode 100644 modules/health-shards-availability/src/main/java/module-info.java rename server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/{ => shards}/ShardsAvailabilityHealthIndicatorServiceIT.java (97%) rename server/src/main/java/org/elasticsearch/cluster/routing/allocation/{ => shards}/ShardsAvailabilityHealthIndicatorService.java (97%) rename server/src/test/java/org/elasticsearch/cluster/routing/allocation/{ => shards}/ShardsAvailabilityHealthIndicatorServiceTests.java (96%) diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 7cfa23e69ff96..3519434e07d42 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -8,7 +8,8 @@ import org.elasticsearch.gradle.internal.info.BuildParams * Side Public License, v 1. */ -apply plugin: 'elasticsearch.java' +apply plugin: org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin +apply plugin: 'java-library' apply plugin: 'application' application { diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java index 30b37c018af01..ef834fad424e3 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java @@ -21,7 +21,7 @@ import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.DataTier; -import org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService; +import org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; diff --git a/modules/health-shards-availability/src/main/java/module-info.java b/modules/health-shards-availability/src/main/java/module-info.java new file mode 100644 index 0000000000000..4ee4cafeb5f96 --- /dev/null +++ b/modules/health-shards-availability/src/main/java/module-info.java @@ -0,0 +1,12 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +module org.elasticsearch.shardhealth { + requires org.elasticsearch.server; + requires org.apache.lucene.core; +} diff --git a/modules/health-shards-availability/src/main/java/org/elasticsearch/health/plugin/ShardsAvailabilityPlugin.java b/modules/health-shards-availability/src/main/java/org/elasticsearch/health/plugin/ShardsAvailabilityPlugin.java index aeb45424ebc58..eac72c36bef18 100644 --- a/modules/health-shards-availability/src/main/java/org/elasticsearch/health/plugin/ShardsAvailabilityPlugin.java +++ b/modules/health-shards-availability/src/main/java/org/elasticsearch/health/plugin/ShardsAvailabilityPlugin.java @@ -9,7 +9,7 @@ package org.elasticsearch.health.plugin; import org.apache.lucene.util.SetOnce; -import org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService; +import org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService; import org.elasticsearch.health.HealthIndicatorService; import org.elasticsearch.plugins.HealthPlugin; import org.elasticsearch.plugins.Plugin; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorServiceIT.java similarity index 97% rename from server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceIT.java rename to server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorServiceIT.java index e85edc5805482..b862d0b2f20b6 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorServiceIT.java @@ -6,13 +6,14 @@ * Side Public License, v 1. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.cluster.routing.allocation.shards; import org.elasticsearch.action.admin.indices.shrink.ResizeType; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.RoutingNodes; +import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.health.HealthIndicatorResult; diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index d8b45adbebb1f..98dd182900f88 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -419,4 +419,6 @@ org.elasticsearch.index.codec.bloomfilter.ES85BloomFilterPostingsFormat, org.elasticsearch.index.codec.bloomfilter.ES87BloomFilterPostingsFormat; provides org.apache.lucene.codecs.DocValuesFormat with ES87TSDBDocValuesFormat; + + exports org.elasticsearch.cluster.routing.allocation.shards to org.elasticsearch.shardhealth, org.elasticsearch.serverless.shardhealth; } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorService.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java similarity index 97% rename from server/src/main/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorService.java rename to server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java index d17f3a297e805..76ca9f88b4b58 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorService.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.cluster.routing.allocation.shards; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -25,6 +25,13 @@ import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; +import org.elasticsearch.cluster.routing.allocation.AllocateUnassignedDecision; +import org.elasticsearch.cluster.routing.allocation.AllocationDecision; +import org.elasticsearch.cluster.routing.allocation.AllocationService; +import org.elasticsearch.cluster.routing.allocation.DataTier; +import org.elasticsearch.cluster.routing.allocation.NodeAllocationResult; +import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; +import org.elasticsearch.cluster.routing.allocation.ShardAllocationDecision; import org.elasticsearch.cluster.routing.allocation.decider.Decision; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider; @@ -127,7 +134,7 @@ public String name() { * @param metadata Metadata for the cluster * @return A new ShardAllocationStatus that has not yet been filled. */ - ShardAllocationStatus createNewStatus(Metadata metadata) { + public ShardAllocationStatus createNewStatus(Metadata metadata) { return new ShardAllocationStatus(metadata); } @@ -415,18 +422,18 @@ static void updateShardAllocationStatus( ) ); - class ShardAllocationCounts { + public class ShardAllocationCounts { int unassigned = 0; int unassigned_new = 0; int unassigned_restarting = 0; int initializing = 0; int started = 0; int relocating = 0; - final Set indicesWithUnavailableShards = new HashSet<>(); - final Set indicesWithAllShardsUnavailable = new HashSet<>(); + public final Set indicesWithUnavailableShards = new HashSet<>(); + public final Set indicesWithAllShardsUnavailable = new HashSet<>(); // We keep the searchable snapshots separately as long as the original index is still available // This is checked during the post-processing - SearchableSnapshotsState searchableSnapshotsState = new SearchableSnapshotsState(); + public SearchableSnapshotsState searchableSnapshotsState = new SearchableSnapshotsState(); final Map> diagnosisDefinitions = new HashMap<>(); public void increment(ShardRouting routing, ClusterState state, NodesShutdownMetadata shutdowns, boolean verbose) { @@ -675,7 +682,7 @@ List checkIsAllocationDisabled(IndexMetadata indexMetadata * @param clusterState the current cluster state. * @return A list of diagnoses for the provided unassigned shard */ - List checkDataTierRelatedIssues( + public List checkDataTierRelatedIssues( IndexMetadata indexMetadata, List nodeAllocationResults, ClusterState clusterState @@ -849,12 +856,12 @@ private static Optional checkNotEnoughNodesInDataTier( } } - class ShardAllocationStatus { - final ShardAllocationCounts primaries = new ShardAllocationCounts(); - final ShardAllocationCounts replicas = new ShardAllocationCounts(); - final Metadata clusterMetadata; + public class ShardAllocationStatus { + protected final ShardAllocationCounts primaries = new ShardAllocationCounts(); + protected final ShardAllocationCounts replicas = new ShardAllocationCounts(); + protected final Metadata clusterMetadata; - ShardAllocationStatus(Metadata clusterMetadata) { + public ShardAllocationStatus(Metadata clusterMetadata) { this.clusterMetadata = clusterMetadata; } @@ -1149,7 +1156,7 @@ static List getRestoreFromSnapshotAffectedResources( } } - static class SearchableSnapshotsState { + public static class SearchableSnapshotsState { private final Set searchableSnapshotWithUnavailableShard = new HashSet<>(); private final Set searchableSnapshotWithOriginalIndexAvailable = new HashSet<>(); @@ -1161,7 +1168,7 @@ void addSearchableSnapshotWithOriginalIndexAvailable(String indexName) { searchableSnapshotWithOriginalIndexAvailable.add(indexName); } - Set getRedSearchableSnapshots() { + public Set getRedSearchableSnapshots() { return Sets.difference(searchableSnapshotWithUnavailableShard, searchableSnapshotWithOriginalIndexAvailable); } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityActionGuideTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityActionGuideTests.java index e059f96474db5..4777b0eb357da 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityActionGuideTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityActionGuideTests.java @@ -10,27 +10,27 @@ import org.elasticsearch.test.ESTestCase; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_CHECK_ALLOCATION_EXPLAIN_API; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_CLUSTER_ROUTING_ALLOCATION; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_INDEX_ROUTING_ALLOCATION; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_TIERS_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_NODE_CAPACITY; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_INCLUDE_DATA; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_REQUIRE_DATA; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_RESTORE_FROM_SNAPSHOT; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.DIAGNOSE_SHARDS_ACTION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ENABLE_CLUSTER_ALLOCATION_ACTION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ENABLE_INDEX_ALLOCATION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ENABLE_TIER_ACTION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.INCREASE_CLUSTER_SHARD_LIMIT_ACTION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.INCREASE_SHARD_LIMIT_ACTION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.MIGRATE_TO_TIERS_ACTION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.RESTORE_FROM_SNAPSHOT_ACTION_GUIDE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.TIER_CAPACITY_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_CHECK_ALLOCATION_EXPLAIN_API; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_CLUSTER_ROUTING_ALLOCATION; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_INDEX_ROUTING_ALLOCATION; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_TIERS_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_NODE_CAPACITY; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_INCLUDE_DATA; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_REQUIRE_DATA; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_RESTORE_FROM_SNAPSHOT; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.DIAGNOSE_SHARDS_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ENABLE_CLUSTER_ALLOCATION_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ENABLE_INDEX_ALLOCATION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ENABLE_TIER_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.INCREASE_CLUSTER_SHARD_LIMIT_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.INCREASE_SHARD_LIMIT_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.MIGRATE_TO_TIERS_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.RESTORE_FROM_SNAPSHOT_ACTION_GUIDE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.TIER_CAPACITY_ACTION_GUIDE; import static org.hamcrest.Matchers.is; public class ShardsAvailabilityActionGuideTests extends ESTestCase { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorServiceTests.java similarity index 96% rename from server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceTests.java rename to server/src/test/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorServiceTests.java index b333e1cdf6fa9..9ab44ec3fb047 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorServiceTests.java @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -package org.elasticsearch.cluster.routing.allocation; +package org.elasticsearch.cluster.routing.allocation.shards; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -24,13 +24,19 @@ import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; -import org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ShardAllocationStatus; +import org.elasticsearch.cluster.routing.allocation.AllocateUnassignedDecision; +import org.elasticsearch.cluster.routing.allocation.AllocationService; +import org.elasticsearch.cluster.routing.allocation.DataTier; +import org.elasticsearch.cluster.routing.allocation.MoveDecision; +import org.elasticsearch.cluster.routing.allocation.NodeAllocationResult; +import org.elasticsearch.cluster.routing.allocation.ShardAllocationDecision; import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.Decision; import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.FilterAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider; +import org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ShardAllocationStatus; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; @@ -54,6 +60,7 @@ import org.elasticsearch.snapshots.SearchableSnapshotsSettings; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; +import org.mockito.Mockito; import org.mockito.stubbing.Answer; import java.util.ArrayList; @@ -74,30 +81,30 @@ import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX; import static org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata.Type.RESTART; import static org.elasticsearch.cluster.routing.ShardRouting.newUnassigned; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_CHECK_ALLOCATION_EXPLAIN_API; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_CLUSTER_ROUTING_ALLOCATION; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_INDEX_ROUTING_ALLOCATION; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_TIERS_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_NODE_CAPACITY; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_TIER_CAPACITY_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_INCLUDE_DATA; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_INCLUDE_DATA_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_REQUIRE_DATA; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_REQUIRE_DATA_LOOKUP; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.ACTION_RESTORE_FROM_SNAPSHOT; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.DIAGNOSIS_WAIT_FOR_INITIALIZATION; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.DIAGNOSIS_WAIT_FOR_OR_FIX_DELAYED_SHARDS; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService.NAME; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.AVAILABLE; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.CREATING; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.INITIALIZING; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.RESTARTING; -import static org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.UNAVAILABLE; import static org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_CHECK_ALLOCATION_EXPLAIN_API; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_CLUSTER_ROUTING_ALLOCATION; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_INDEX_ROUTING_ALLOCATION; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_ENABLE_TIERS_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_NODE_CAPACITY; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_CLUSTER_SETTING_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_SHARD_LIMIT_INDEX_SETTING_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_INCREASE_TIER_CAPACITY_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_INCLUDE_DATA; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_INCLUDE_DATA_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_REQUIRE_DATA; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_MIGRATE_TIERS_AWAY_FROM_REQUIRE_DATA_LOOKUP; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.ACTION_RESTORE_FROM_SNAPSHOT; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.DIAGNOSIS_WAIT_FOR_INITIALIZATION; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.DIAGNOSIS_WAIT_FOR_OR_FIX_DELAYED_SHARDS; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService.NAME; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.AVAILABLE; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.CREATING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.INITIALIZING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.RESTARTING; +import static org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorServiceTests.ShardState.UNAVAILABLE; import static org.elasticsearch.common.util.CollectionUtils.concatLists; import static org.elasticsearch.core.TimeValue.timeValueSeconds; import static org.elasticsearch.health.Diagnosis.Resource.Type.FEATURE_STATE; @@ -2233,7 +2240,7 @@ private static ShardsAvailabilityHealthIndicatorService createAllocationHealthIn when(clusterService.state()).thenReturn(clusterState); var clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); when(clusterService.getClusterSettings()).thenReturn(clusterSettings); - var allocationService = mock(AllocationService.class); + var allocationService = Mockito.mock(AllocationService.class); when(allocationService.explainShardAllocation(any(), any())).thenAnswer((Answer) invocation -> { ShardRouting shardRouting = invocation.getArgument(0); var key = new ShardRoutingKey(shardRouting.getIndexName(), shardRouting.getId(), shardRouting.primary()); diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java index 7737a5b42dfae..82784d9112a1b 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java @@ -17,7 +17,7 @@ import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.routing.allocation.DataTier; -import org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService; +import org.elasticsearch.cluster.routing.allocation.shards.ShardsAvailabilityHealthIndicatorService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.core.TimeValue; @@ -42,7 +42,7 @@ import static org.hamcrest.Matchers.hasItem; /** - * Contains all integration tests for the {@link org.elasticsearch.cluster.routing.allocation.ShardsAvailabilityHealthIndicatorService} + * Contains all integration tests for the {@link ShardsAvailabilityHealthIndicatorService} * that require the data tiers allocation decider logic. */ @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0) From b620c5c2e6960d503a761b6e60e13cce50d0a69f Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Fri, 3 Nov 2023 18:24:05 -0500 Subject: [PATCH 10/14] Correctly logging watcher history write failures (#101802) It looks like failures to write watcher history have not been getting logged since watcher history became a data stream. This updates the filter to look for errors writing to the watcher history data stream. --- docs/changelog/101802.yaml | 5 +++++ .../main/java/org/elasticsearch/xpack/watcher/Watcher.java | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 docs/changelog/101802.yaml diff --git a/docs/changelog/101802.yaml b/docs/changelog/101802.yaml new file mode 100644 index 0000000000000..20e857c32f664 --- /dev/null +++ b/docs/changelog/101802.yaml @@ -0,0 +1,5 @@ +pr: 101802 +summary: Correctly logging watcher history write failures +area: Watcher +type: bug +issues: [] diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index a46b42e2153bd..a32edf1a0545c 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -19,6 +19,7 @@ import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.OriginSettingClient; +import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.metadata.IndexTemplateMetadata; @@ -423,7 +424,7 @@ public void afterBulk(long executionId, BulkRequest request, BulkResponse respon .collect(Collectors.toMap(BulkItemResponse::getId, BulkItemResponse::getFailureMessage)); Map historyFailures = Arrays.stream(response.getItems()) .filter(BulkItemResponse::isFailed) - .filter(r -> r.getIndex().startsWith(HistoryStoreField.INDEX_PREFIX)) + .filter(r -> r.getIndex().startsWith(DataStream.BACKING_INDEX_PREFIX + HistoryStoreField.DATA_STREAM)) .collect(Collectors.toMap(BulkItemResponse::getId, BulkItemResponse::getFailureMessage)); if (triggeredFailures.isEmpty() == false) { String failure = String.join(", ", triggeredFailures.values()); @@ -444,7 +445,7 @@ public void afterBulk(long executionId, BulkRequest request, BulkResponse respon Map overwrittenIds = Arrays.stream(response.getItems()) .filter(BulkItemResponse::isFailed) - .filter(r -> r.getIndex().startsWith(HistoryStoreField.INDEX_PREFIX)) + .filter(r -> r.getIndex().startsWith(DataStream.BACKING_INDEX_PREFIX + HistoryStoreField.DATA_STREAM)) .filter(r -> r.getVersion() > 1) .collect(Collectors.toMap(BulkItemResponse::getId, BulkItemResponse::getFailureMessage)); if (overwrittenIds.isEmpty() == false) { From 4dff9cd5fac558fe8961dd3a0d0de3a23268b82e Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Sat, 4 Nov 2023 20:29:36 +0100 Subject: [PATCH 11/14] Cleanup dead code in o.e.s.aggregations (#101806) Just a few mostly automated obvious dead code removals. --- .../aggregations/AdaptingAggregator.java | 4 - .../aggregations/AggregationBuilders.java | 8 -- .../aggregations/AggregatorFactory.java | 2 - .../PipelineAggregationBuilder.java | 15 --- .../PipelineAggregatorBuilders.java | 5 - .../bucket/IteratorAndCurrent.java | 4 - .../bucket/composite/BinaryValuesSource.java | 2 +- .../DateHistogramValuesSourceBuilder.java | 7 -- .../bucket/composite/DoubleValuesSource.java | 2 +- .../composite/GlobalOrdinalValuesSource.java | 2 +- .../HistogramValuesSourceBuilder.java | 7 -- .../bucket/composite/LongValuesSource.java | 2 +- .../SingleDimensionValuesSource.java | 5 - .../filter/FiltersAggregationBuilder.java | 7 -- .../geogrid/GeoGridAggregationBuilder.java | 8 -- .../DateHistogramAggregationBuilder.java | 5 - .../DateHistogramAggregatorFactory.java | 4 - .../bucket/histogram/DateIntervalWrapper.java | 9 -- .../HistogramAggregationBuilder.java | 4 - .../histogram/HistogramAggregatorFactory.java | 4 - .../histogram/InternalDateHistogram.java | 4 - .../InternalVariableWidthHistogram.java | 12 +-- .../ParsedVariableWidthHistogram.java | 20 ---- .../SizedBucketAggregatorBuilder.java | 18 ---- ...iableWidthHistogramAggregationBuilder.java | 4 - .../nested/NestedAggregationBuilder.java | 7 -- .../ReverseNestedAggregationBuilder.java | 7 -- .../nested/ReverseNestedAggregator.java | 5 +- .../bucket/prefix/IpPrefixAggregator.java | 16 ---- .../range/AbstractRangeAggregatorFactory.java | 4 - .../range/DateRangeAggregationBuilder.java | 8 -- .../range/DateRangeAggregatorFactory.java | 14 +-- .../range/GeoDistanceAggregationBuilder.java | 12 --- .../bucket/range/InternalDateRange.java | 17 ---- .../bucket/range/InternalGeoDistance.java | 14 --- .../bucket/range/InternalRange.java | 10 -- .../range/IpRangeAggregationBuilder.java | 18 ---- .../bucket/range/RangeAggregationBuilder.java | 7 -- .../bucket/range/RangeAggregator.java | 8 -- .../bucket/range/RangeAggregatorFactory.java | 14 +-- .../DiversifiedAggregationBuilder.java | 21 ----- .../sampler/SamplerAggregationBuilder.java | 7 -- .../RandomSamplerAggregationBuilder.java | 13 --- .../bucket/terms/InternalMappedRareTerms.java | 8 -- .../bucket/terms/InternalRareTerms.java | 5 - .../bucket/terms/LongRareTerms.java | 5 - .../terms/RareTermsAggregationBuilder.java | 7 -- .../terms/RareTermsAggregatorFactory.java | 15 --- .../bucket/terms/SignificanceLookup.java | 4 +- .../SignificantTermsAggregationBuilder.java | 19 ---- .../SignificantTextAggregationBuilder.java | 20 ---- .../bucket/terms/StringRareTerms.java | 5 - .../bucket/terms/UnmappedRareTerms.java | 4 - .../terms/heuristic/PercentageScore.java | 14 --- ...AbstractPercentilesAggregationBuilder.java | 7 -- .../ExtendedStatsAggregationBuilder.java | 4 - .../metrics/GeoBoundsAggregationBuilder.java | 7 -- .../metrics/HyperLogLogPlusPlus.java | 2 - .../metrics/ParsedExtendedStats.java | 3 - .../metrics/TopHitsAggregationBuilder.java | 91 ------------------- .../AbstractPipelineAggregationBuilder.java | 4 - ...cketMetricsPipelineAggregationBuilder.java | 7 -- ...ucketScriptPipelineAggregationBuilder.java | 14 --- ...mulativeSumPipelineAggregationBuilder.java | 7 -- .../pipeline/ParsedDerivative.java | 10 -- ...tilesBucketPipelineAggregationBuilder.java | 7 -- .../SerialDiffPipelineAggregationBuilder.java | 21 ----- .../aggregations/support/AggregationInfo.java | 4 - .../support/TimeSeriesValuesSourceType.java | 4 - 69 files changed, 11 insertions(+), 653 deletions(-) delete mode 100644 server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/SizedBucketAggregatorBuilder.java diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/AdaptingAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/AdaptingAggregator.java index 0be4e7f729bbf..f96b732b9464f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/AdaptingAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/AdaptingAggregator.java @@ -130,10 +130,6 @@ public void collectDebugInfo(BiConsumer add) { add.accept("delegate_debug", delegateDebug); } - public Aggregator delegate() { - return delegate; - } - @Override public String toString() { return name(); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilders.java b/server/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilders.java index 3f998bffd1860..d78567f3effdb 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilders.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/AggregationBuilders.java @@ -75,7 +75,6 @@ import org.elasticsearch.search.aggregations.metrics.TopHitsAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.ValueCount; import org.elasticsearch.search.aggregations.metrics.ValueCountAggregationBuilder; -import org.elasticsearch.search.aggregations.metrics.WeightedAvgAggregationBuilder; import java.util.List; @@ -100,13 +99,6 @@ public static AvgAggregationBuilder avg(String name) { return new AvgAggregationBuilder(name); } - /** - * Create a new {@link Avg} aggregation with the given name. - */ - public static WeightedAvgAggregationBuilder weightedAvg(String name) { - return new WeightedAvgAggregationBuilder(name); - } - /** * Create a new {@link Max} aggregation with the given name. */ diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java index bf74494e872bb..15b5c29589227 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java @@ -64,8 +64,6 @@ public String name() { return name; } - public void doValidate() {} - protected abstract Aggregator createInternal(Aggregator parent, CardinalityUpperBound cardinality, Map metadata) throws IOException; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregationBuilder.java index c43eb252a5364..153a54bf890e4 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregationBuilder.java @@ -112,11 +112,6 @@ public Collection getSiblingAggregations() { return siblingAggregations; } - @Override - public Collection getSiblingPipelineAggregations() { - return siblingPipelineAggregations; - } - @Override public void validateHasParent(String type, String name) { addValidationError(type + " aggregation [" + name + "] must be declared inside of another aggregation"); @@ -155,11 +150,6 @@ public Collection getSiblingAggregations() { return parent.getSubAggregations(); } - @Override - public Collection getSiblingPipelineAggregations() { - return parent.getPipelineAggregations(); - } - @Override public void validateHasParent(String type, String name) { // There is a parent inside the tree. @@ -181,11 +171,6 @@ public void validateParentAggSequentiallyOrderedWithoutSkips(String type, String */ public abstract Collection getSiblingAggregations(); - /** - * Pipeline aggregations that are siblings to the aggregation being validated. - */ - public abstract Collection getSiblingPipelineAggregations(); - /** * Add a validation error to this context. All validation errors * are accumulated in a list and, if there are any, the request diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregatorBuilders.java b/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregatorBuilders.java index f280eb4de61bb..61da00241a4ea 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregatorBuilders.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/PipelineAggregatorBuilders.java @@ -11,7 +11,6 @@ import org.elasticsearch.script.Script; import org.elasticsearch.search.aggregations.pipeline.AvgBucketPipelineAggregationBuilder; import org.elasticsearch.search.aggregations.pipeline.BucketScriptPipelineAggregationBuilder; -import org.elasticsearch.search.aggregations.pipeline.CumulativeSumPipelineAggregationBuilder; import org.elasticsearch.search.aggregations.pipeline.ExtendedStatsBucketPipelineAggregationBuilder; import org.elasticsearch.search.aggregations.pipeline.MaxBucketPipelineAggregationBuilder; import org.elasticsearch.search.aggregations.pipeline.MinBucketPipelineAggregationBuilder; @@ -62,10 +61,6 @@ public static BucketScriptPipelineAggregationBuilder bucketScript(String name, S return new BucketScriptPipelineAggregationBuilder(name, script, bucketsPaths); } - public static CumulativeSumPipelineAggregationBuilder cumulativeSum(String name, String bucketsPath) { - return new CumulativeSumPipelineAggregationBuilder(name, bucketsPath); - } - public static SerialDiffPipelineAggregationBuilder diff(String name, String bucketsPath) { return new SerialDiffPipelineAggregationBuilder(name, bucketsPath); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/IteratorAndCurrent.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/IteratorAndCurrent.java index af8757e10ccf7..37c5f49dc55fe 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/IteratorAndCurrent.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/IteratorAndCurrent.java @@ -21,10 +21,6 @@ public IteratorAndCurrent(Iterator iterator) { this.current = iterator.next(); } - public Iterator getIterator() { - return iterator; - } - public B current() { return current; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/BinaryValuesSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/BinaryValuesSource.java index 58fd7f85f6076..62f587f5249d1 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/BinaryValuesSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/BinaryValuesSource.java @@ -48,7 +48,7 @@ class BinaryValuesSource extends SingleDimensionValuesSource { int size, int reverseMul ) { - super(bigArrays, format, fieldType, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, fieldType, missingBucket, missingOrder, reverseMul); this.breakerConsumer = breakerConsumer; this.docValuesFunc = docValuesFunc; this.values = bigArrays.newObjectArray(Math.min(size, 100)); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java index 2cd33e470e3e5..d31d3a18b3567 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java @@ -212,13 +212,6 @@ public ZoneId timeZone() { return timeZone; } - /** - * Get the offset to use when rounding, which is a number of milliseconds. - */ - public long offset() { - return offset; - } - /** * Set the offset on this builder, which is a number of milliseconds. * @return this for chaining diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DoubleValuesSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DoubleValuesSource.java index 2dc48b7ce0e2d..752c4ecf97401 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DoubleValuesSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/DoubleValuesSource.java @@ -43,7 +43,7 @@ class DoubleValuesSource extends SingleDimensionValuesSource { int size, int reverseMul ) { - super(bigArrays, format, fieldType, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, fieldType, missingBucket, missingOrder, reverseMul); this.docValuesFunc = docValuesFunc; this.bits = this.missingBucket ? new BitArray(100, bigArrays) : null; boolean success = false; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java index 855b456546314..f833bb39b3b56 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/GlobalOrdinalValuesSource.java @@ -76,7 +76,7 @@ class GlobalOrdinalValuesSource extends SingleDimensionValuesSource { int size, int reverseMul ) { - super(bigArrays, format, type, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, type, missingBucket, missingOrder, reverseMul); this.uniqueValueCount = uniqueValueCount; this.docValuesFunc = docValuesFunc; this.values = bigArrays.newLongArray(Math.min(size, 100), false); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java index e3ca337ef8a8c..9d17db7a77864 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java @@ -147,13 +147,6 @@ public String type() { return TYPE; } - /** - * Returns the interval that is set on this source - **/ - public double interval() { - return interval; - } - /** * Sets the interval on this source. **/ diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/LongValuesSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/LongValuesSource.java index 7613d926d3c6d..3d79509ad9377 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/LongValuesSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/LongValuesSource.java @@ -59,7 +59,7 @@ class LongValuesSource extends SingleDimensionValuesSource { int size, int reverseMul ) { - super(bigArrays, format, fieldType, missingBucket, missingOrder, size, reverseMul); + super(bigArrays, format, fieldType, missingBucket, missingOrder, reverseMul); this.bigArrays = bigArrays; this.docValuesFunc = docValuesFunc; this.rounding = rounding; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java index bd3c8b7eb322c..6376c5334d7b5 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/SingleDimensionValuesSource.java @@ -31,8 +31,6 @@ abstract class SingleDimensionValuesSource> implements R protected final MappedFieldType fieldType; protected final boolean missingBucket; protected final MissingOrder missingOrder; - - protected final int size; protected final int reverseMul; protected T afterValue; @@ -45,7 +43,6 @@ abstract class SingleDimensionValuesSource> implements R * @param fieldType The field type or null if the source is a script. * @param missingBucket If true, an explicit `null bucket represents documents with missing values. * @param missingOrder How to order missing buckets if missingBucket is true. - * @param size The number of values to record. * @param reverseMul -1 if the natural order ({@link SortOrder#ASC} should be reversed. */ SingleDimensionValuesSource( @@ -54,7 +51,6 @@ abstract class SingleDimensionValuesSource> implements R @Nullable MappedFieldType fieldType, boolean missingBucket, MissingOrder missingOrder, - int size, int reverseMul ) { this.bigArrays = bigArrays; @@ -62,7 +58,6 @@ abstract class SingleDimensionValuesSource> implements R this.fieldType = fieldType; this.missingBucket = missingBucket; this.missingOrder = missingOrder; - this.size = size; this.reverseMul = reverseMul; this.afterValue = null; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java index 81678404d1dab..c96fe5ad550f4 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/filter/FiltersAggregationBuilder.java @@ -198,13 +198,6 @@ public FiltersAggregationBuilder keyedBucket(boolean keyedBucket) { return this; } - /** - * Get whether to return keyed bucket in array - */ - public boolean keyedBucket() { - return keyedBucket; - } - @Override public BucketCardinality bucketCardinality() { return BucketCardinality.MANY; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java index 882b4960dd36c..ff9495ca4d825 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java @@ -151,10 +151,6 @@ public GeoGridAggregationBuilder size(int size) { return this; } - public int size() { - return requiredSize; - } - public GeoGridAggregationBuilder shardSize(int shardSize) { if (shardSize <= 0) { throw new IllegalArgumentException("[shardSize] must be greater than 0. Found [" + shardSize + "] in [" + name + "]"); @@ -163,10 +159,6 @@ public GeoGridAggregationBuilder shardSize(int shardSize) { return this; } - public int shardSize() { - return shardSize; - } - public GeoGridAggregationBuilder setGeoBoundingBox(GeoBoundingBox geoBoundingBox) { this.geoBoundingBox = geoBoundingBox; // no validation done here, similar to geo_bounding_box query behavior. diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java index ebbb290e1db9c..2653f9ac53553 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregationBuilder.java @@ -290,11 +290,6 @@ public DateHistogramAggregationBuilder extendedBounds(LongBounds extendedBounds) return this; } - /** Return hard bounds for this histogram, or {@code null} if none are set. */ - public LongBounds hardBounds() { - return hardBounds; - } - /** Set hard bounds on this histogram, specifying boundaries outside which buckets cannot be created. */ public DateHistogramAggregationBuilder hardBounds(LongBounds hardBounds) { if (hardBounds == null) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java index b62e3c9e91f6f..1a75766c40a6b 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java @@ -117,10 +117,6 @@ public DateHistogramAggregatorFactory( this.rounding = rounding; } - public long minDocCount() { - return minDocCount; - } - @Override protected Aggregator doCreateInternal(Aggregator parent, CardinalityUpperBound cardinality, Map metadata) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java index 7218bef0b9d9b..2371506082f1b 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.time.ZoneId; -import java.util.Locale; import java.util.Objects; import static org.elasticsearch.core.RestApiVersion.equalTo; @@ -59,10 +58,6 @@ public enum IntervalTypeEnum implements Writeable { @Deprecated LEGACY_DATE_HISTO(null); - public static IntervalTypeEnum fromString(String name) { - return valueOf(name.trim().toUpperCase(Locale.ROOT)); - } - public static IntervalTypeEnum fromStream(StreamInput in) throws IOException { return in.readEnum(IntervalTypeEnum.class); } @@ -72,10 +67,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeEnum(this); } - public String value() { - return name().toLowerCase(Locale.ROOT); - } - public boolean isValid() { // I'm being a little cheeky here and just reusing the name for signaling invlaid choices too return this.preferredName != null; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregationBuilder.java index 0740557a526d3..f5fb2d128f75f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregationBuilder.java @@ -216,10 +216,6 @@ public double maxBound() { return DoubleBounds.getEffectiveMax(extendedBounds); } - protected DoubleBounds extendedBounds() { - return extendedBounds; - } - /** * Set extended bounds on this builder: buckets between {@code minBound} and * {@code maxBound} will be created even if no documents fell into these diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java index d0ec504f0aa2b..ca61a5f4ddcf6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java @@ -84,10 +84,6 @@ public HistogramAggregatorFactory( this.hardBounds = hardBounds; } - public long minDocCount() { - return minDocCount; - } - @Override protected Aggregator doCreateInternal(Aggregator parent, CardinalityUpperBound cardinality, Map metadata) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java index 4eaec7034b7f4..ed883a4b04d6b 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogram.java @@ -269,10 +269,6 @@ public List getBuckets() { return Collections.unmodifiableList(buckets); } - DocValueFormat getFormatter() { - return format; - } - long getMinDocCount() { return minDocCount; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java index 9f464fa1b23cb..5686c0ea11dfa 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalVariableWidthHistogram.java @@ -187,10 +187,6 @@ public int compareKey(InternalVariableWidthHistogram.Bucket other) { return Double.compare(centroid, other.centroid); // Use centroid for bucket ordering } - public DocValueFormat getFormatter() { - return format; - } - Bucket finalizeSampling(SamplingContext samplingContext) { return new Bucket( centroid, @@ -282,10 +278,6 @@ public List getBuckets() { return Collections.unmodifiableList(buckets); } - DocValueFormat getFormatter() { - return format; - } - public int getTargetBuckets() { return targetNumBuckets; } @@ -525,7 +517,7 @@ private void mergeBucketsWithSameMin(List buckets, AggregationReduceCont * * After this adjustment, A will contain more values than indicated and B will have less. */ - private static void adjustBoundsForOverlappingBuckets(List buckets, AggregationReduceContext reduceContext) { + private static void adjustBoundsForOverlappingBuckets(List buckets) { for (int i = 1; i < buckets.size(); i++) { Bucket curBucket = buckets.get(i); Bucket prevBucket = buckets.get(i - 1); @@ -545,7 +537,7 @@ public InternalAggregation reduce(List aggregations, Aggreg if (reduceContext.isFinalReduce()) { buckets.sort(Comparator.comparing(Bucket::min)); mergeBucketsWithSameMin(reducedBuckets, reduceContext); - adjustBoundsForOverlappingBuckets(reducedBuckets, reduceContext); + adjustBoundsForOverlappingBuckets(reducedBuckets); } return new InternalVariableWidthHistogram(getName(), reducedBuckets, emptyBucketInfo, targetNumBuckets, format, metadata); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedVariableWidthHistogram.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedVariableWidthHistogram.java index cc29ce21c2507..ba33373354f3e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedVariableWidthHistogram.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/ParsedVariableWidthHistogram.java @@ -93,16 +93,6 @@ public double getMin() { return min; } - public String getMinAsString() { - if (minAsString != null) { - return minAsString; - } - if (min != null) { - return Double.toString(min); - } - return null; - } - public void setMax(Double max) { this.max = max; } @@ -115,16 +105,6 @@ public double getMax() { return max; } - public String getMaxAsString() { - if (maxAsString != null) { - return maxAsString; - } - if (max != null) { - return Double.toString(max); - } - return null; - } - static ParsedBucket fromXContent(XContentParser parser, boolean keyed) throws IOException { final ParsedBucket bucket = new ParsedBucket(); bucket.setKeyed(keyed); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/SizedBucketAggregatorBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/SizedBucketAggregatorBuilder.java deleted file mode 100644 index 55729094ace57..0000000000000 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/SizedBucketAggregatorBuilder.java +++ /dev/null @@ -1,18 +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 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 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.search.aggregations.bucket.histogram; - -import java.util.concurrent.TimeUnit; - -/** - * An aggregator capable of reporting bucket sizes in milliseconds. Used by RateAggregator for calendar-based buckets. - */ -public interface SizedBucketAggregatorBuilder { - double calendarDivider(TimeUnit timeUnit); -} diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregationBuilder.java index f7870df45648e..04e73691979f8 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregationBuilder.java @@ -114,10 +114,6 @@ public VariableWidthHistogramAggregationBuilder setInitialBuffer(int initialBuff return this; } - public int getNumBuckets() { - return numBuckets; - } - public int getShardSize() { if (shardSize == -1) { return numBuckets * 50; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java index f4ba3db383586..9df53a0cfe826 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregationBuilder.java @@ -69,13 +69,6 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(path); } - /** - * Get the path to use for this nested aggregation. - */ - public String path() { - return path; - } - @Override public BucketCardinality bucketCardinality() { return BucketCardinality.ONE; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregationBuilder.java index e6c4e59bf3f93..71e6c6ace203d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregationBuilder.java @@ -72,13 +72,6 @@ public ReverseNestedAggregationBuilder path(String path) { return this; } - /** - * Get the path to use for this nested aggregation. - */ - public String path() { - return path; - } - @Override public BucketCardinality bucketCardinality() { return BucketCardinality.ONE; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java index d64e016be7351..789f936359dfa 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedAggregator.java @@ -33,7 +33,6 @@ public class ReverseNestedAggregator extends BucketsAggregator implements Single static final ParseField PATH_FIELD = new ParseField("path"); - private final Query parentFilter; private final BitSetProducer parentBitsetProducer; public ReverseNestedAggregator( @@ -46,6 +45,7 @@ public ReverseNestedAggregator( Map metadata ) throws IOException { super(name, factories, context, parent, cardinality, metadata); + Query parentFilter; if (objectMapper == null) { parentFilter = Queries.newNonNestedFilter(context.getIndexSettings().getIndexVersionCreated()); } else { @@ -102,7 +102,4 @@ public InternalAggregation buildEmptyAggregation() { return new InternalReverseNested(name, 0, buildEmptySubAggregations(), metadata()); } - Query getParentFilter() { - return parentFilter; - } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/IpPrefixAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/IpPrefixAggregator.java index d7e807cc7cc6b..eb8b0f95047b9 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/IpPrefixAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/prefix/IpPrefixAggregator.java @@ -53,22 +53,6 @@ public IpPrefix(boolean isIpv6, int prefixLength, boolean appendPrefixLength, By this.netmask = netmask; } - public boolean isIpv6() { - return isIpv6; - } - - public int getPrefixLength() { - return prefixLength; - } - - public boolean appendPrefixLength() { - return appendPrefixLength; - } - - public BytesRef getNetmask() { - return netmask; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java index a084f251693a4..a8476071ee52d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java @@ -17,7 +17,6 @@ import org.elasticsearch.search.aggregations.support.AggregationContext; import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory; import org.elasticsearch.search.aggregations.support.ValuesSourceConfig; -import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry; import java.io.IOException; import java.util.Map; @@ -27,12 +26,10 @@ public class AbstractRangeAggregatorFactory extends ValuesSourc private final InternalRange.Factory rangeFactory; private final R[] ranges; private final boolean keyed; - private final ValuesSourceRegistry.RegistryKey registryKey; private final RangeAggregatorSupplier aggregatorSupplier; public AbstractRangeAggregatorFactory( String name, - ValuesSourceRegistry.RegistryKey registryKey, ValuesSourceConfig config, R[] ranges, boolean keyed, @@ -47,7 +44,6 @@ public AbstractRangeAggregatorFactory( this.ranges = ranges; this.keyed = keyed; this.rangeFactory = rangeFactory; - this.registryKey = registryKey; this.aggregatorSupplier = aggregatorSupplier; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregationBuilder.java index 1dfb7a8dac2f5..59baf14f988f6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregationBuilder.java @@ -240,14 +240,6 @@ public DateRangeAggregationBuilder addUnboundedTo(String key, double to) { return this; } - /** - * Same as {@link #addUnboundedTo(String, double)} but the key will be - * computed automatically. - */ - public DateRangeAggregationBuilder addUnboundedTo(double to) { - return addUnboundedTo(null, to); - } - /** * Add a new range with no upper bound. * diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorFactory.java index b0661811c5932..393c732409a91 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/DateRangeAggregatorFactory.java @@ -30,19 +30,7 @@ public DateRangeAggregatorFactory( RangeAggregatorSupplier aggregatorSupplier ) throws IOException { - super( - name, - DateRangeAggregationBuilder.REGISTRY_KEY, - config, - ranges, - keyed, - rangeFactory, - context, - parent, - subFactoriesBuilder, - metadata, - aggregatorSupplier - ); + super(name, config, ranges, keyed, rangeFactory, context, parent, subFactoriesBuilder, metadata, aggregatorSupplier); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java index a44d92f024e46..ffc6d68f21a05 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/GeoDistanceAggregationBuilder.java @@ -414,10 +414,6 @@ public GeoDistanceAggregationBuilder unit(DistanceUnit unit) { return this; } - public DistanceUnit unit() { - return unit; - } - public GeoDistanceAggregationBuilder distanceType(GeoDistance distanceType) { if (distanceType == null) { throw new IllegalArgumentException("[distanceType] must not be null: [" + name + "]"); @@ -426,19 +422,11 @@ public GeoDistanceAggregationBuilder distanceType(GeoDistance distanceType) { return this; } - public GeoDistance distanceType() { - return distanceType; - } - public GeoDistanceAggregationBuilder keyed(boolean keyed) { this.keyed = keyed; return this; } - public boolean keyed() { - return keyed; - } - @Override public BucketCardinality bucketCardinality() { return BucketCardinality.MANY; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalDateRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalDateRange.java index 999d37e1fe65a..c99abc4eb904b 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalDateRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalDateRange.java @@ -11,7 +11,6 @@ import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.InternalAggregations; -import org.elasticsearch.search.aggregations.support.ValueType; import java.io.IOException; import java.time.Instant; @@ -71,25 +70,9 @@ private Double internalGetTo() { return to; } - @Override - protected InternalRange.Factory getFactory() { - return FACTORY; - } - - boolean keyed() { - return keyed; - } - - DocValueFormat format() { - return format; - } } public static class Factory extends InternalRange.Factory { - @Override - public ValueType getValueType() { - return ValueType.DATE; - } @Override public InternalDateRange create( diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalGeoDistance.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalGeoDistance.java index 028fce1b4c567..31306d81220d6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalGeoDistance.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalGeoDistance.java @@ -11,7 +11,6 @@ import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; -import org.elasticsearch.search.aggregations.support.ValueType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; import java.io.IOException; @@ -27,14 +26,6 @@ static class Bucket extends InternalRange.Bucket { super(key, from, to, docCount, aggregations, keyed, DocValueFormat.RAW); } - @Override - protected InternalRange.Factory getFactory() { - return FACTORY; - } - - boolean keyed() { - return keyed; - } } public static class Factory extends InternalRange.Factory { @@ -43,11 +34,6 @@ public ValuesSourceType getValueSourceType() { return CoreValuesSourceType.GEOPOINT; } - @Override - public ValueType getValueType() { - return ValueType.GEOPOINT; - } - @Override public InternalGeoDistance create( String name, diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java index c6f3cbaf740f0..cb970fc87fd33 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java @@ -17,7 +17,6 @@ import org.elasticsearch.search.aggregations.InternalMultiBucketAggregation; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.SamplingContext; -import org.elasticsearch.search.aggregations.support.ValueType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; import org.elasticsearch.xcontent.XContentBuilder; @@ -117,11 +116,6 @@ public InternalAggregations getAggregations() { return aggregations; } - @SuppressWarnings("unchecked") - protected Factory getFactory() { - return FACTORY; - } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { final String key = getKeyAsString(); @@ -206,10 +200,6 @@ public ValuesSourceType getValueSourceType() { return CoreValuesSourceType.NUMERIC; } - public ValueType getValueType() { - return ValueType.NUMERIC; - } - @SuppressWarnings("unchecked") public R create(String name, List ranges, DocValueFormat format, boolean keyed, Map metadata) { return (R) new InternalRange(name, ranges, format, keyed, metadata); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java index ef580929521d0..42f6d9957c329 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/IpRangeAggregationBuilder.java @@ -39,7 +39,6 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; @@ -164,18 +163,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(to); } - public String getKey() { - return key; - } - - public String getFrom() { - return from; - } - - public String getTo() { - return to; - } - @Override public boolean equals(Object obj) { if (obj == null || getClass() != obj.getClass()) { @@ -253,11 +240,6 @@ public boolean keyed() { return keyed; } - /** Get the current list or ranges that are configured on this aggregation. */ - public List getRanges() { - return Collections.unmodifiableList(ranges); - } - /** Add a new {@link Range} to this aggregation. */ public IpRangeAggregationBuilder addRange(Range range) { ranges.add(range); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregationBuilder.java index 9fdbaa10509e6..f9fc993c3f347 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregationBuilder.java @@ -203,13 +203,6 @@ protected ValuesSourceRegistry.RegistryKey getRegistryKey() { return REGISTRY_KEY; } - private static String generateKey(double from, double to, DocValueFormat format) { - StringBuilder builder = new StringBuilder().append(Double.isInfinite(from) ? "*" : format.format(from)) - .append("-") - .append(Double.isInfinite(to) ? "*" : format.format(to)); - return builder.toString(); - } - @Override public TransportVersion getMinimalSupportedVersion() { return TransportVersions.ZERO; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java index 98237d19f0f33..7c89061ea32f2 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregator.java @@ -199,14 +199,6 @@ public double getTo() { return this.originalTo; } - public Double getOriginalFrom() { - return originalFrom; - } - - public Double getOriginalTo() { - return originalTo; - } - public String getFromAsString() { return this.fromAsStr; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorFactory.java index 6e9781b0d9531..42d0f55e14a8d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/RangeAggregatorFactory.java @@ -32,18 +32,6 @@ public RangeAggregatorFactory( Map metadata, RangeAggregatorSupplier aggregatorSupplier ) throws IOException { - super( - name, - RangeAggregationBuilder.REGISTRY_KEY, - config, - ranges, - keyed, - rangeFactory, - context, - parent, - subFactoriesBuilder, - metadata, - aggregatorSupplier - ); + super(name, config, ranges, keyed, rangeFactory, context, parent, subFactoriesBuilder, metadata, aggregatorSupplier); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedAggregationBuilder.java index 6dd998c0db043..90c29a8e3556f 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedAggregationBuilder.java @@ -106,13 +106,6 @@ public DiversifiedAggregationBuilder shardSize(int shardSize) { return this; } - /** - * Get the max num docs to be returned from each shard. - */ - public int shardSize() { - return shardSize; - } - /** * Set the max num docs to be returned per value. */ @@ -126,13 +119,6 @@ public DiversifiedAggregationBuilder maxDocsPerValue(int maxDocsPerValue) { return this; } - /** - * Get the max num docs to be returned per value. - */ - public int maxDocsPerValue() { - return maxDocsPerValue; - } - /** * Set the execution hint. */ @@ -141,13 +127,6 @@ public DiversifiedAggregationBuilder executionHint(String executionHint) { return this; } - /** - * Get the execution hint. - */ - public String executionHint() { - return executionHint; - } - @Override public BucketCardinality bucketCardinality() { return BucketCardinality.ONE; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java index 9795097f308da..5c3208418df08 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/SamplerAggregationBuilder.java @@ -67,13 +67,6 @@ public SamplerAggregationBuilder shardSize(int shardSize) { return this; } - /** - * Get the max num docs to be returned from each shard. - */ - public int shardSize() { - return shardSize; - } - @Override public BucketCardinality bucketCardinality() { return BucketCardinality.ONE; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/random/RandomSamplerAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/random/RandomSamplerAggregationBuilder.java index 80d396d9aff7d..240f016c66954 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/random/RandomSamplerAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/random/RandomSamplerAggregationBuilder.java @@ -21,7 +21,6 @@ import org.elasticsearch.xcontent.ObjectParser; import org.elasticsearch.xcontent.ParseField; import org.elasticsearch.xcontent.XContentBuilder; -import org.elasticsearch.xcontent.XContentParser; import java.io.IOException; import java.util.Collection; @@ -45,10 +44,6 @@ public class RandomSamplerAggregationBuilder extends AbstractAggregationBuilder< PARSER.declareDouble(RandomSamplerAggregationBuilder::setProbability, PROBABILITY); } - public static RandomSamplerAggregationBuilder parse(String aggregationName, XContentParser parser) throws IOException { - return PARSER.parse(parser, new RandomSamplerAggregationBuilder(aggregationName), null); - } - private int seed = Randomness.get().nextInt(); private double p; @@ -78,10 +73,6 @@ public RandomSamplerAggregationBuilder(StreamInput in) throws IOException { this.seed = in.readInt(); } - public double getProbability() { - return p; - } - protected RandomSamplerAggregationBuilder( RandomSamplerAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, @@ -140,10 +131,6 @@ protected AggregatorFactory doBuild( return new RandomSamplerAggregatorFactory(name, seed, p, context, parent, subfactoriesBuilder, metadata); } - public int getSeed() { - return seed; - } - @Override protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java index fd6ecb0b36252..f1b9608c9c2cf 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalMappedRareTerms.java @@ -7,8 +7,6 @@ */ package org.elasticsearch.search.aggregations.bucket.terms; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.common.Randomness; import org.elasticsearch.common.io.stream.StreamInput; @@ -42,8 +40,6 @@ public abstract class InternalMappedRareTerms, final SetBackedScalingCuckooFilter filter; - protected final Logger logger = LogManager.getLogger(getClass()); - InternalMappedRareTerms( String name, BucketOrder order, @@ -59,10 +55,6 @@ public abstract class InternalMappedRareTerms, this.filter = filter; } - public long getMaxDocCount() { - return maxDocCount; - } - SetBackedScalingCuckooFilter getFilter() { return filter; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalRareTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalRareTerms.java index 2b2f6a19d46a0..a9870d113ae3a 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalRareTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/InternalRareTerms.java @@ -166,11 +166,6 @@ protected B reduceBucket(List buckets, AggregationReduceContext context) { protected abstract A createWithFilter(String name, List buckets, SetBackedScalingCuckooFilter filter); - /** - * Create an array to hold some buckets. Used in collecting the results. - */ - protected abstract B[] createBucketsArray(int size); - @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongRareTerms.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongRareTerms.java index 8a27a6929f0ba..2f8b685d4d623 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongRareTerms.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/LongRareTerms.java @@ -126,11 +126,6 @@ protected LongRareTerms createWithFilter(String name, List return new LongRareTerms(name, order, getMetadata(), format, buckets, maxDocCount, filter); } - @Override - protected LongRareTerms.Bucket[] createBucketsArray(int size) { - return new LongRareTerms.Bucket[size]; - } - @Override public boolean containsTerm(SetBackedScalingCuckooFilter filter, LongRareTerms.Bucket bucket) { return filter.mightContain((long) bucket.getKey()); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregationBuilder.java index 768c962d13db9..0422428e6b728 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregationBuilder.java @@ -162,13 +162,6 @@ public IncludeExclude includeExclude() { return includeExclude; } - /** - * Get the current false positive rate for individual cuckoo filters. - */ - public double getPrecision() { - return precision; - } - /** * Set's the false-positive rate for individual cuckoo filters. Does not dictate the overall fpp rate * since we use a "scaling" cuckoo filter which adds more filters as required, and the overall diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorFactory.java index 088d575a98ea8..2cc49816d3c25 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorFactory.java @@ -8,7 +8,6 @@ package org.elasticsearch.search.aggregations.bucket.terms; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.AggregatorFactories; @@ -210,20 +209,8 @@ Aggregator create( ); } - @Override - boolean needsGlobalOrdinals() { - return false; - } - }; - public static ExecutionMode fromString(String value, final DeprecationLogger deprecationLogger) { - return switch (value) { - case "map" -> MAP; - default -> throw new IllegalArgumentException("Unknown `execution_hint`: [" + value + "], expected any of [map]"); - }; - } - private final ParseField parseField; ExecutionMode(ParseField parseField) { @@ -244,8 +231,6 @@ abstract Aggregator create( CardinalityUpperBound cardinality ) throws IOException; - abstract boolean needsGlobalOrdinals(); - @Override public String toString() { return parseField.getPreferredName(); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificanceLookup.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificanceLookup.java index 9ac9c0e241566..cf8a1df3e0079 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificanceLookup.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificanceLookup.java @@ -223,7 +223,7 @@ private long getBackgroundFrequency(Query query) throws IOException { // for types that use the inverted index, we prefer using a terms // enum that will do a better job at reusing index inputs Term term = ((TermQuery) query).getTerm(); - TermsEnum termsEnum = getTermsEnum(term.field()); + TermsEnum termsEnum = getTermsEnum(); if (termsEnum.seekExact(term.bytes())) { return termsEnum.docFreq(); } @@ -237,7 +237,7 @@ private long getBackgroundFrequency(Query query) throws IOException { return new IndexSearcher(context.searcher().getIndexReader()).count(query); } - private TermsEnum getTermsEnum(String field) throws IOException { + private TermsEnum getTermsEnum() throws IOException { // TODO this method helps because of asMultiBucketAggregator. Once we remove it we can move this logic into the aggregators. if (termsEnum != null) { return termsEnum; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregationBuilder.java index 5311688ceee54..bb89e7d54bcb6 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregationBuilder.java @@ -186,14 +186,6 @@ public TermsAggregator.BucketCountThresholds bucketCountThresholds() { return bucketCountThresholds; } - public SignificantTermsAggregationBuilder bucketCountThresholds(TermsAggregator.BucketCountThresholds bucketCountThresholds) { - if (bucketCountThresholds == null) { - throw new IllegalArgumentException("[bucketCountThresholds] must not be null: [" + name + "]"); - } - this.bucketCountThresholds = bucketCountThresholds; - return this; - } - /** * Sets the size - indicating how many term buckets should be returned * (defaults to 10) @@ -256,13 +248,6 @@ public SignificantTermsAggregationBuilder executionHint(String executionHint) { return this; } - /** - * Expert: gets an execution hint to the aggregation. - */ - public String executionHint() { - return executionHint; - } - public SignificantTermsAggregationBuilder backgroundFilter(QueryBuilder backgroundFilter) { if (backgroundFilter == null) { throw new IllegalArgumentException("[backgroundFilter] must not be null: [" + name + "]"); @@ -271,10 +256,6 @@ public SignificantTermsAggregationBuilder backgroundFilter(QueryBuilder backgrou return this; } - public QueryBuilder backgroundFilter() { - return backgroundFilter; - } - /** * Set terms to include and exclude from the aggregation results */ diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTextAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTextAggregationBuilder.java index a73d12c23a378..99dc93a175f7b 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTextAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTextAggregationBuilder.java @@ -123,10 +123,6 @@ protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map> sorts) { return this; } - /** - * Gets the bytes representing the sort builders for this request. - */ - public List> sorts() { - return sorts; - } - /** * Adds highlight to perform as part of the search. */ @@ -296,23 +289,6 @@ public TopHitsAggregationBuilder highlighter(HighlightBuilder highlightBuilder) return this; } - /** - * Gets the highlighter builder for this request. - */ - public HighlightBuilder highlighter() { - return highlightBuilder; - } - - /** - * Indicates whether the response should contain the stored _source for - * every hit - */ - public TopHitsAggregationBuilder fetchSource(boolean fetch) { - FetchSourceContext fetchSourceContext = this.fetchSourceContext != null ? this.fetchSourceContext : FetchSourceContext.FETCH_SOURCE; - this.fetchSourceContext = FetchSourceContext.of(fetch, fetchSourceContext.includes(), fetchSourceContext.excludes()); - return this; - } - /** * Indicate that _source should be returned with every hit, with an * "include" and/or "exclude" set which can include simple wildcard @@ -362,14 +338,6 @@ public TopHitsAggregationBuilder fetchSource(@Nullable FetchSourceContext fetchS return this; } - /** - * Gets the {@link FetchSourceContext} which defines how the _source - * should be fetched. - */ - public FetchSourceContext fetchSource() { - return fetchSourceContext; - } - /** * Adds a stored field to load and return (note, it must be stored) as part of the search request. * To disable the stored fields entirely (source and metadata fields) use {@code storedField("_none_")}. @@ -394,13 +362,6 @@ public TopHitsAggregationBuilder storedFields(List fields) { return this; } - /** - * Gets the stored fields context - */ - public StoredFieldsContext storedFields() { - return storedFieldsContext; - } - /** * Adds a field to load from doc values and return as part of * the search request. @@ -424,13 +385,6 @@ public TopHitsAggregationBuilder docValueField(String docValueField) { return docValueField(docValueField, null); } - /** - * Gets the field-data fields. - */ - public List docValueFields() { - return docValueFields; - } - /** * Adds a field to load and return as part of the search request. */ @@ -452,13 +406,6 @@ public TopHitsAggregationBuilder fetchField(String field) { return fetchField(new FieldAndFormat(field, null, null)); } - /** - * Gets the fields to load and return as part of the search request. - */ - public List fetchFields() { - return fetchFields; - } - /** * Adds a script field under the given name with the provided script. * @@ -511,13 +458,6 @@ public TopHitsAggregationBuilder scriptFields(List scriptFields) { return this; } - /** - * Gets the script fields. - */ - public Set scriptFields() { - return scriptFields; - } - /** * Should each {@link org.elasticsearch.search.SearchHit} be returned * with an explanation of the hit (ranking). @@ -527,14 +467,6 @@ public TopHitsAggregationBuilder explain(boolean explain) { return this; } - /** - * Indicates whether each search hit will be returned with an - * explanation of the hit (ranking) - */ - public boolean explain() { - return explain; - } - /** * Should each {@link org.elasticsearch.search.SearchHit} be returned * with a version associated with it. @@ -544,14 +476,6 @@ public TopHitsAggregationBuilder version(boolean version) { return this; } - /** - * Indicates whether the document's version will be included in the - * search hits. - */ - public boolean version() { - return version; - } - /** * Should each {@link org.elasticsearch.search.SearchHit} be returned with the * sequence number and primary term of the last modification of the document. @@ -561,14 +485,6 @@ public TopHitsAggregationBuilder seqNoAndPrimaryTerm(Boolean seqNoAndPrimaryTerm return this; } - /** - * Indicates whether {@link org.elasticsearch.search.SearchHit}s should be returned with the - * sequence number and primary term of the last modification of the document. - */ - public Boolean seqNoAndPrimaryTerm() { - return seqNoAndPrimaryTerm; - } - /** * Applies when sorting, and controls if scores will be tracked as well. * Defaults to {@code false}. @@ -578,13 +494,6 @@ public TopHitsAggregationBuilder trackScores(boolean trackScores) { return this; } - /** - * Indicates whether scores will be tracked for this request. - */ - public boolean trackScores() { - return trackScores; - } - @Override public TopHitsAggregationBuilder subAggregations(Builder subFactories) { throw new AggregationInitializationException( diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/AbstractPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/AbstractPipelineAggregationBuilder.java index 74bb9a8881d79..b3335dcbd5be5 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/AbstractPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/AbstractPipelineAggregationBuilder.java @@ -58,10 +58,6 @@ public void writeTo(StreamOutput out) throws IOException { protected abstract void doWriteTo(StreamOutput out) throws IOException; - public String type() { - return type; - } - protected abstract PipelineAggregator createInternal(Map metadata); /** diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketMetricsPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketMetricsPipelineAggregationBuilder.java index b5a9da37c60f6..c93d8f1c41874 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketMetricsPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketMetricsPipelineAggregationBuilder.java @@ -65,13 +65,6 @@ public AF format(String format) { return (AF) this; } - /** - * Gets the format to use on the output of this aggregation. - */ - public String format() { - return format; - } - protected DocValueFormat formatter() { if (format != null) { return new DocValueFormat.Decimal(format); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptPipelineAggregationBuilder.java index 4993c8ec25d83..1cf49af421466 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/BucketScriptPipelineAggregationBuilder.java @@ -142,13 +142,6 @@ public BucketScriptPipelineAggregationBuilder format(String format) { return this; } - /** - * Gets the format to use on the output of this aggregation. - */ - public String format() { - return format; - } - protected DocValueFormat formatter() { if (format != null) { return new DocValueFormat.Decimal(format); @@ -168,13 +161,6 @@ public BucketScriptPipelineAggregationBuilder gapPolicy(GapPolicy gapPolicy) { return this; } - /** - * Gets the gap policy to use for this aggregation. - */ - public GapPolicy gapPolicy() { - return gapPolicy; - } - @Override protected PipelineAggregator createInternal(Map metadata) { return new BucketScriptPipelineAggregator(name, bucketsPathsMap, script, formatter(), gapPolicy, metadata); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumPipelineAggregationBuilder.java index c2816629b653f..944c4e8a88d08 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/CumulativeSumPipelineAggregationBuilder.java @@ -73,13 +73,6 @@ public CumulativeSumPipelineAggregationBuilder format(String format) { return this; } - /** - * Gets the format to use on the output of this aggregation. - */ - public String format() { - return format; - } - protected DocValueFormat formatter() { if (format != null) { return new DocValueFormat.Decimal(format); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedDerivative.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedDerivative.java index 66d2c0621b410..e7751230334d5 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedDerivative.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/ParsedDerivative.java @@ -24,16 +24,6 @@ public class ParsedDerivative extends ParsedSimpleValue { private static final ParseField NORMALIZED_AS_STRING = new ParseField("normalized_value_as_string"); private static final ParseField NORMALIZED = new ParseField("normalized_value"); - /** - * Returns the normalized value. If no normalised factor has been specified - * this method will return {@link #value()} - * - * @return the normalized value - */ - public double normalizedValue() { - return this.normalizedValue; - } - @Override public String getType() { return "derivative"; diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketPipelineAggregationBuilder.java index a47f1255e0fe9..4edecb3c8b480 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketPipelineAggregationBuilder.java @@ -84,13 +84,6 @@ public PercentilesBucketPipelineAggregationBuilder setKeyed(boolean keyed) { return this; } - /** - * Get whether the XContent should be keyed - */ - public boolean getKeyed() { - return keyed; - } - @Override protected PipelineAggregator createInternal(Map metadata) { return new PercentilesBucketPipelineAggregator(name, percents, keyed, bucketsPaths, gapPolicy(), formatter(), metadata); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/SerialDiffPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/SerialDiffPipelineAggregationBuilder.java index 1143594e98d16..935104bcacd51 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/SerialDiffPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/SerialDiffPipelineAggregationBuilder.java @@ -70,13 +70,6 @@ public SerialDiffPipelineAggregationBuilder lag(int lag) { return this; } - /** - * Gets the lag to use when calculating the serial difference. - */ - public int lag() { - return lag; - } - /** * Sets the format to use on the output of this aggregation. */ @@ -88,13 +81,6 @@ public SerialDiffPipelineAggregationBuilder format(String format) { return this; } - /** - * Gets the format to use on the output of this aggregation. - */ - public String format() { - return format; - } - /** * Sets the GapPolicy to use on the output of this aggregation. */ @@ -106,13 +92,6 @@ public SerialDiffPipelineAggregationBuilder gapPolicy(GapPolicy gapPolicy) { return this; } - /** - * Gets the GapPolicy to use on the output of this aggregation. - */ - public GapPolicy gapPolicy() { - return gapPolicy; - } - protected DocValueFormat formatter() { if (format != null) { return new DocValueFormat.Decimal(format); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationInfo.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationInfo.java index e3662b150270c..11b2da7c82e24 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationInfo.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/AggregationInfo.java @@ -55,10 +55,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeMap(aggs, StreamOutput::writeStringCollection); } - public Map> getAggregations() { - return aggs; - } - @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("aggregations"); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/TimeSeriesValuesSourceType.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/TimeSeriesValuesSourceType.java index e1e249466aea6..6529c3f565a33 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/TimeSeriesValuesSourceType.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/TimeSeriesValuesSourceType.java @@ -84,10 +84,6 @@ public ValuesSource replaceMissing( } }; - public static ValuesSourceType fromString(String name) { - return valueOf(name.trim().toUpperCase(Locale.ROOT)); - } - public String value() { return name().toLowerCase(Locale.ROOT); } From 3dd97ba924c5844500ed4e4d015680fc2e8f3dd4 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 6 Nov 2023 16:06:03 +1100 Subject: [PATCH 12/14] Fix lastUnsafeSegmentGenerationForGets for realtime get (#101700) This PR makes sure that the lastUnsafeSegmentGenerationForGets is updated after the flush (triggered by realtime-get) so that it captures the latest commit generation at all time. This is necessary because there could be extra flushes right before or after this one which increment the last commit generation further. --- docs/changelog/101700.yaml | 5 +++++ .../org/elasticsearch/index/engine/InternalEngine.java | 10 +++++++++- .../index/shard/ShardGetServiceTests.java | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 docs/changelog/101700.yaml diff --git a/docs/changelog/101700.yaml b/docs/changelog/101700.yaml new file mode 100644 index 0000000000000..08671360688a7 --- /dev/null +++ b/docs/changelog/101700.yaml @@ -0,0 +1,5 @@ +pr: 101700 +summary: Fix `lastUnsafeSegmentGenerationForGets` for realtime get +area: Engine +type: bug +issues: [] diff --git a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java index 9419cd7e6ab5f..141a06eff0ec6 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java @@ -1039,11 +1039,19 @@ private VersionValue getVersionFromMap(BytesRef id) { // but we only need to do this once since the last operation per ID is to add to the version // map so once we pass this point we can safely lookup from the version map. if (versionMap.isUnsafe()) { - lastUnsafeSegmentGenerationForGets.set(lastCommittedSegmentInfos.getGeneration() + 1); refreshInternalSearcher(UNSAFE_VERSION_MAP_REFRESH_SOURCE, true); + // After the refresh, the doc that triggered it must now be part of the last commit. + // In rare cases, there could be other flush cycles completed in between the above line + // and the line below which push the last commit generation further. But that's OK. + // The invariant here is that doc is available within the generations of commits upto + // lastUnsafeSegmentGenerationForGets (inclusive). Therefore it is ok for it be larger + // which means the search shard needs to wait for extra generations and these generations + // are guaranteed to happen since they are all committed. + lastUnsafeSegmentGenerationForGets.set(lastCommittedSegmentInfos.getGeneration()); } versionMap.enforceSafeAccess(); } + // The versionMap can still be unsafe at this point due to archive being unsafe } return versionMap.getUnderLock(id); } diff --git a/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java b/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java index f099fa657b89c..b32e9f4db8b77 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/ShardGetServiceTests.java @@ -30,7 +30,6 @@ import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM; import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; public class ShardGetServiceTests extends IndexShardTestCase { @@ -241,7 +240,8 @@ public void testGetFromTranslog() throws IOException { .getFromTranslog("2", new String[] { "foo" }, true, 1, VersionType.INTERNAL, FetchSourceContext.FETCH_SOURCE, false); assertNull(getResult); var lastUnsafeGeneration = engine.getLastUnsafeSegmentGenerationForGets(); - assertThat(lastUnsafeGeneration, greaterThan(0L)); + // last unsafe generation is set to last committed gen after the refresh triggered by realtime get + assertThat(lastUnsafeGeneration, equalTo(engine.getLastCommittedSegmentInfos().getGeneration())); assertTrue(LiveVersionMapTestUtils.isSafeAccessRequired(map)); assertFalse(LiveVersionMapTestUtils.isUnsafe(map)); @@ -250,7 +250,7 @@ public void testGetFromTranslog() throws IOException { engine.flush(true, true, flushFuture); var flushResult = flushFuture.actionGet(); assertTrue(flushResult.flushPerformed()); - assertThat(flushResult.generation(), equalTo(lastUnsafeGeneration)); + assertThat(flushResult.generation(), equalTo(lastUnsafeGeneration + 1)); assertThat(engine.getLastUnsafeSegmentGenerationForGets(), equalTo(lastUnsafeGeneration)); // No longer in translog getResult = primary.getService() From 49c5b03d575fe4644422cbfe5eeeebcc027071e3 Mon Sep 17 00:00:00 2001 From: Abdon Pijpelink Date: Mon, 6 Nov 2023 08:41:15 +0100 Subject: [PATCH 13/14] [DOCS] Update CCS compatibility matrix for 8.11 (#101786) --- .../ccs-version-compat-matrix.asciidoc | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/docs/reference/search/search-your-data/ccs-version-compat-matrix.asciidoc b/docs/reference/search/search-your-data/ccs-version-compat-matrix.asciidoc index cae5627d65b54..8c289c27a2d31 100644 --- a/docs/reference/search/search-your-data/ccs-version-compat-matrix.asciidoc +++ b/docs/reference/search/search-your-data/ccs-version-compat-matrix.asciidoc @@ -1,20 +1,21 @@ -[cols="^,^,^,^,^,^,^,^,^,^,^,^,^,^,^"] +[cols="^,^,^,^,^,^,^,^,^,^,^,^,^,^,^,^"] |==== -| 14+^h| Remote cluster version +| 15+^h| Remote cluster version h| Local cluster version - | 6.8 | 7.1–7.16 | 7.17 | 8.0 | 8.1 | 8.2 | 8.3 | 8.4 | 8.5 |8.6 |8.7 |8.8 |8.9 |8.10 -| 6.8 | {yes-icon} | {yes-icon} | {yes-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} -| 7.1–7.16 | {yes-icon} | {yes-icon} | {yes-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} -| 7.17 | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.0 | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.1 | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.2 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.3 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon}|{yes-icon} | {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.4 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} |{yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.5 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} |{yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.6 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.7 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.8 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.9 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} -| 8.10 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} + | 6.8 | 7.1–7.16 | 7.17 | 8.0 | 8.1 | 8.2 | 8.3 | 8.4 | 8.5 |8.6 |8.7 |8.8 |8.9 |8.10 |8.11 +| 6.8 | {yes-icon} | {yes-icon} | {yes-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} +| 7.1–7.16 | {yes-icon} | {yes-icon} | {yes-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} +| 7.17 | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.0 | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.1 | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.2 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon}| {yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.3 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon}|{yes-icon} | {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.4 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} |{yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.5 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} |{yes-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.6 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {yes-icon}| {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.7 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.8 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.9 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.10 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} +| 8.11 | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}| {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} |==== \ No newline at end of file From 76ab37b35d9b423dfe85b3b21b2fada2826f4994 Mon Sep 17 00:00:00 2001 From: Abdon Pijpelink Date: Mon, 6 Nov 2023 08:42:13 +0100 Subject: [PATCH 14/14] [DOCS] Uniform formatting for ES|QL commands (#101728) * Source commands * Missing word * Processing commands * Apply suggestions from code review Co-authored-by: Alexander Spies * Review feedback * Add sort detail for mv * More review feedback --------- Co-authored-by: Alexander Spies --- docs/reference/esql/index.asciidoc | 2 +- .../esql/processing-commands/dissect.asciidoc | 10 +-- .../esql/processing-commands/drop.asciidoc | 18 +++++- .../esql/processing-commands/enrich.asciidoc | 10 +-- .../esql/processing-commands/eval.asciidoc | 30 +++++++-- .../esql/processing-commands/grok.asciidoc | 2 +- .../esql/processing-commands/keep.asciidoc | 24 ++++++-- .../esql/processing-commands/limit.asciidoc | 26 ++++++-- .../processing-commands/mv_expand.asciidoc | 19 +++++- .../esql/processing-commands/rename.asciidoc | 21 +++++-- .../esql/processing-commands/sort.asciidoc | 46 ++++++++++---- .../esql/processing-commands/stats.asciidoc | 61 ++++++++++++++----- .../esql/processing-commands/where.asciidoc | 33 ++++++---- .../esql/source-commands/from.asciidoc | 45 ++++++++++++-- .../esql/source-commands/row.asciidoc | 20 ++++++ .../esql/source-commands/show.asciidoc | 29 ++++++++- .../src/main/resources/docs.csv-spec | 2 +- .../src/main/resources/show.csv-spec | 8 ++- 18 files changed, 326 insertions(+), 80 deletions(-) diff --git a/docs/reference/esql/index.asciidoc b/docs/reference/esql/index.asciidoc index 2946f4e61d629..799f95751aa69 100644 --- a/docs/reference/esql/index.asciidoc +++ b/docs/reference/esql/index.asciidoc @@ -62,7 +62,7 @@ An overview of using the <>, <>, and The current limitations of {esql}. <>:: -A few examples of what you can with {esql}. +A few examples of what you can do with {esql}. include::esql-get-started.asciidoc[] diff --git a/docs/reference/esql/processing-commands/dissect.asciidoc b/docs/reference/esql/processing-commands/dissect.asciidoc index eca10c201c968..eb7ab80d6174d 100644 --- a/docs/reference/esql/processing-commands/dissect.asciidoc +++ b/docs/reference/esql/processing-commands/dissect.asciidoc @@ -4,9 +4,9 @@ **Syntax** -[source,txt] +[source,esql] ---- -DISSECT input "pattern" [ append_separator=""] +DISSECT input "pattern" [ APPEND_SEPARATOR=""] ---- *Parameters* @@ -16,9 +16,9 @@ The column that contains the string you want to structure. If the column has multiple values, `DISSECT` will process each value. `pattern`:: -A dissect pattern. +A <>. -`append_separator=""`:: +``:: A string used as the separator between appended values, when using the <>. *Description* @@ -29,7 +29,7 @@ delimiter-based pattern, and extracts the specified keys as columns. Refer to <> for the syntax of dissect patterns. -*Example* +*Examples* // tag::examples[] The following example parses a string that contains a timestamp, some text, and diff --git a/docs/reference/esql/processing-commands/drop.asciidoc b/docs/reference/esql/processing-commands/drop.asciidoc index 50e3b27fb1b28..4787c5f137314 100644 --- a/docs/reference/esql/processing-commands/drop.asciidoc +++ b/docs/reference/esql/processing-commands/drop.asciidoc @@ -2,7 +2,23 @@ [[esql-drop]] === `DROP` -Use `DROP` to remove columns: +**Syntax** + +[source,esql] +---- +DROP columns +---- + +*Parameters* + +`columns`:: +A comma-separated list of columns to remove. Supports wildcards. + +*Description* + +The `DROP` processing command removes one or more columns. + +*Examples* [source,esql] ---- diff --git a/docs/reference/esql/processing-commands/enrich.asciidoc b/docs/reference/esql/processing-commands/enrich.asciidoc index df402f3b1bd50..603683858b8c0 100644 --- a/docs/reference/esql/processing-commands/enrich.asciidoc +++ b/docs/reference/esql/processing-commands/enrich.asciidoc @@ -4,7 +4,7 @@ **Syntax** -[source,txt] +[source,esql] ---- ENRICH policy [ON match_field] [WITH [new_name1 = ]field1, [new_name2 = ]field2, ...] ---- @@ -15,18 +15,18 @@ ENRICH policy [ON match_field] [WITH [new_name1 = ]field1, [new_name2 = ]field2, The name of the enrich policy. You need to <> and <> the enrich policy first. -`ON match_field`:: +`match_field`:: The match field. `ENRICH` uses its value to look for records in the enrich index. If not specified, the match will be performed on the column with the same name as the `match_field` defined in the <>. -`WITH fieldX`:: +`fieldX`:: The enrich fields from the enrich index that are added to the result as new columns. If a column with the same name as the enrich field already exists, the existing column will be replaced by the new column. If not specified, each of the enrich fields defined in the policy is added -`new_nameX =`:: +`new_nameX`:: Enables you to change the name of the column that's added for each of the enrich fields. Defaults to the enrich field name. @@ -74,7 +74,7 @@ include::{esql-specs}/docs-IT_tests_only.csv-spec[tag=enrich_on-result] By default, each of the enrich fields defined in the policy is added as a column. To explicitly select the enrich fields that are added, use -`WITH , ...`: +`WITH , , ...`: [source.merge.styled,esql] ---- diff --git a/docs/reference/esql/processing-commands/eval.asciidoc b/docs/reference/esql/processing-commands/eval.asciidoc index a0a78f2a3bf97..eb69a587014ab 100644 --- a/docs/reference/esql/processing-commands/eval.asciidoc +++ b/docs/reference/esql/processing-commands/eval.asciidoc @@ -1,7 +1,30 @@ [discrete] [[esql-eval]] === `EVAL` -`EVAL` enables you to append new columns: + +**Syntax** + +[source,esql] +---- +EVAL column1 = value1[, ..., columnN = valueN] +---- + +*Parameters* + +`columnX`:: +The column name. + +`valueX`:: +The value for the column. Can be a literal, an expression, or a +<>. + +*Description* + +The `EVAL` processing command enables you to append new columns with calculated +values. `EVAL` supports various functions for calculating values. Refer to +<> for more information. + +*Examples* [source.merge.styled,esql] ---- @@ -23,8 +46,3 @@ include::{esql-specs}/docs.csv-spec[tag=evalReplace] |=== include::{esql-specs}/docs.csv-spec[tag=evalReplace-result] |=== - -[discrete] -==== Functions -`EVAL` supports various functions for calculating values. Refer to -<> for more information. diff --git a/docs/reference/esql/processing-commands/grok.asciidoc b/docs/reference/esql/processing-commands/grok.asciidoc index c95fe59f888ce..d5d58a9eaee12 100644 --- a/docs/reference/esql/processing-commands/grok.asciidoc +++ b/docs/reference/esql/processing-commands/grok.asciidoc @@ -4,7 +4,7 @@ **Syntax** -[source,txt] +[source,esql] ---- GROK input "pattern" ---- diff --git a/docs/reference/esql/processing-commands/keep.asciidoc b/docs/reference/esql/processing-commands/keep.asciidoc index 3e54e5a7d1c5c..7515583b1bfd1 100644 --- a/docs/reference/esql/processing-commands/keep.asciidoc +++ b/docs/reference/esql/processing-commands/keep.asciidoc @@ -2,11 +2,25 @@ [[esql-keep]] === `KEEP` -The `KEEP` command enables you to specify what columns are returned and the -order in which they are returned. +**Syntax** -To limit the columns that are returned, use a comma-separated list of column -names. The columns are returned in the specified order: +[source,esql] +---- +KEEP columns +---- + +*Parameters* +`columns`:: +A comma-separated list of columns to keep. Supports wildcards. + +*Description* + +The `KEEP` processing command enables you to specify what columns are returned +and the order in which they are returned. + +*Examples* + +The columns are returned in the specified order: [source.merge.styled,esql] ---- @@ -27,7 +41,7 @@ include::{esql-specs}/docs.csv-spec[tag=keepWildcard] The asterisk wildcard (`*`) by itself translates to all columns that do not match the other arguments. This query will first return all columns with a name -that starts with an h, followed by all other columns: +that starts with `h`, followed by all other columns: [source,esql] ---- diff --git a/docs/reference/esql/processing-commands/limit.asciidoc b/docs/reference/esql/processing-commands/limit.asciidoc index c02b534af59e1..457d5e9e65223 100644 --- a/docs/reference/esql/processing-commands/limit.asciidoc +++ b/docs/reference/esql/processing-commands/limit.asciidoc @@ -2,12 +2,30 @@ [[esql-limit]] === `LIMIT` -The `LIMIT` processing command enables you to limit the number of rows: +**Syntax** [source,esql] ---- -include::{esql-specs}/docs.csv-spec[tag=limit] +LIMIT max_number_of_rows ---- -If not specified, `LIMIT` defaults to `500`. A single query will not return -more than 10,000 rows, regardless of the `LIMIT` value. +*Parameters* + +`max_number_of_rows`:: +The maximum number of rows to return. + +*Description* + +The `LIMIT` processing command enables you to limit the number of rows that are +returned. If not specified, `LIMIT` defaults to `500`. + +A query does not return more than 10,000 rows, regardless of the `LIMIT` value. +You can change this with the `esql.query.result_truncation_max_size` static +cluster setting. + +*Example* + +[source,esql] +---- +include::{esql-specs}/docs.csv-spec[tag=limit] +---- diff --git a/docs/reference/esql/processing-commands/mv_expand.asciidoc b/docs/reference/esql/processing-commands/mv_expand.asciidoc index d62b28aabe440..46dc4fd0a33cf 100644 --- a/docs/reference/esql/processing-commands/mv_expand.asciidoc +++ b/docs/reference/esql/processing-commands/mv_expand.asciidoc @@ -2,7 +2,24 @@ [[esql-mv_expand]] === `MV_EXPAND` -The `MV_EXPAND` processing command expands multivalued fields into one row per value, duplicating other fields: +**Syntax** + +[source,esql] +---- +MV_EXPAND column +---- + +*Parameters* + +`column`:: +The multivalued column to expand. + +*Description* + +The `MV_EXPAND` processing command expands multivalued columns into one row per +value, duplicating other columns. + +*Example* [source.merge.styled,esql] ---- diff --git a/docs/reference/esql/processing-commands/rename.asciidoc b/docs/reference/esql/processing-commands/rename.asciidoc index 1dda424317976..773fe8b640f75 100644 --- a/docs/reference/esql/processing-commands/rename.asciidoc +++ b/docs/reference/esql/processing-commands/rename.asciidoc @@ -2,22 +2,33 @@ [[esql-rename]] === `RENAME` -Use `RENAME` to rename a column using the following syntax: +**Syntax** [source,esql] ---- -RENAME AS +RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN] ---- -For example: +*Parameters* + +`old_nameX`:: +The name of a column you want to rename. + +`new_nameX`:: +The new name of the column. + +*Description* + +The `RENAME` processing command renames one or more columns. If a column with +the new name already exists, it will be replaced by the new column. + +*Examples* [source,esql] ---- include::{esql-specs}/docs.csv-spec[tag=rename] ---- -If a column with the new name already exists, it will be replaced by the new -column. Multiple columns can be renamed with a single `RENAME` command: diff --git a/docs/reference/esql/processing-commands/sort.asciidoc b/docs/reference/esql/processing-commands/sort.asciidoc index 76a9193375932..fea7bfaf0c65f 100644 --- a/docs/reference/esql/processing-commands/sort.asciidoc +++ b/docs/reference/esql/processing-commands/sort.asciidoc @@ -1,35 +1,59 @@ [discrete] [[esql-sort]] === `SORT` -Use the `SORT` command to sort rows on one or more fields: + +**Syntax** + +[source,esql] +---- +SORT column1 [ASC/DESC][NULLS FIRST/NULLS LAST][, ..., columnN [ASC/DESC][NULLS FIRST/NULLS LAST]] +---- + +*Parameters* + +`columnX`:: +The column to sort on. + +*Description* + +The `SORT` processing command sorts a table on one or more columns. + +The default sort order is ascending. Use `ASC` or `DESC` to specify an explicit +sort order. + +Two rows with the same sort key are considered equal. You can provide additional +sort expressions to act as tie breakers. + +Sorting on multivalued columns uses the lowest value when sorting ascending and +the highest value when sorting descending. + +By default, `null` values are treated as being larger than any other value. With +an ascending sort order, `null` values are sorted last, and with a descending +sort order, `null` values are sorted first. You can change that by providing +`NULLS FIRST` or `NULLS LAST`. + +*Examples* [source,esql] ---- include::{esql-specs}/docs.csv-spec[tag=sort] ---- -The default sort order is ascending. Set an explicit sort order using `ASC` or -`DESC`: +Explicitly sorting in ascending order with `ASC`: [source,esql] ---- include::{esql-specs}/docs.csv-spec[tag=sortDesc] ---- -Two rows with the same sort key are considered equal. You can provide additional -sort expressions to act as tie breakers: +Providing additional sort expressions to act as tie breakers: [source,esql] ---- include::{esql-specs}/docs.csv-spec[tag=sortTie] ---- -[discrete] -==== `null` values -By default, `null` values are treated as being larger than any other value. With -an ascending sort order, `null` values are sorted last, and with a descending -sort order, `null` values are sorted first. You can change that by providing -`NULLS FIRST` or `NULLS LAST`: +Sorting `null` values first using `NULLS FIRST`: [source,esql] ---- diff --git a/docs/reference/esql/processing-commands/stats.asciidoc b/docs/reference/esql/processing-commands/stats.asciidoc index e0a9bbb52b03e..cbdb74d350fb1 100644 --- a/docs/reference/esql/processing-commands/stats.asciidoc +++ b/docs/reference/esql/processing-commands/stats.asciidoc @@ -1,8 +1,49 @@ [discrete] [[esql-stats-by]] === `STATS ... BY` -Use `STATS ... BY` to group rows according to a common value and calculate one -or more aggregated values over the grouped rows. + +**Syntax** + +[source,esql] +---- +STATS [column1 =] expression1[, ..., [columnN =] expressionN] [BY grouping_column1[, ..., grouping_columnN]] +---- + +*Parameters* + +`columnX`:: +The name by which the aggregated value is returned. If omitted, the name is +equal to the corresponding expression (`expressionX`). + +`expressionX`:: +An expression that computes an aggregated value. + +`grouping_columnX`:: +The column containing the values to group by. + +*Description* + +The `STATS ... BY` processing command groups rows according to a common value +and calculate one or more aggregated values over the grouped rows. If `BY` is +omitted, the output table contains exactly one row with the aggregations applied +over the entire dataset. + +The following aggregation functions are supported: + +include::../functions/aggregation-functions.asciidoc[tag=agg_list] + +NOTE: `STATS` without any groups is much much faster than adding a group. + +NOTE: Grouping on a single column is currently much more optimized than grouping + on many columns. In some tests we have seen grouping on a single `keyword` + column to be five times faster than grouping on two `keyword` columns. Do + not try to work around this by combining the two columns together with + something like <> and then grouping - that is not going to be + faster. + +*Examples* + +Calculating a statistic and grouping by the values of another column: [source.merge.styled,esql] ---- @@ -13,8 +54,8 @@ include::{esql-specs}/docs.csv-spec[tag=stats] include::{esql-specs}/docs.csv-spec[tag=stats-result] |=== -If `BY` is omitted, the output table contains exactly one row with the -aggregations applied over the entire dataset: +Omitting `BY` returns one row with the aggregations applied over the entire +dataset: [source.merge.styled,esql] ---- @@ -39,15 +80,3 @@ keyword family fields): ---- include::{esql-specs}/docs.csv-spec[tag=statsGroupByMultipleValues] ---- - -The following aggregation functions are supported: - -include::../functions/aggregation-functions.asciidoc[tag=agg_list] - -NOTE: `STATS` without any groups is much much faster than adding group. - -NOTE: Grouping on a single field is currently much more optimized than grouping - on many fields. In some tests we've seen grouping on a single `keyword` - field to be five times faster than grouping on two `keyword` fields. Don't - try to work around this combining the two fields together with something - like <> and then grouping - that's not going to be faster. diff --git a/docs/reference/esql/processing-commands/where.asciidoc b/docs/reference/esql/processing-commands/where.asciidoc index 8dd55df12b9e7..e723a977bf99c 100644 --- a/docs/reference/esql/processing-commands/where.asciidoc +++ b/docs/reference/esql/processing-commands/where.asciidoc @@ -2,8 +2,27 @@ [[esql-where]] === `WHERE` -Use `WHERE` to produce a table that contains all the rows from the input table -for which the provided condition evaluates to `true`: +**Syntax** + +[source,esql] +---- +WHERE expression +---- + +*Parameters* + +`expression`:: +A boolean expression. + +*Description* + +The `WHERE` processing command produces a table that contains all the rows from +the input table for which the provided condition evaluates to `true`. + +`WHERE` supports various <> and +<>. + +*Examples* [source,esql] ---- @@ -17,15 +36,7 @@ Which, if `still_hired` is a boolean field, can be simplified to: include::{esql-specs}/docs.csv-spec[tag=whereBoolean] ---- -[discrete] -==== Operators - -Refer to <> for an overview of the supported operators. - -[discrete] -==== Functions -`WHERE` supports various functions for calculating values. Refer to -<> for more information. +Using a function: [source,esql] ---- diff --git a/docs/reference/esql/source-commands/from.asciidoc b/docs/reference/esql/source-commands/from.asciidoc index 5718bfc27ac1c..6f54a42ddad35 100644 --- a/docs/reference/esql/source-commands/from.asciidoc +++ b/docs/reference/esql/source-commands/from.asciidoc @@ -2,10 +2,47 @@ [[esql-from]] === `FROM` -The `FROM` source command returns a table with up to 10,000 documents from a -data stream, index, or alias. Each row in the resulting table represents a -document. Each column corresponds to a field, and can be accessed by the name -of that field. +**Syntax** + +[source,esql] +---- +FROM index_pattern [METADATA fields] +---- + +*Parameters* + +`index_pattern`:: +A list of indices, data streams or aliases. Supports wildcards and date math. + +`fields`:: +A comma-separated list of <> to retrieve. + +*Description* + +The `FROM` source command returns a table with data from a data stream, index, +or alias. Each row in the resulting table represents a document. Each column +corresponds to a field, and can be accessed by the name of that field. + +[NOTE] +==== +By default, an {esql} query without an explicit <> uses an implicit +limit of 500. This applies to `FROM` too. A `FROM` command without `LIMIT`: + +[source,esql] +---- +FROM employees +---- + +is executed as: + +[source,esql] +---- +FROM employees +| LIMIT 500 +---- +==== + +*Examples* [source,esql] ---- diff --git a/docs/reference/esql/source-commands/row.asciidoc b/docs/reference/esql/source-commands/row.asciidoc index edfe5ecbf7cf3..adce844f365b8 100644 --- a/docs/reference/esql/source-commands/row.asciidoc +++ b/docs/reference/esql/source-commands/row.asciidoc @@ -2,9 +2,29 @@ [[esql-row]] === `ROW` +**Syntax** + +[source,esql] +---- +ROW column1 = value1[, ..., columnN = valueN] +---- + +*Parameters* + +`columnX`:: +The column name. + +`valueX`:: +The value for the column. Can be a literal, an expression, or a +<>. + +*Description* + The `ROW` source command produces a row with one or more columns with values that you specify. This can be useful for testing. +*Examples* + [source.merge.styled,esql] ---- include::{esql-specs}/row.csv-spec[tag=example] diff --git a/docs/reference/esql/source-commands/show.asciidoc b/docs/reference/esql/source-commands/show.asciidoc index 956baf628e9f3..ea8c83ceb772a 100644 --- a/docs/reference/esql/source-commands/show.asciidoc +++ b/docs/reference/esql/source-commands/show.asciidoc @@ -1,10 +1,35 @@ [discrete] [[esql-show]] -=== `SHOW ` +=== `SHOW` -The `SHOW ` source command returns information about the deployment and +**Syntax** + +[source,esql] +---- +SHOW item +---- + +*Parameters* + +`item`:: +Can be `INFO` or `FUNCTIONS`. + +*Description* + +The `SHOW` source command returns information about the deployment and its capabilities: * Use `SHOW INFO` to return the deployment's version, build date and hash. * Use `SHOW FUNCTIONS` to return a list of all supported functions and a synopsis of each function. + +*Examples* + +[source.merge.styled,esql] +---- +include::{esql-specs}/show.csv-spec[tag=showFunctionsFiltered] +---- +[%header.monospaced.styled,format=dsv,separator=|] +|=== +include::{esql-specs}/show.csv-spec[tag=showFunctionsFiltered-result] +|=== diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec index 02d530a2ae835..dbf76033fbe79 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/docs.csv-spec @@ -278,7 +278,7 @@ docsWhereFunction // tag::whereFunction[] FROM employees | KEEP first_name, last_name, height -| WHERE length(first_name) < 4 +| WHERE LENGTH(first_name) < 4 // end::whereFunction[] | SORT first_name ; diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec index 117bb9646bc5d..0b45f9ac5aea4 100644 --- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec +++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/show.csv-spec @@ -184,10 +184,16 @@ synopsis:keyword showFunctionsFiltered -show functions | where starts_with(name, "is_"); +// tag::showFunctionsFiltered[] +SHOW functions +| WHERE STARTS_WITH(name, "is_") +// end::showFunctionsFiltered[] +; +// tag::showFunctionsFiltered-result[] name:keyword | synopsis:keyword | argNames:keyword | argTypes:keyword | argDescriptions:keyword | returnType:keyword | description:keyword | optionalArgs:boolean | variadic:boolean is_finite |? is_finite(arg1:?) |arg1 |? | "" |? | "" | false | false is_infinite |? is_infinite(arg1:?) |arg1 |? | "" |? | "" | false | false is_nan |? is_nan(arg1:?) |arg1 |? | "" |? | "" | false | false +// end::showFunctionsFiltered-result[] ;