Skip to content

[SPARK-30272][SQL][CORE] Remove usage of Guava that breaks in 27; replace with workalikes #26911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

package org.apache.spark.util.kvstore;

import com.google.common.base.Objects;

public class CustomType1 {

@KVIndex
Expand Down Expand Up @@ -52,12 +50,7 @@ public int hashCode() {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("key", key)
.add("id", id)
.add("name", name)
.add("num", num)
.toString();
return "CustomType1[key=" + key + ",id=" + id + ",name=" + name + ",num=" + num;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;

import com.google.common.base.Objects;
import com.google.common.io.ByteStreams;
import io.netty.channel.DefaultFileRegion;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import org.apache.spark.network.util.JavaUtils;
import org.apache.spark.network.util.LimitedInputStream;
Expand Down Expand Up @@ -144,10 +145,10 @@ public Object convertToNetty() throws IOException {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("file", file)
.add("offset", offset)
.add("length", length)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format of the toString is a bit different after this. Before (Guava): Foo{bar=baz, bing=3} After (Commons Lang3): Foo[bar=baz,bing=3]. I think the exact format is not important for these classes though?

.append("file", file)
.append("offset", offset)
.append("length", length)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import java.io.InputStream;
import java.nio.ByteBuffer;

import com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* A {@link ManagedBuffer} backed by a Netty {@link ByteBuf}.
Expand Down Expand Up @@ -69,8 +70,8 @@ public Object convertToNetty() throws IOException {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("buf", buf)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("buf", buf)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
import java.io.InputStream;
import java.nio.ByteBuffer;

import com.google.common.base.Objects;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.Unpooled;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* A {@link ManagedBuffer} backed by {@link ByteBuffer}.
Expand Down Expand Up @@ -67,8 +68,8 @@ public Object convertToNetty() throws IOException {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("buf", buf)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("buf", buf)
.toString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
import javax.annotation.Nullable;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.SettableFuture;
import io.netty.channel.Channel;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -301,10 +302,10 @@ public void close() {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("remoteAdress", channel.remoteAddress())
.add("clientId", clientId)
.add("isActive", isActive())
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("remoteAdress", channel.remoteAddress())
.append("clientId", clientId)
.append("isActive", isActive())
.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import java.util.Objects;

import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* Response to {@link ChunkFetchRequest} when there is an error fetching the chunk.
Expand Down Expand Up @@ -54,7 +57,7 @@ public static ChunkFetchFailure decode(ByteBuf buf) {

@Override
public int hashCode() {
return Objects.hashCode(streamChunkId, errorString);
return Objects.hash(streamChunkId, errorString);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Work-alikes from java.util; should do the same thing as it calls Arrays.hashCode in both cases

}

@Override
Expand All @@ -68,9 +71,9 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("streamChunkId", streamChunkId)
.add("errorString", errorString)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("streamChunkId", streamChunkId)
.append("errorString", errorString)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* Request to fetch a sequence of a single chunk of a stream. This will correspond to a single
Expand Down Expand Up @@ -64,8 +65,8 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("streamChunkId", streamChunkId)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("streamChunkId", streamChunkId)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import java.util.Objects;

import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import org.apache.spark.network.buffer.ManagedBuffer;
import org.apache.spark.network.buffer.NettyManagedBuffer;
Expand Down Expand Up @@ -67,7 +70,7 @@ public static ChunkFetchSuccess decode(ByteBuf buf) {

@Override
public int hashCode() {
return Objects.hashCode(streamChunkId, body());
return Objects.hash(streamChunkId, body());
}

@Override
Expand All @@ -81,9 +84,9 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("streamChunkId", streamChunkId)
.add("buffer", body())
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("streamChunkId", streamChunkId)
.append("buffer", body())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import java.util.Objects;

import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import org.apache.spark.network.buffer.ManagedBuffer;
import org.apache.spark.network.buffer.NettyManagedBuffer;
Expand Down Expand Up @@ -72,8 +75,8 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("body", body())
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("body", body())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import java.util.Objects;

import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/** Response to {@link RpcRequest} for a failed RPC. */
public final class RpcFailure extends AbstractMessage implements ResponseMessage {
Expand Down Expand Up @@ -52,7 +55,7 @@ public static RpcFailure decode(ByteBuf buf) {

@Override
public int hashCode() {
return Objects.hashCode(requestId, errorString);
return Objects.hash(requestId, errorString);
}

@Override
Expand All @@ -66,9 +69,9 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("requestId", requestId)
.add("errorString", errorString)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("requestId", requestId)
.append("errorString", errorString)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import java.util.Objects;

import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import org.apache.spark.network.buffer.ManagedBuffer;
import org.apache.spark.network.buffer.NettyManagedBuffer;
Expand Down Expand Up @@ -64,7 +67,7 @@ public static RpcRequest decode(ByteBuf buf) {

@Override
public int hashCode() {
return Objects.hashCode(requestId, body());
return Objects.hash(requestId, body());
}

@Override
Expand All @@ -78,9 +81,9 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("requestId", requestId)
.add("body", body())
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("requestId", requestId)
.append("body", body())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import java.util.Objects;

import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import org.apache.spark.network.buffer.ManagedBuffer;
import org.apache.spark.network.buffer.NettyManagedBuffer;
Expand Down Expand Up @@ -64,7 +67,7 @@ public static RpcResponse decode(ByteBuf buf) {

@Override
public int hashCode() {
return Objects.hashCode(requestId, body());
return Objects.hash(requestId, body());
}

@Override
Expand All @@ -78,9 +81,9 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("requestId", requestId)
.add("body", body())
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("requestId", requestId)
.append("body", body())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package org.apache.spark.network.protocol;

import com.google.common.base.Objects;
import java.util.Objects;

import io.netty.buffer.ByteBuf;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* Encapsulates a request for a particular chunk of a stream.
Expand Down Expand Up @@ -51,7 +54,7 @@ public static StreamChunkId decode(ByteBuf buffer) {

@Override
public int hashCode() {
return Objects.hashCode(streamId, chunkIndex);
return Objects.hash(streamId, chunkIndex);
}

@Override
Expand All @@ -65,9 +68,9 @@ public boolean equals(Object other) {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("streamId", streamId)
.add("chunkIndex", chunkIndex)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("streamId", streamId)
.append("chunkIndex", chunkIndex)
.toString();
}
}
Loading