Skip to content

Commit

Permalink
Replace calls to Arrays.asList with too few arguments.
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Dec 5, 2024
1 parent b6846ce commit c2fe00e
Show file tree
Hide file tree
Showing 35 changed files with 181 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.google.common.annotations.VisibleForTesting;
import java.time.Clock;
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.opensearch.client.Client;
import org.opensearch.cluster.LocalNodeClusterManagerListener;
Expand Down Expand Up @@ -183,7 +183,7 @@ private void cancel(Cancellable cron) {

@VisibleForTesting
public List<Cancellable> getFlintIndexRetentionCron() {
return Arrays.asList(flintIndexRetentionCron);
return Collections.singletonList(flintIndexRetentionCron);
}

private String executorName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -137,7 +136,7 @@ public class AsyncQueryExecutorServiceSpec extends OpenSearchIntegTestCase {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(TestSettingPlugin.class);
return List.of(TestSettingPlugin.class);
}

public static class TestSettingPlugin extends Plugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static org.opensearch.sql.data.type.ExprCoreType.STRING;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -94,7 +93,7 @@ public LogicalPlan visitFunction(Function node, AnalysisContext context) {
generatePath(nestedField.toString()));
}

return mergeChildIfLogicalNested(new ArrayList<>(Arrays.asList(args)));
return mergeChildIfLogicalNested(new ArrayList<>(List.of(args)));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.sql.ast.expression;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -25,7 +25,7 @@ public class Argument extends UnresolvedExpression {
// private final DataType valueType;
@Override
public List<UnresolvedExpression> getChild() {
return Arrays.asList(value);
return Collections.singletonList(value);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/expression/In.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.sql.ast.expression;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -28,7 +28,7 @@ public class In extends UnresolvedExpression {

@Override
public List<UnresolvedExpression> getChild() {
return Arrays.asList(field);
return Collections.singletonList(field);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/expression/Not.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.sql.ast.expression;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -23,7 +23,7 @@ public class Not extends UnresolvedExpression {

@Override
public List<UnresolvedExpression> getChild() {
return Arrays.asList(expression);
return Collections.singletonList(expression);
}

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

package org.opensearch.sql.ast.expression;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -27,7 +27,7 @@ public UnresolvedArgument(String argName, UnresolvedExpression value) {

@Override
public List<UnresolvedExpression> getChild() {
return Arrays.asList(value);
return Collections.singletonList(value);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/tree/Relation.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package org.opensearch.sql.ast.tree;

import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
Expand All @@ -32,7 +32,7 @@ public Relation(UnresolvedExpression tableName) {
}

public Relation(UnresolvedExpression tableName, String alias) {
this.tableName = Arrays.asList(tableName);
this.tableName = Collections.singletonList(tableName);
this.alias = alias;
}

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

import static org.opensearch.sql.data.type.ExprCoreType.UNKNOWN;

import java.util.Arrays;
import java.util.List;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.expression.Expression;
Expand Down Expand Up @@ -44,7 +43,7 @@ default boolean shouldCast(ExprType other) {

/** Get the parent type. */
default List<ExprType> getParent() {
return Arrays.asList(UNKNOWN);
return List.of(UNKNOWN);
}

/** Get the type name. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.sql.planner.logical;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -30,7 +30,7 @@ public LogicalDedupe(
Integer allowedDuplication,
Boolean keepEmpty,
Boolean consecutive) {
super(Arrays.asList(child));
super(Collections.singletonList(child));
this.dedupeList = dedupeList;
this.allowedDuplication = allowedDuplication;
this.keepEmpty = keepEmpty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import static org.opensearch.sql.data.type.ExprCoreType.INTEGER;
import static org.opensearch.sql.data.type.ExprCoreType.STRUCT;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -77,11 +77,11 @@ protected List<NamedExpression> analyze(UnresolvedExpression unresolvedExpressio
.when(optimizer)
.optimize(any(), any());
return new SelectExpressionAnalyzer(expressionAnalyzer)
.analyze(Arrays.asList(unresolvedExpression), analysisContext, optimizer);
.analyze(Collections.singletonList(unresolvedExpression), analysisContext, optimizer);
}

protected void assertAnalyzeEqual(
NamedExpression expected, UnresolvedExpression unresolvedExpression) {
assertEquals(Arrays.asList(expected), analyze(unresolvedExpression));
assertEquals(Collections.singletonList(expected), analyze(unresolvedExpression));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void testFullyQualifiedName() {
@Test
void defaultDataSourceNameResolve() {
when(dataSourceService.dataSourceExists(any())).thenReturn(Boolean.FALSE);
identifierOf(Arrays.asList("tables"), dataSourceService)
identifierOf(List.of("tables"), dataSourceService)
.datasource(DEFAULT_DATASOURCE_NAME)
.schema(DEFAULT_SCHEMA_NAME)
.name("tables");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private static Stream<Arguments> getValueTestArgumentStream() {
1D,
"1",
true,
Arrays.asList(integerValue(1)),
List.of(integerValue(1)),
ImmutableMap.of("1", integerValue(1)),
LocalDate.parse("2012-08-07"),
LocalTime.parse("18:00:00"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_BOOLEAN;

import com.google.common.collect.ImmutableList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -73,7 +72,7 @@ void register() {
@Test
void compile() {
when(mockExpression.type()).thenReturn(UNDEFINED);
when(functionSignature.getParamTypeList()).thenReturn(Arrays.asList(UNDEFINED));
when(functionSignature.getParamTypeList()).thenReturn(List.of(UNDEFINED));
when(mockfunctionResolver.getFunctionName()).thenReturn(mockFunctionName);
when(mockfunctionResolver.resolve(any()))
.thenReturn(Pair.of(functionSignature, functionExpressionBuilder));
Expand All @@ -82,15 +81,15 @@ void compile() {
BuiltinFunctionRepository repo = new BuiltinFunctionRepository(mockMap);
repo.register(mockfunctionResolver);

repo.compile(functionProperties, mockFunctionName, Arrays.asList(mockExpression));
repo.compile(functionProperties, mockFunctionName, List.of(mockExpression));
verify(functionExpressionBuilder, times(1)).apply(eq(functionProperties), any());
}

@Test
void compile_datasource_defined_function() {
DefaultFunctionResolver dataSourceFunctionResolver = mock(DefaultFunctionResolver.class);
when(mockExpression.type()).thenReturn(UNDEFINED);
when(functionSignature.getParamTypeList()).thenReturn(Arrays.asList(UNDEFINED));
when(functionSignature.getParamTypeList()).thenReturn(List.of(UNDEFINED));
when(dataSourceFunctionResolver.getFunctionName()).thenReturn(mockFunctionName);
when(dataSourceFunctionResolver.resolve(any()))
.thenReturn(Pair.of(functionSignature, functionExpressionBuilder));
Expand All @@ -100,7 +99,7 @@ void compile_datasource_defined_function() {
functionProperties,
Collections.singletonList(dataSourceFunctionResolver),
mockFunctionName,
Arrays.asList(mockExpression));
List.of(mockExpression));
verify(functionExpressionBuilder, times(1)).apply(eq(functionProperties), any());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static org.opensearch.sql.planner.logical.LogicalPlanDSL.window;

import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -92,12 +91,12 @@ public void visit_should_return_default_physical_operator() {
ReferenceExpression exclude = ref("name", STRING);
ReferenceExpression dedupeField = ref("name", STRING);
Expression filterExpr = literal(ExprBooleanValue.of(true));
List<NamedExpression> groupByExprs = Arrays.asList(DSL.named("age", ref("age", INTEGER)));
List<Expression> aggExprs = Arrays.asList(ref("age", INTEGER));
List<NamedExpression> groupByExprs = List.of(named("age", ref("age", INTEGER)));
List<Expression> aggExprs = List.of(ref("age", INTEGER));
ReferenceExpression rareTopNField = ref("age", INTEGER);
List<Expression> topByExprs = Arrays.asList(ref("age", INTEGER));
List<Expression> topByExprs = List.of(ref("age", INTEGER));
List<NamedAggregator> aggregators =
Arrays.asList(DSL.named("avg(age)", new AvgAggregator(aggExprs, ExprCoreType.DOUBLE)));
List.of(named("avg(age)", new AvgAggregator(aggExprs, ExprCoreType.DOUBLE)));
Map<ReferenceExpression, ReferenceExpression> mappings =
ImmutableMap.of(ref("name", STRING), ref("lastname", STRING));
Pair<ReferenceExpression, Expression> newEvalField =
Expand Down
Loading

0 comments on commit c2fe00e

Please sign in to comment.