Skip to content

Commit

Permalink
Remove extraneous parens in single arg lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
losipiuk committed Feb 17, 2022
1 parent 192cf01 commit 92245c3
Show file tree
Hide file tree
Showing 37 changed files with 64 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void testObtainTokenWhenTokenIsNeverAvailable()
{
RedirectHandler redirectHandler = new MockRedirectHandler();

TokenPoller poller = MockTokenPoller.onPoll((tokenUri) -> {
TokenPoller poller = MockTokenPoller.onPoll(tokenUri -> {
sleepUninterruptibly(Duration.ofMillis(20));
return TokenPollResult.pending(TOKEN_URI);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public NodeAssignmentStats(NodeTaskMap nodeTaskMap, NodeMap nodeMap, List<Remote

// pre-populate the assignment counts with zeros
if (existingTasks.size() < nodeMapSize) {
Function<String, PendingSplitInfo> createEmptySplitInfo = (ignored) -> new PendingSplitInfo(PartitionedSplitsInfo.forZeroSplits(), 0);
Function<String, PendingSplitInfo> createEmptySplitInfo = ignored -> new PendingSplitInfo(PartitionedSplitsInfo.forZeroSplits(), 0);
for (InternalNode node : nodeMap.getNodesByHostAndPort().values()) {
stageQueuedSplitInfo.computeIfAbsent(node.getNodeIdentifier(), createEmptySplitInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private static boolean someParameterIsUnknown(List<Type> parameters)
private List<ApplicableFunction> getUnknownOnlyCastFunctions(List<ApplicableFunction> applicableFunction, List<Type> actualParameters)
{
return applicableFunction.stream()
.filter((function) -> onlyCastsUnknown(function, actualParameters))
.filter(function -> onlyCastsUnknown(function, actualParameters))
.collect(toImmutableList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public synchronized OutputSource createOutputSource(Set<TaskId> selectedTasks)

// Finish ExchangeSink and create ExchangeSource asynchronously to avoid blocking an ExchangeClient thread for potentially substantial amount of time
ListenableFuture<ExchangeSource> exchangeSourceFuture = FluentFuture.from(toListenableFuture(exchangeSink.finish()))
.transformAsync((ignored) -> {
.transformAsync(ignored -> {
exchange.sinkFinished(sinkInstanceHandle);
synchronized (this) {
exchangeSink = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ interface PageReleasedListener
static PageReleasedListener forLocalExchangeMemoryManager(LocalExchangeMemoryManager memoryManager)
{
requireNonNull(memoryManager, "memoryManager is null");
return (releasedSizeInBytes) -> memoryManager.updateMemoryUsage(-releasedSizeInBytes);
return releasedSizeInBytes -> memoryManager.updateMemoryUsage(-releasedSizeInBytes);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public PassthroughExchanger(LocalExchangeSource localExchangeSource, long buffer
this.localExchangeSource = requireNonNull(localExchangeSource, "localExchangeSource is null");
this.memoryTracker = requireNonNull(memoryTracker, "memoryTracker is null");
bufferMemoryManager = new LocalExchangeMemoryManager(bufferMaxMemory);
onPageReleased = (releasedSizeInBytes) -> {
onPageReleased = releasedSizeInBytes -> {
this.bufferMemoryManager.updateMemoryUsage(-releasedSizeInBytes);
this.memoryTracker.accept(-releasedSizeInBytes);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public Type process(Node node, @Nullable StackableAstVisitorContext<Context> con
protected Type visitRow(Row node, StackableAstVisitorContext<Context> context)
{
List<Type> types = node.getItems().stream()
.map((child) -> process(child, context))
.map(child -> process(child, context))
.collect(toImmutableList());

Type type = RowType.anonymous(types);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ private Optional<Expression> coerceComparisonWithRounding(
Type valueType = nullableValue.getType();
Object value = nullableValue.getValue();
return floorValue(valueType, symbolExpressionType, value)
.map((floorValue) -> rewriteComparisonExpression(symbolExpressionType, symbolExpression, valueType, value, floorValue, comparisonOperator));
.map(floorValue -> rewriteComparisonExpression(symbolExpressionType, symbolExpression, valueType, value, floorValue, comparisonOperator));
}

private Expression rewriteComparisonExpression(
Expand Down Expand Up @@ -833,7 +833,7 @@ private Expression rewriteComparisonExpression(
private Optional<Object> floorValue(Type fromType, Type toType, Object value)
{
return getSaturatedFloorCastOperator(fromType, toType)
.map((operator) -> functionInvoker.invoke(operator, session.toConnectorSession(), value));
.map(operator -> functionInvoker.invoke(operator, session.toConnectorSession(), value));
}

private Optional<ResolvedFunction> getSaturatedFloorCastOperator(Type fromType, Type toType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public Expression rewriteIfExpression(IfExpression node, Void context, Expressio
Expression condition = treeRewriter.rewrite(node.getCondition(), context);
Expression trueValue = treeRewriter.rewrite(node.getTrueValue(), context);

Optional<Expression> falseValue = node.getFalseValue().map((value) -> treeRewriter.rewrite(value, context));
Optional<Expression> falseValue = node.getFalseValue().map(value -> treeRewriter.rewrite(value, context));

return new SearchedCaseExpression(ImmutableList.of(new WhenClause(condition, trueValue)), falseValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private JoinEnumerationResult chooseJoinOrder(LinkedHashSet<PlanNode> sources, L
memo.put(multiJoinKey, bestResult);
}

bestResult.planNode.ifPresent((planNode) -> log.debug("Least cost join was: %s", planNode));
bestResult.planNode.ifPresent(planNode -> log.debug("Least cost join was: %s", planNode));
return bestResult;
}

Expand Down Expand Up @@ -446,7 +446,7 @@ private List<JoinEnumerationResult> getPossibleJoinNodes(JoinNode joinNode, Join

private List<JoinEnumerationResult> getPossibleJoinNodes(JoinNode joinNode, DistributionType distributionType)
{
return getPossibleJoinNodes(joinNode, distributionType, (node) -> true);
return getPossibleJoinNodes(joinNode, distributionType, node -> true);
}

private List<JoinEnumerationResult> getPossibleJoinNodes(JoinNode joinNode, DistributionType distributionType, Predicate<JoinNode> isAllowed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ protected RowExpression visitSearchedCaseExpression(SearchedCaseExpression node,
*/
RowExpression expression = node.getDefaultValue()
.map((value) -> process(value, context))
.map(value -> process(value, context))
.orElse(constantNull(getType(node)));

for (WhenClause clause : Lists.reverse(node.getWhenClauses())) {
Expand Down
6 changes: 3 additions & 3 deletions core/trino-main/src/main/java/io/trino/type/DecimalCasts.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private static SqlScalarFunction castFunctionFromDecimalTo(TypeSignature to, Str
.choice(choice -> choice
.implementation(methodsGroup -> methodsGroup
.methods(methodNames)
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
long precision = context.getLiteral("precision");
long scale = context.getLiteral("scale");
Object tenToScale;
Expand Down Expand Up @@ -140,7 +140,7 @@ private static SqlScalarFunction castFunctionToDecimalFromBuilder(TypeSignature
.returnConvention(nullableResult ? NULLABLE_RETURN : FAIL_ON_NULL)
.implementation(methodsGroup -> methodsGroup
.methods(methodNames)
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
DecimalType resultType = (DecimalType) context.getReturnType();
Object tenToScale;
if (isShortDecimal(resultType)) {
Expand All @@ -163,7 +163,7 @@ private static SqlScalarFunction castFunctionToDecimalFromBuilder(TypeSignature
.choice(choice -> choice
.implementation(methodsGroup -> methodsGroup
.methods("shortDecimalToVarchar", "longDecimalToVarchar")
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
long scale = context.getLiteral("scale");
VarcharType resultType = (VarcharType) context.getReturnType();
long length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private DecimalSaturatedFloorCasts() {}
.choice(choice -> choice
.implementation(methodsGroup -> methodsGroup
.methods("shortDecimalToShortDecimal", "shortDecimalToLongDecimal", "longDecimalToShortDecimal", "longDecimalToLongDecimal")
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
int sourcePrecision = toIntExact(context.getLiteral("source_precision"));
int sourceScale = toIntExact(context.getLiteral("source_scale"));
int resultPrecision = toIntExact(context.getLiteral("result_precision"));
Expand Down Expand Up @@ -120,7 +120,7 @@ private static SqlScalarFunction decimalToGenericIntegerTypeSaturatedFloorCast(T
.choice(choice -> choice
.implementation(methodsGroup -> methodsGroup
.methods("shortDecimalToGenericIntegerType", "longDecimalToGenericIntegerType")
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
int sourceScale = toIntExact(context.getLiteral("source_scale"));
return ImmutableList.of(sourceScale, minValue, maxValue);
})))
Expand Down Expand Up @@ -171,7 +171,7 @@ private static SqlScalarFunction genericIntegerTypeToDecimalSaturatedFloorCast(T
.choice(choice -> choice
.implementation(methodsGroup -> methodsGroup
.methods("genericIntegerTypeToShortDecimal", "genericIntegerTypeToLongDecimal")
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
int resultPrecision = toIntExact(context.getLiteral("result_precision"));
int resultScale = toIntExact(context.getLiteral("result_scale"));
return ImmutableList.of(resultPrecision, resultScale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class DecimalToDecimalCasts
.choice(choice -> choice
.implementation(methodsGroup -> methodsGroup
.methods("shortToShortCast")
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
DecimalType argumentType = (DecimalType) context.getParameterTypes().get(0);
DecimalType resultType = (DecimalType) context.getReturnType();
long rescale = longTenToNth(Math.abs(resultType.getScale() - argumentType.getScale()));
Expand All @@ -51,7 +51,7 @@ public final class DecimalToDecimalCasts
}))
.implementation(methodsGroup -> methodsGroup
.methods("shortToLongCast", "longToShortCast", "longToLongCast")
.withExtraParameters((context) -> {
.withExtraParameters(context -> {
DecimalType argumentType = (DecimalType) context.getParameterTypes().get(0);
DecimalType resultType = (DecimalType) context.getReturnType();
return ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public static final class Builder
private ListRoleGrants roleGrants = defaultRoleAuthorizations();
private Grants<String> schemaGrants = new AllowAllGrants<>();
private Grants<SchemaTableName> tableGrants = new AllowAllGrants<>();
private Function<SchemaTableName, ViewExpression> rowFilter = (tableName) -> null;
private Function<SchemaTableName, ViewExpression> rowFilter = tableName -> null;
private BiFunction<SchemaTableName, String, ViewExpression> columnMask = (tableName, columnName) -> null;
private boolean allowMissingColumnsOnInsert;

Expand Down Expand Up @@ -603,7 +603,7 @@ public MockConnectorFactory build()

public static Function<ConnectorSession, List<String>> defaultListSchemaNames()
{
return (session) -> ImmutableList.of();
return session -> ImmutableList.of();
}

public static ListRoleGrants defaultRoleAuthorizations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ private static HashDistributionTaskSource createHashDistributionTaskSource(
partitionedExchangeSources,
replicatedExchangeSources,
splitBatchSize,
(getSplitsTime) -> {},
getSplitsTime -> {},
bucketToPartitionMap,
bucketNodeMap,
Optional.of(CATALOG));
Expand Down Expand Up @@ -625,7 +625,7 @@ private static SourceDistributionTaskSource createSourceDistributionTaskSource(
new TestingSplitSource(CATALOG, splits),
replicatedSources,
splitBatchSize,
(getSplitsTime) -> {},
getSplitsTime -> {},
Optional.of(CATALOG),
minSplitsPerTask,
splitWeightPerTask,
Expand Down Expand Up @@ -676,7 +676,7 @@ private static Optional<List<HostAddress>> addressesList(String... addresses)

private static BucketNodeMap getTestingBucketNodeMap(int bucketCount)
{
return new DynamicBucketNodeMap((split) -> {
return new DynamicBucketNodeMap(split -> {
TestingConnectorSplit testingConnectorSplit = (TestingConnectorSplit) split.getConnectorSplit();
return testingConnectorSplit.getBucket().getAsInt();
}, bucketCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private static SignatureBuilder functionSignature(List<String> arguments, String
{
ImmutableSet<String> literalParameters = ImmutableSet.of("p", "s", "p1", "s1", "p2", "s2", "p3", "s3");
List<TypeSignature> argumentSignatures = arguments.stream()
.map((signature) -> parseTypeSignature(signature, literalParameters))
.map(signature -> parseTypeSignature(signature, literalParameters))
.collect(toImmutableList());
return new SignatureBuilder()
.returnType(parseTypeSignature(returnType, literalParameters))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void testExceptionFromResponseHandler()
TestingTicker ticker = new TestingTicker();
AtomicReference<Duration> tickerIncrement = new AtomicReference<>(new Duration(0, TimeUnit.SECONDS));

TestingHttpClient.Processor processor = (input) -> {
TestingHttpClient.Processor processor = input -> {
Duration delta = tickerIncrement.get();
ticker.increment(delta.toMillis(), TimeUnit.MILLISECONDS);
throw new RuntimeException("Foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ public void testDynamicFilterConsumer()
queryId,
0,
dynamicFilters,
(domains) -> domains.forEach((filter, domain) -> assertNull(consumerCollectedFilters.put(filter, domain))));
domains -> domains.forEach((filter, domain) -> assertNull(consumerCollectedFilters.put(filter, domain))));
assertTrue(consumerCollectedFilters.isEmpty());

dynamicFilterService.addTaskDynamicFilters(
Expand All @@ -686,7 +686,7 @@ filterId1, singleValue(INTEGER, 3L),
queryId,
0,
ImmutableSet.of(filterId1),
(domains) -> domains.forEach((filter, domain) -> assertNull(secondConsumerCollectedFilters.put(filter, domain))));
domains -> domains.forEach((filter, domain) -> assertNull(secondConsumerCollectedFilters.put(filter, domain))));
assertEquals(secondConsumerCollectedFilters, ImmutableMap.of(filterId1, multipleValues(INTEGER, ImmutableList.of(1L, 3L))));

// complete filterId2
Expand Down Expand Up @@ -722,7 +722,7 @@ public void testDynamicFilterConsumerCallbackCount()
queryId,
0,
dynamicFilters,
(domains) -> {
domains -> {
callbackCount.getAndIncrement();
domains.forEach((filter, domain) -> assertNull(consumerCollectedFilters.put(filter, domain)));
});
Expand Down Expand Up @@ -756,7 +756,7 @@ filterId1, multipleValues(INTEGER, ImmutableList.of(1L, 3L)),
queryId,
0,
dynamicFilters,
(domains) -> {
domains -> {
secondCallbackCount.getAndIncrement();
domains.forEach((filter, domain) -> assertNull(secondConsumerCollectedFilters.put(filter, domain)));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public String getName()
@Override
public HeaderAuthenticator create(Map<String, String> config)
{
return (headers) -> Optional.ofNullable(headers.getHeader(header))
return headers -> Optional.ofNullable(headers.getHeader(header))
.map(values -> new BasicPrincipal(values.get(0)))
.orElseThrow(() -> new AccessDeniedException("You shall not pass!"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testFiresOnNestedCountAggregate()
.globalGrouping()
.step(AggregationNode.Step.SINGLE)
.source(
p.aggregation((aggregationBuilder) -> aggregationBuilder
p.aggregation(aggregationBuilder -> aggregationBuilder
.source(p.tableScan(ImmutableList.of(), ImmutableMap.of()))
.globalGrouping()
.step(AggregationNode.Step.SINGLE)))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected String visitNode(Node node, Void context)
protected String visitRow(Row node, Void context)
{
return "ROW (" + Joiner.on(", ").join(node.getItems().stream()
.map((child) -> process(child, context))
.map(child -> process(child, context))
.collect(toList())) + ")";
}

Expand Down Expand Up @@ -613,7 +613,7 @@ protected String visitSearchedCaseExpression(SearchedCaseExpression node, Void c
}

node.getDefaultValue()
.ifPresent((value) -> parts.add("ELSE").add(process(value, context)));
.ifPresent(value -> parts.add("ELSE").add(process(value, context)));

parts.add("END");

Expand All @@ -633,7 +633,7 @@ protected String visitSimpleCaseExpression(SimpleCaseExpression node, Void conte
}

node.getDefaultValue()
.ifPresent((value) -> parts.add("ELSE").add(process(value, context)));
.ifPresent(value -> parts.add("ELSE").add(process(value, context)));

parts.add("END");

Expand Down
Loading

0 comments on commit 92245c3

Please sign in to comment.