Skip to content

Commit

Permalink
Remove unnecessary use of Guava functional interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Aug 27, 2019
1 parent b2b7233 commit 7727323
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.datastax.driver.core.querybuilder.Clause;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Select;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
Expand All @@ -63,6 +62,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Stream;

import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.plugin.hive;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
Expand Down Expand Up @@ -76,6 +75,7 @@
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Iterables.getOnlyElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import io.prestosql.spi.connector.ConnectorTransactionHandle;
import io.prestosql.transaction.TransactionId;

import java.util.function.Function;
import java.util.function.Supplier;

import static com.google.common.base.MoreObjects.toStringHelper;
import static java.util.Objects.requireNonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.execution;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures;
Expand Down Expand Up @@ -51,6 +50,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.execution.scheduler;

import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
Expand Down Expand Up @@ -49,6 +48,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.prestosql.execution.scheduler;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
Expand All @@ -41,6 +40,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

import static io.prestosql.execution.scheduler.NodeScheduler.calculateLowWatermark;
import static io.prestosql.execution.scheduler.NodeScheduler.randomizedNodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.execution.scheduler;

import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
Expand All @@ -36,6 +35,7 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

import static io.prestosql.execution.scheduler.NetworkLocation.ROOT_LOCATION;
import static io.prestosql.execution.scheduler.NodeScheduler.calculateLowWatermark;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import io.prestosql.spi.connector.CatalogSchemaTableName;
Expand All @@ -24,6 +23,7 @@
import javax.annotation.concurrent.Immutable;

import java.util.Objects;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static io.prestosql.metadata.MetadataUtil.checkObjectName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.prestosql.operator.aggregation;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import io.airlift.bytecode.DynamicClassLoader;
import io.prestosql.Session;
Expand All @@ -25,6 +24,7 @@

import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;

public class LazyAccumulatorFactoryBinder
implements AccumulatorFactoryBinder
Expand Down
9 changes: 5 additions & 4 deletions presto-main/src/main/java/io/prestosql/util/MoreLists.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Streams.stream;
import static java.util.Objects.requireNonNull;

public final class MoreLists
Expand All @@ -34,20 +35,20 @@ public static <T> List<List<T>> listOfListsCopy(List<List<T>> lists)
.collect(toImmutableList());
}

public static <T> List<T> filteredCopy(List<T> elements, Predicate<T> predicate)
public static <T> List<T> filteredCopy(Iterable<T> elements, Predicate<T> predicate)
{
requireNonNull(elements, "elements is null");
requireNonNull(predicate, "predicate is null");
return elements.stream()
return stream(elements)
.filter(predicate)
.collect(toImmutableList());
}

public static <T, R> List<R> mappedCopy(List<T> elements, Function<T, R> mapper)
public static <T, R> List<R> mappedCopy(Iterable<T> elements, Function<T, R> mapper)
{
requireNonNull(elements, "elements is null");
requireNonNull(mapper, "mapper is null");
return elements.stream()
return stream(elements)
.map(mapper)
.collect(toImmutableList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.execution.scheduler;

import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
Expand Down Expand Up @@ -68,6 +67,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Supplier;

import static com.google.common.base.Preconditions.checkArgument;
import static io.airlift.concurrent.Threads.daemonThreadsNamed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.prestosql.memory;

import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.Futures;
Expand Down Expand Up @@ -47,6 +46,7 @@
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.function.Supplier;

import static com.google.common.base.Preconditions.checkState;
import static io.airlift.units.DataSize.Unit.BYTE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.tests;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import io.prestosql.Session;
import io.prestosql.client.IntervalDayTime;
Expand Down Expand Up @@ -51,10 +50,10 @@
import java.util.OptionalLong;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterables.transform;
import static io.prestosql.spi.type.BigintType.BIGINT;
import static io.prestosql.spi.type.BooleanType.BOOLEAN;
import static io.prestosql.spi.type.Chars.isCharType;
Expand All @@ -74,6 +73,7 @@
import static io.prestosql.type.IntervalYearMonthType.INTERVAL_YEAR_MONTH;
import static io.prestosql.type.JsonType.JSON;
import static io.prestosql.type.UuidType.UUID;
import static io.prestosql.util.MoreLists.mappedCopy;
import static java.util.stream.Collectors.toList;

public class TestingPrestoClient
Expand Down Expand Up @@ -133,7 +133,7 @@ public void addResults(QueryStatusInfo statusInfo, QueryData data)

if (data.getData() != null) {
checkState(types.get() != null, "data received without types");
rows.addAll(transform(data.getData(), dataToRow(types.get())));
rows.addAll(mappedCopy(data.getData(), dataToRow(types.get())));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
*/
package io.prestosql.tests.tpch;

import com.google.common.base.Function;
import io.prestosql.spi.connector.ConnectorIndex;
import io.prestosql.spi.connector.ConnectorPageSource;
import io.prestosql.spi.connector.RecordPageSource;
import io.prestosql.spi.connector.RecordSet;
import io.prestosql.tests.tpch.TpchIndexedData.IndexedTable;

import java.util.function.Function;

import static java.util.Objects.requireNonNull;

class TpchConnectorIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.tests.tpch;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import io.prestosql.plugin.tpch.TpchColumnHandle;
import io.prestosql.spi.connector.ColumnHandle;
Expand All @@ -32,6 +31,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
Expand Down

0 comments on commit 7727323

Please sign in to comment.