Skip to content

Commit

Permalink
Revert more changes not specifically related to Arrays.asList
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Dec 12, 2024
1 parent 9202868 commit df81d5c
Show file tree
Hide file tree
Showing 34 changed files with 106 additions and 88 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.sql.ast.tree;

import java.util.Collections;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -40,7 +41,7 @@ public RareTopN attach(UnresolvedPlan child) {

@Override
public List<UnresolvedPlan> getChild() {
return List.of(this.child);
return Collections.singletonList(this.child);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -66,16 +66,16 @@ private static DefaultFunctionResolver avg() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.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());
}
Expand All @@ -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))));
Expand All @@ -101,16 +102,16 @@ private static DefaultFunctionResolver sum() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.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());
}
Expand All @@ -121,28 +122,28 @@ private static DefaultFunctionResolver min() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.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());
}
Expand All @@ -153,28 +154,28 @@ private static DefaultFunctionResolver max() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.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());
}
Expand All @@ -185,7 +186,7 @@ private static DefaultFunctionResolver varSamp() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, singletonList(DOUBLE)),
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> varianceSample(arguments, DOUBLE))
.build());
}
Expand All @@ -196,7 +197,7 @@ private static DefaultFunctionResolver varPop() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, singletonList(DOUBLE)),
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> variancePopulation(arguments, DOUBLE))
.build());
}
Expand All @@ -207,7 +208,7 @@ private static DefaultFunctionResolver stddevSamp() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, singletonList(DOUBLE)),
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> stddevSample(arguments, DOUBLE))
.build());
}
Expand All @@ -218,7 +219,7 @@ private static DefaultFunctionResolver stddevPop() {
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, singletonList(DOUBLE)),
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> stddevPopulation(arguments, DOUBLE))
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,10 +68,11 @@ public static DefaultFunctionResolver define(
implWithProperties(
SerializableFunction<FunctionProperties, ExprValue> 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<Expression, ExprValue> valueEnv) {
return function.apply(functionProperties);
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -24,7 +23,7 @@ public class LogicalAD extends LogicalPlan {
* @param arguments arguments of the algorithm
*/
public LogicalAD(LogicalPlan child, Map<String, Literal> arguments) {
super(singletonList(child));
super(Collections.singletonList(child));
this.arguments = arguments;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.sql.planner.logical;

import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -24,7 +25,7 @@ public class LogicalAggregation extends LogicalPlan {
/** Constructor of LogicalAggregation. */
public LogicalAggregation(
LogicalPlan child, List<NamedAggregator> aggregatorList, List<NamedExpression> groupByList) {
super(List.of(child));
super(Collections.singletonList(child));
this.aggregatorList = aggregatorList;
this.groupByList = groupByList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.sql.planner.logical;

import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -26,7 +27,7 @@ public class LogicalEval extends LogicalPlan {

/** Constructor of LogicalEval. */
public LogicalEval(LogicalPlan child, List<Pair<ReferenceExpression, Expression>> expressions) {
super(List.of(child));
super(Collections.singletonList(child));
this.expressions = expressions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +23,7 @@ public class LogicalHighlight extends LogicalPlan {
/** Constructor of LogicalHighlight. */
public LogicalHighlight(
LogicalPlan childPlan, Expression highlightField, Map<String, Literal> arguments) {
super(singletonList(childPlan));
super(Collections.singletonList(childPlan));
this.highlightField = highlightField;
this.arguments = arguments;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,7 +21,7 @@ public class LogicalML extends LogicalPlan {
* @param arguments arguments of the algorithm
*/
public LogicalML(LogicalPlan child, Map<String, Literal> arguments) {
super(singletonList(child));
super(Collections.singletonList(child));
this.arguments = arguments;
}

Expand Down
Loading

0 comments on commit df81d5c

Please sign in to comment.