Skip to content

Commit

Permalink
[SPARK-35420][BUILD] Replace the usage of toStringHelper with ToStrin…
Browse files Browse the repository at this point in the history
…gBuilder

### What changes were proposed in this pull request?

This PR replaces `toStringHelper`, an API which breaks in Guava 27.

### Why are the changes needed?

SPARK-30272 (#26911) removed usages which breaks in Guava 27 but `toStringHelper` is instroduced again.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Build successfully finished with the following command.
```
build/sbt -Dguava.version=27.0-jre -Phive -Phive-thriftserver -Pyarn -Pmesos -Pkubernetes -Phadoop-cloud -Pdocker-integration-tests -Pkubernetes-integration-tests -Pkinesis-asl -Pspark-ganglia-lgpl package
```

Closes #32567 from sarutak/remove-old-guava-usage.

Authored-by: Kousuke Saruta <sarutak@oss.nttdata.com>
Signed-off-by: Kousuke Saruta <sarutak@oss.nttdata.com>
  • Loading branch information
sarutak committed May 17, 2021
1 parent 7c13636 commit b4348b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import com.google.common.collect.Maps;
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.roaringbitmap.RoaringBitmap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -770,9 +772,9 @@ public int hashCode() {

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

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;

import org.apache.spark.network.protocol.Encoders;

Expand Down Expand Up @@ -51,9 +53,9 @@ public int hashCode() {

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

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

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;
import org.roaringbitmap.RoaringBitmap;

import org.apache.spark.network.protocol.Encoders;
Expand Down Expand Up @@ -76,9 +78,9 @@ public int hashCode() {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("shuffleId", shuffleId)
.add("reduceId size", reduceIds.length)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("shuffleId", shuffleId)
.append("reduceId size", reduceIds.length)
.toString();
}

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

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;

import org.apache.spark.network.protocol.Encoders;

Expand Down Expand Up @@ -59,12 +61,12 @@ public int hashCode() {

@Override
public String toString() {
return Objects.toStringHelper(this)
.add("appId", appId)
.add("shuffleId", shuffleId)
.add("mapIndex", mapIndex)
.add("reduceId", reduceId)
.add("index", index)
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("appId", appId)
.append("shuffleId", shuffleId)
.append("mapIndex", mapIndex)
.append("reduceId", reduceId)
.append("index", index)
.toString();
}

Expand Down

0 comments on commit b4348b7

Please sign in to comment.