Repository: spark Updated Branches: refs/heads/branch-1.4 9b37e32c5 -> e1f7de33b
[SPARK-7719] Re-add UnsafeShuffleWriterSuite test that was removed for Java 6 compat This patch re-adds a test which was removed in 9ebb44f8abb1a13f045eed60190954db904ffef7 due to a Java 6 compatibility issue. We now use Guava's `Iterators.emptyIterator()` in place of `Collections.emptyIterator()`, which isn't present in all Java 6 versions. Author: Josh Rosen <joshro...@databricks.com> Closes #6298 from JoshRosen/SPARK-7719-fix-java-6-test-code and squashes the following commits: 5c9bd85 [Josh Rosen] Re-add UnsafeShuffleWriterSuite.emptyIterator() test which was removed due to Java 6 issue (cherry picked from commit 5196efff53af4965ff216a9d5c0f8b2b4fc98652) Signed-off-by: Josh Rosen <joshro...@databricks.com> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/e1f7de33 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/e1f7de33 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/e1f7de33 Branch: refs/heads/branch-1.4 Commit: e1f7de33bff418841333a099c3bf3712c28db63a Parents: 9b37e32 Author: Josh Rosen <joshro...@databricks.com> Authored: Wed May 20 17:52:50 2015 -0700 Committer: Josh Rosen <joshro...@databricks.com> Committed: Wed May 20 17:53:11 2015 -0700 ---------------------------------------------------------------------- .../shuffle/unsafe/UnsafeShuffleWriterSuite.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/e1f7de33/core/src/test/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleWriterSuite.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleWriterSuite.java b/core/src/test/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleWriterSuite.java index 03116d8..83d1091 100644 --- a/core/src/test/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleWriterSuite.java +++ b/core/src/test/java/org/apache/spark/shuffle/unsafe/UnsafeShuffleWriterSuite.java @@ -26,6 +26,7 @@ import scala.collection.Iterator; import scala.reflect.ClassTag; import scala.runtime.AbstractFunction1; +import com.google.common.collect.Iterators; import com.google.common.collect.HashMultiset; import com.google.common.io.ByteStreams; import org.junit.After; @@ -253,6 +254,20 @@ public class UnsafeShuffleWriterSuite { } @Test + public void writeEmptyIterator() throws Exception { + final UnsafeShuffleWriter<Object, Object> writer = createWriter(true); + writer.write(Iterators.<Product2<Object, Object>>emptyIterator()); + final Option<MapStatus> mapStatus = writer.stop(true); + assertTrue(mapStatus.isDefined()); + assertTrue(mergedOutputFile.exists()); + assertArrayEquals(new long[NUM_PARTITITONS], partitionSizesInMergedFile); + assertEquals(0, taskMetrics.shuffleWriteMetrics().get().shuffleRecordsWritten()); + assertEquals(0, taskMetrics.shuffleWriteMetrics().get().shuffleBytesWritten()); + assertEquals(0, taskMetrics.diskBytesSpilled()); + assertEquals(0, taskMetrics.memoryBytesSpilled()); + } + + @Test public void writeWithoutSpilling() throws Exception { // In this example, each partition should have exactly one record: final ArrayList<Product2<Object, Object>> dataToWrite = --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org