|
17 | 17 |
|
18 | 18 | package org.apache.spark.storage |
19 | 19 |
|
| 20 | +import java.util.UUID |
| 21 | + |
20 | 22 | import org.apache.spark.SparkFunSuite |
21 | 23 |
|
22 | 24 | class BlockIdSuite extends SparkFunSuite { |
@@ -67,6 +69,32 @@ class BlockIdSuite extends SparkFunSuite { |
67 | 69 | assertSame(id, BlockId(id.toString)) |
68 | 70 | } |
69 | 71 |
|
| 72 | + test("shuffle data") { |
| 73 | + val id = ShuffleDataBlockId(4, 5, 6) |
| 74 | + assertSame(id, ShuffleDataBlockId(4, 5, 6)) |
| 75 | + assertDifferent(id, ShuffleDataBlockId(6, 5, 6)) |
| 76 | + assert(id.name === "shuffle_4_5_6.data") |
| 77 | + assert(id.asRDDId === None) |
| 78 | + assert(id.shuffleId === 4) |
| 79 | + assert(id.mapId === 5) |
| 80 | + assert(id.reduceId === 6) |
| 81 | + assert(!id.isShuffle) |
| 82 | + assertSame(id, BlockId(id.toString)) |
| 83 | + } |
| 84 | + |
| 85 | + test("shuffle index") { |
| 86 | + val id = ShuffleIndexBlockId(7, 8, 9) |
| 87 | + assertSame(id, ShuffleIndexBlockId(7, 8, 9)) |
| 88 | + assertDifferent(id, ShuffleIndexBlockId(9, 8, 9)) |
| 89 | + assert(id.name === "shuffle_7_8_9.index") |
| 90 | + assert(id.asRDDId === None) |
| 91 | + assert(id.shuffleId === 7) |
| 92 | + assert(id.mapId === 8) |
| 93 | + assert(id.reduceId === 9) |
| 94 | + assert(!id.isShuffle) |
| 95 | + assertSame(id, BlockId(id.toString)) |
| 96 | + } |
| 97 | + |
70 | 98 | test("broadcast") { |
71 | 99 | val id = BroadcastBlockId(42) |
72 | 100 | assertSame(id, BroadcastBlockId(42)) |
@@ -101,6 +129,30 @@ class BlockIdSuite extends SparkFunSuite { |
101 | 129 | assertSame(id, BlockId(id.toString)) |
102 | 130 | } |
103 | 131 |
|
| 132 | + test("temp local") { |
| 133 | + val id = TempLocalBlockId(new UUID(5, 2)) |
| 134 | + assertSame(id, TempLocalBlockId(new UUID(5, 2))) |
| 135 | + assertDifferent(id, TempLocalBlockId(new UUID(5, 3))) |
| 136 | + assert(id.name === "temp_local_00000000-0000-0005-0000-000000000002") |
| 137 | + assert(id.asRDDId === None) |
| 138 | + assert(id.isBroadcast === false) |
| 139 | + assert(id.id.getMostSignificantBits() === 5) |
| 140 | + assert(id.id.getLeastSignificantBits() === 2) |
| 141 | + assert(!id.isShuffle) |
| 142 | + } |
| 143 | + |
| 144 | + test("temp shuffle") { |
| 145 | + val id = TempShuffleBlockId(new UUID(1, 2)) |
| 146 | + assertSame(id, TempShuffleBlockId(new UUID(1, 2))) |
| 147 | + assertDifferent(id, TempShuffleBlockId(new UUID(1, 3))) |
| 148 | + assert(id.name === "temp_shuffle_00000000-0000-0001-0000-000000000002") |
| 149 | + assert(id.asRDDId === None) |
| 150 | + assert(id.isBroadcast === false) |
| 151 | + assert(id.id.getMostSignificantBits() === 1) |
| 152 | + assert(id.id.getLeastSignificantBits() === 2) |
| 153 | + assert(!id.isShuffle) |
| 154 | + } |
| 155 | + |
104 | 156 | test("test") { |
105 | 157 | val id = TestBlockId("abc") |
106 | 158 | assertSame(id, TestBlockId("abc")) |
|
0 commit comments