From df81d5cfe6dc75ca81d2a43aa516f63bda475494 Mon Sep 17 00:00:00 2001 From: currantw Date: Thu, 12 Dec 2024 13:12:01 -0800 Subject: [PATCH] Revert more changes not specifically related to `Arrays.asList` Signed-off-by: currantw --- .../org/opensearch/sql/ast/tree/RareTopN.java | 3 +- .../aggregation/AggregatorFunctions.java | 61 ++++++++++--------- .../sql/expression/function/FunctionDSL.java | 9 ++- .../sql/expression/text/TextFunctions.java | 3 +- .../window/ranking/RankingWindowFunction.java | 4 +- .../sql/planner/logical/LogicalAD.java | 5 +- .../planner/logical/LogicalAggregation.java | 3 +- .../sql/planner/logical/LogicalEval.java | 3 +- .../sql/planner/logical/LogicalFilter.java | 5 +- .../sql/planner/logical/LogicalHighlight.java | 5 +- .../sql/planner/logical/LogicalLimit.java | 5 +- .../sql/planner/logical/LogicalML.java | 5 +- .../sql/planner/logical/LogicalMLCommons.java | 5 +- .../sql/planner/logical/LogicalProject.java | 3 +- .../sql/planner/logical/LogicalRareTopN.java | 3 +- .../sql/planner/logical/LogicalRemove.java | 5 +- .../sql/planner/logical/LogicalRename.java | 5 +- .../sql/planner/logical/LogicalSort.java | 3 +- .../sql/planner/logical/LogicalWindow.java | 5 +- .../planner/physical/AggregationOperator.java | 3 +- .../sql/planner/physical/DedupeOperator.java | 3 +- .../sql/planner/physical/EvalOperator.java | 3 +- .../sql/planner/physical/FilterOperator.java | 3 +- .../sql/planner/physical/NestedOperator.java | 4 +- .../sql/planner/physical/ProjectOperator.java | 3 +- .../planner/physical/RareTopNOperator.java | 3 +- .../sql/planner/physical/RemoveOperator.java | 3 +- .../sql/planner/physical/RenameOperator.java | 3 +- .../sql/planner/physical/SortOperator.java | 3 +- .../planner/physical/TakeOrderedOperator.java | 3 +- .../sql/planner/physical/WindowOperator.java | 3 +- .../physical/collector/MetricCollector.java | 3 +- .../assigner/TumblingWindowAssigner.java | 3 +- .../protocol/response/QueryResultTest.java | 11 ++-- 34 files changed, 106 insertions(+), 88 deletions(-) diff --git a/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java b/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java index 6c0d203a00..2cbe170541 100644 --- a/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java +++ b/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java @@ -5,6 +5,7 @@ package org.opensearch.sql.ast.tree; +import java.util.Collections; import java.util.List; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -40,7 +41,7 @@ public RareTopN attach(UnresolvedPlan child) { @Override public List getChild() { - return List.of(this.child); + return Collections.singletonList(this.child); } @Override diff --git a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java index c54c1bcc9c..698fb20408 100644 --- a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java +++ b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java @@ -5,7 +5,6 @@ package org.opensearch.sql.expression.aggregation; -import static java.util.Collections.singletonList; import static org.opensearch.sql.data.type.ExprCoreType.ARRAY; import static org.opensearch.sql.data.type.ExprCoreType.DATE; import static org.opensearch.sql.data.type.ExprCoreType.DOUBLE; @@ -22,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import java.util.Collections; import java.util.stream.Collectors; import lombok.experimental.UtilityClass; import org.opensearch.sql.data.type.ExprCoreType; @@ -66,16 +66,16 @@ private static DefaultFunctionResolver avg() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> new AvgAggregator(arguments, DOUBLE)) .put( - new FunctionSignature(functionName, singletonList(DATE)), + new FunctionSignature(functionName, Collections.singletonList(DATE)), (functionProperties, arguments) -> new AvgAggregator(arguments, DATE)) .put( - new FunctionSignature(functionName, singletonList(TIME)), + new FunctionSignature(functionName, Collections.singletonList(TIME)), (functionProperties, arguments) -> new AvgAggregator(arguments, TIME)) .put( - new FunctionSignature(functionName, singletonList(TIMESTAMP)), + new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)), (functionProperties, arguments) -> new AvgAggregator(arguments, TIMESTAMP)) .build()); } @@ -88,7 +88,8 @@ private static DefaultFunctionResolver count() { ExprCoreType.coreTypes().stream() .collect( Collectors.toMap( - type -> new FunctionSignature(functionName, singletonList(type)), + type -> + new FunctionSignature(functionName, Collections.singletonList(type)), type -> (functionProperties, arguments) -> new CountAggregator(arguments, INTEGER)))); @@ -101,16 +102,16 @@ private static DefaultFunctionResolver sum() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(INTEGER)), + new FunctionSignature(functionName, Collections.singletonList(INTEGER)), (functionProperties, arguments) -> new SumAggregator(arguments, INTEGER)) .put( - new FunctionSignature(functionName, singletonList(LONG)), + new FunctionSignature(functionName, Collections.singletonList(LONG)), (functionProperties, arguments) -> new SumAggregator(arguments, LONG)) .put( - new FunctionSignature(functionName, singletonList(FLOAT)), + new FunctionSignature(functionName, Collections.singletonList(FLOAT)), (functionProperties, arguments) -> new SumAggregator(arguments, FLOAT)) .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> new SumAggregator(arguments, DOUBLE)) .build()); } @@ -121,28 +122,28 @@ private static DefaultFunctionResolver min() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(INTEGER)), + new FunctionSignature(functionName, Collections.singletonList(INTEGER)), (functionProperties, arguments) -> new MinAggregator(arguments, INTEGER)) .put( - new FunctionSignature(functionName, singletonList(LONG)), + new FunctionSignature(functionName, Collections.singletonList(LONG)), (functionProperties, arguments) -> new MinAggregator(arguments, LONG)) .put( - new FunctionSignature(functionName, singletonList(FLOAT)), + new FunctionSignature(functionName, Collections.singletonList(FLOAT)), (functionProperties, arguments) -> new MinAggregator(arguments, FLOAT)) .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> new MinAggregator(arguments, DOUBLE)) .put( - new FunctionSignature(functionName, singletonList(STRING)), + new FunctionSignature(functionName, Collections.singletonList(STRING)), (functionProperties, arguments) -> new MinAggregator(arguments, STRING)) .put( - new FunctionSignature(functionName, singletonList(DATE)), + new FunctionSignature(functionName, Collections.singletonList(DATE)), (functionProperties, arguments) -> new MinAggregator(arguments, DATE)) .put( - new FunctionSignature(functionName, singletonList(TIME)), + new FunctionSignature(functionName, Collections.singletonList(TIME)), (functionProperties, arguments) -> new MinAggregator(arguments, TIME)) .put( - new FunctionSignature(functionName, singletonList(TIMESTAMP)), + new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)), (functionProperties, arguments) -> new MinAggregator(arguments, TIMESTAMP)) .build()); } @@ -153,28 +154,28 @@ private static DefaultFunctionResolver max() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(INTEGER)), + new FunctionSignature(functionName, Collections.singletonList(INTEGER)), (functionProperties, arguments) -> new MaxAggregator(arguments, INTEGER)) .put( - new FunctionSignature(functionName, singletonList(LONG)), + new FunctionSignature(functionName, Collections.singletonList(LONG)), (functionProperties, arguments) -> new MaxAggregator(arguments, LONG)) .put( - new FunctionSignature(functionName, singletonList(FLOAT)), + new FunctionSignature(functionName, Collections.singletonList(FLOAT)), (functionProperties, arguments) -> new MaxAggregator(arguments, FLOAT)) .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> new MaxAggregator(arguments, DOUBLE)) .put( - new FunctionSignature(functionName, singletonList(STRING)), + new FunctionSignature(functionName, Collections.singletonList(STRING)), (functionProperties, arguments) -> new MaxAggregator(arguments, STRING)) .put( - new FunctionSignature(functionName, singletonList(DATE)), + new FunctionSignature(functionName, Collections.singletonList(DATE)), (functionProperties, arguments) -> new MaxAggregator(arguments, DATE)) .put( - new FunctionSignature(functionName, singletonList(TIME)), + new FunctionSignature(functionName, Collections.singletonList(TIME)), (functionProperties, arguments) -> new MaxAggregator(arguments, TIME)) .put( - new FunctionSignature(functionName, singletonList(TIMESTAMP)), + new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)), (functionProperties, arguments) -> new MaxAggregator(arguments, TIMESTAMP)) .build()); } @@ -185,7 +186,7 @@ private static DefaultFunctionResolver varSamp() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> varianceSample(arguments, DOUBLE)) .build()); } @@ -196,7 +197,7 @@ private static DefaultFunctionResolver varPop() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> variancePopulation(arguments, DOUBLE)) .build()); } @@ -207,7 +208,7 @@ private static DefaultFunctionResolver stddevSamp() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> stddevSample(arguments, DOUBLE)) .build()); } @@ -218,7 +219,7 @@ private static DefaultFunctionResolver stddevPop() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, Collections.singletonList(DOUBLE)), (functionProperties, arguments) -> stddevPopulation(arguments, DOUBLE)) .build()); } diff --git a/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java b/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java index 670a086f7e..8ebbfd3a3c 100644 --- a/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java +++ b/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java @@ -6,6 +6,7 @@ package org.opensearch.sql.expression.function; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @@ -67,10 +68,11 @@ public static DefaultFunctionResolver define( implWithProperties( SerializableFunction function, ExprType returnType) { return functionName -> { - FunctionSignature functionSignature = new FunctionSignature(functionName, List.of()); + FunctionSignature functionSignature = + new FunctionSignature(functionName, Collections.emptyList()); FunctionBuilder functionBuilder = (functionProperties, arguments) -> - new FunctionExpression(functionName, List.of()) { + new FunctionExpression(functionName, Collections.emptyList()) { @Override public ExprValue valueOf(Environment valueEnv) { return function.apply(functionProperties); @@ -106,7 +108,8 @@ public String toString() { ExprType argsType) { return functionName -> { - FunctionSignature functionSignature = new FunctionSignature(functionName, List.of(argsType)); + FunctionSignature functionSignature = + new FunctionSignature(functionName, Collections.singletonList(argsType)); FunctionBuilder functionBuilder = (functionProperties, arguments) -> new FunctionExpression(functionName, arguments) { diff --git a/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java b/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java index b555c8c05c..2c3bbf7efb 100644 --- a/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java +++ b/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java @@ -12,6 +12,7 @@ import static org.opensearch.sql.expression.function.FunctionDSL.impl; import static org.opensearch.sql.expression.function.FunctionDSL.nullMissingHandling; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import lombok.experimental.UtilityClass; @@ -175,7 +176,7 @@ private DefaultFunctionResolver concat() { concatFuncName, funcName -> Pair.of( - new FunctionSignature(concatFuncName, List.of(ARRAY)), + new FunctionSignature(concatFuncName, Collections.singletonList(ARRAY)), (funcProp, args) -> new FunctionExpression(funcName, args) { @Override diff --git a/core/src/main/java/org/opensearch/sql/expression/window/ranking/RankingWindowFunction.java b/core/src/main/java/org/opensearch/sql/expression/window/ranking/RankingWindowFunction.java index 87f4b7de15..c119629cda 100644 --- a/core/src/main/java/org/opensearch/sql/expression/window/ranking/RankingWindowFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/window/ranking/RankingWindowFunction.java @@ -5,6 +5,8 @@ package org.opensearch.sql.expression.window.ranking; +import static java.util.Collections.emptyList; + import java.util.List; import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.Pair; @@ -33,7 +35,7 @@ public abstract class RankingWindowFunction extends FunctionExpression protected int rank; public RankingWindowFunction(FunctionName functionName) { - super(functionName, List.of()); + super(functionName, emptyList()); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java index 40f70c422c..25dbd14f1a 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java @@ -1,7 +1,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +23,7 @@ public class LogicalAD extends LogicalPlan { * @param arguments arguments of the algorithm */ public LogicalAD(LogicalPlan child, Map arguments) { - super(singletonList(child)); + super(Collections.singletonList(child)); this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java index d40feb7dff..ecbcece623 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.logical; +import java.util.Collections; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +25,7 @@ public class LogicalAggregation extends LogicalPlan { /** Constructor of LogicalAggregation. */ public LogicalAggregation( LogicalPlan child, List aggregatorList, List groupByList) { - super(List.of(child)); + super(Collections.singletonList(child)); this.aggregatorList = aggregatorList; this.groupByList = groupByList; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java index b93b80202e..e7b8f353bc 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.logical; +import java.util.Collections; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +27,7 @@ public class LogicalEval extends LogicalPlan { /** Constructor of LogicalEval. */ public LogicalEval(LogicalPlan child, List> expressions) { - super(List.of(child)); + super(Collections.singletonList(child)); this.expressions = expressions; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java index 7c2902c455..49280e8709 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -21,7 +20,7 @@ public class LogicalFilter extends LogicalPlan { /** Constructor of LogicalFilter. */ public LogicalFilter(LogicalPlan child, Expression condition) { - super(singletonList(child)); + super(Collections.singletonList(child)); this.condition = condition; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java index 1ad86fffd9..41fcd48f81 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +23,7 @@ public class LogicalHighlight extends LogicalPlan { /** Constructor of LogicalHighlight. */ public LogicalHighlight( LogicalPlan childPlan, Expression highlightField, Map arguments) { - super(singletonList(childPlan)); + super(Collections.singletonList(childPlan)); this.highlightField = highlightField; this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java index 6933958976..bec77d9b6f 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -20,7 +19,7 @@ public class LogicalLimit extends LogicalPlan { /** Constructor of LogicalLimit. */ public LogicalLimit(LogicalPlan input, Integer limit, Integer offset) { - super(singletonList(input)); + super(Collections.singletonList(input)); this.limit = limit; this.offset = offset; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java index dd7a5ae460..780e0bba94 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java @@ -1,7 +1,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -22,7 +21,7 @@ public class LogicalML extends LogicalPlan { * @param arguments arguments of the algorithm */ public LogicalML(LogicalPlan child, Map arguments) { - super(singletonList(child)); + super(Collections.singletonList(child)); this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java index bfb1b4261d..cfc313a68d 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java @@ -1,7 +1,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,7 +24,7 @@ public class LogicalMLCommons extends LogicalPlan { * @param arguments arguments of the algorithm */ public LogicalMLCommons(LogicalPlan child, String algorithm, Map arguments) { - super(singletonList(child)); + super(Collections.singletonList(child)); this.algorithm = algorithm; this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java index 37320f8428..5978620480 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.logical; +import java.util.Collections; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +25,7 @@ public LogicalProject( LogicalPlan child, List projectList, List namedParseExpressions) { - super(List.of(child)); + super(Collections.singletonList(child)); this.projectList = projectList; this.namedParseExpressions = namedParseExpressions; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java index 17bb090f60..2c387eca9c 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.logical; +import java.util.Collections; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +31,7 @@ public LogicalRareTopN( Integer noOfResults, List fieldList, List groupByList) { - super(List.of(child)); + super(Collections.singletonList(child)); this.commandType = commandType; this.noOfResults = noOfResults; this.fieldList = fieldList; diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java index a32fe0a2ab..c1aeda22c7 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import java.util.Set; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -22,7 +21,7 @@ public class LogicalRemove extends LogicalPlan { /** Constructor of LogicalRemove. */ public LogicalRemove(LogicalPlan child, Set removeList) { - super(singletonList(child)); + super(Collections.singletonList(child)); this.removeList = removeList; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java index 7c117ce240..25ee645932 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -22,7 +21,7 @@ public class LogicalRename extends LogicalPlan { /** Constructor of LogicalRename. */ public LogicalRename(LogicalPlan child, Map renameMap) { - super(singletonList(child)); + super(Collections.singletonList(child)); this.renameMap = renameMap; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java index f5b9164e59..569ca7e309 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.logical; +import java.util.Collections; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -23,7 +24,7 @@ public class LogicalSort extends LogicalPlan { /** Constructor of LogicalSort. */ public LogicalSort(LogicalPlan child, List> sortList) { - super(List.of(child)); + super(Collections.singletonList(child)); this.sortList = sortList; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java index 37310be391..00c89410a7 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.Collections; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -28,7 +27,7 @@ public class LogicalWindow extends LogicalPlan { /** Constructor of logical window. */ public LogicalWindow( LogicalPlan child, NamedExpression windowFunction, WindowDefinition windowDefinition) { - super(singletonList(child)); + super(Collections.singletonList(child)); this.windowFunction = windowFunction; this.windowDefinition = windowDefinition; } diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java index c853788501..cc1c047c31 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.physical; +import java.util.Collections; import java.util.Iterator; import java.util.List; import lombok.EqualsAndHashCode; @@ -58,7 +59,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java index 73a2fb5aa1..7faec2154b 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java @@ -6,6 +6,7 @@ package org.opensearch.sql.planner.physical; import com.google.common.collect.ImmutableList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -77,7 +78,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java index 14c9e4e8a6..ac62fe1b86 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java @@ -10,6 +10,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -49,7 +50,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java index e1eeb3adb3..088dd07f8d 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.physical; +import java.util.Collections; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -36,7 +37,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java index 92f463b742..fb5ec276ac 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java @@ -5,11 +5,11 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; import static java.util.stream.Collectors.mapping; import static java.util.stream.Collectors.toList; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.ListIterator; @@ -80,7 +80,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java index 84e7c833eb..55422dacd3 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -41,7 +42,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java index c1c6a122a2..ecf997f7ae 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java @@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Streams; import java.util.AbstractMap; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; @@ -83,7 +84,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java index bd2b2c91fc..b4a724aa7a 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java @@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -48,7 +49,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java index 1039646563..e6f97dab4a 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java @@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -55,7 +56,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java index 468ebf9b31..b635f01d18 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java @@ -5,6 +5,7 @@ package org.opensearch.sql.planner.physical; +import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -62,7 +63,7 @@ public void open() { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java index 97d31cb4d4..a6e0f968e6 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java @@ -6,6 +6,7 @@ package org.opensearch.sql.planner.physical; import com.google.common.collect.Ordering; +import java.util.Collections; import java.util.Iterator; import java.util.List; import lombok.EqualsAndHashCode; @@ -72,7 +73,7 @@ public void open() { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java index 16f76b776f..10377ce47a 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java @@ -8,6 +8,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterators; import com.google.common.collect.PeekingIterator; +import java.util.Collections; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -61,7 +62,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return List.of(input); + return Collections.singletonList(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java b/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java index 5307947df7..2cfa3c9457 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java @@ -6,6 +6,7 @@ package org.opensearch.sql.planner.physical.collector; import java.util.AbstractMap; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -56,6 +57,6 @@ public void collect(BindingTuple input) { public List results() { LinkedHashMap map = new LinkedHashMap<>(); aggregators.forEach(agg -> map.put(agg.getKey().getName(), agg.getValue().result())); - return List.of(ExprTupleValue.fromExprValueMap(map)); + return Collections.singletonList(ExprTupleValue.fromExprValueMap(map)); } } diff --git a/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java b/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java index 9a003303a7..2591689a35 100644 --- a/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java +++ b/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java @@ -6,6 +6,7 @@ package org.opensearch.sql.planner.streaming.windowing.assigner; import com.google.common.base.Preconditions; +import java.util.Collections; import java.util.List; import org.opensearch.sql.planner.streaming.windowing.Window; import org.opensearch.sql.utils.DateTimeUtils; @@ -30,6 +31,6 @@ public TumblingWindowAssigner(long windowSize) { @Override public List assign(long timestamp) { long startTime = DateTimeUtils.getWindowStartTime(timestamp, windowSize); - return List.of(new Window(startTime, startTime + windowSize)); + return Collections.singletonList(new Window(startTime, startTime + windowSize)); } } diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java index af03429bac..fc3402e20a 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java @@ -5,8 +5,6 @@ package org.opensearch.sql.protocol.response; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -17,6 +15,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.Arrays; +import java.util.Collections; import org.junit.jupiter.api.Test; import org.opensearch.sql.executor.ExecutionEngine; import org.opensearch.sql.executor.pagination.Cursor; @@ -47,7 +46,7 @@ void columnNameTypes() { QueryResult response = new QueryResult( schema, - singletonList(tupleValue(ImmutableMap.of("name", "John", "age", 20))), + Collections.singletonList(tupleValue(ImmutableMap.of("name", "John", "age", 20))), Cursor.None); assertEquals(ImmutableMap.of("name", "string", "age", "integer"), response.columnNameTypes()); @@ -60,14 +59,16 @@ void columnNameTypesWithAlias() { ImmutableList.of(new ExecutionEngine.Schema.Column("name", "n", STRING))); QueryResult response = new QueryResult( - schema, singletonList(tupleValue(ImmutableMap.of("n", "John"))), Cursor.None); + schema, + Collections.singletonList(tupleValue(ImmutableMap.of("n", "John"))), + Cursor.None); assertEquals(ImmutableMap.of("n", "string"), response.columnNameTypes()); } @Test void columnNameTypesFromEmptyExprValues() { - QueryResult response = new QueryResult(schema, emptyList(), Cursor.None); + QueryResult response = new QueryResult(schema, Collections.emptyList(), Cursor.None); assertEquals(ImmutableMap.of("name", "string", "age", "integer"), response.columnNameTypes()); }