Skip to content

Commit 7eae2d1

Browse files
committed
Merge branch 'master' into reduce-logging
2 parents 66d7066 + d9bcc2a commit 7eae2d1

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

core/src/main/scala/spark/RDD.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ abstract class RDD[T: ClassManifest](@transient sc: SparkContext) extends Serial
256256
}
257257

258258
def saveAsObjectFile(path: String) {
259-
this.glom
259+
this.mapPartitions(iter => iter.grouped(10).map(_.toArray))
260260
.map(x => (NullWritable.get(), new BytesWritable(Utils.serialize(x))))
261261
.saveAsSequenceFile(path)
262262
}

core/src/test/scala/spark/BoundedMemoryCacheSuite.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package spark
22

33
import org.scalatest.FunSuite
44
import org.scalatest.PrivateMethodTester
5+
import org.scalatest.matchers.ShouldMatchers
56

6-
class BoundedMemoryCacheSuite extends FunSuite with PrivateMethodTester {
7+
class BoundedMemoryCacheSuite extends FunSuite with PrivateMethodTester with ShouldMatchers {
78
test("constructor test") {
89
val cache = new BoundedMemoryCache(60)
910
expect(60)(cache.getCapacity)
@@ -22,15 +23,21 @@ class BoundedMemoryCacheSuite extends FunSuite with PrivateMethodTester {
2223
logInfo("Dropping key (%s, %d) of size %d to make space".format(datasetId, partition, entry.size))
2324
}
2425
}
26+
27+
// NOTE: The String class definition changed in JDK 7 to exclude the int fields count and length
28+
// This means that the size of strings will be lesser by 8 bytes in JDK 7 compared to JDK 6.
29+
// http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
30+
// Work around to check for either.
31+
2532
//should be OK
26-
expect(CachePutSuccess(56))(cache.put("1", 0, "Meh"))
33+
cache.put("1", 0, "Meh") should (equal (CachePutSuccess(56)) or equal (CachePutSuccess(48)))
2734

2835
//we cannot add this to cache (there is not enough space in cache) & we cannot evict the only value from
2936
//cache because it's from the same dataset
3037
expect(CachePutFailure())(cache.put("1", 1, "Meh"))
3138

3239
//should be OK, dataset '1' can be evicted from cache
33-
expect(CachePutSuccess(56))(cache.put("2", 0, "Meh"))
40+
cache.put("2", 0, "Meh") should (equal (CachePutSuccess(56)) or equal (CachePutSuccess(48)))
3441

3542
//should fail, cache should obey it's capacity
3643
expect(CachePutFailure())(cache.put("3", 0, "Very_long_and_useless_string"))

core/src/test/scala/spark/SizeEstimatorSuite.scala

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package spark
33
import org.scalatest.FunSuite
44
import org.scalatest.BeforeAndAfterAll
55
import org.scalatest.PrivateMethodTester
6+
import org.scalatest.matchers.ShouldMatchers
67

78
class DummyClass1 {}
89

@@ -19,7 +20,8 @@ class DummyClass4(val d: DummyClass3) {
1920
val x: Int = 0
2021
}
2122

22-
class SizeEstimatorSuite extends FunSuite with BeforeAndAfterAll with PrivateMethodTester {
23+
class SizeEstimatorSuite extends FunSuite
24+
with BeforeAndAfterAll with PrivateMethodTester with ShouldMatchers {
2325
var oldArch: String = _
2426
var oldOops: String = _
2527

@@ -42,11 +44,15 @@ class SizeEstimatorSuite extends FunSuite with BeforeAndAfterAll with PrivateMet
4244
expect(48)(SizeEstimator.estimate(new DummyClass4(new DummyClass3)))
4345
}
4446

47+
// NOTE: The String class definition changed in JDK 7 to exclude the int fields count and length.
48+
// This means that the size of strings will be lesser by 8 bytes in JDK 7 compared to JDK 6.
49+
// http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
50+
// Work around to check for either.
4551
test("strings") {
46-
expect(48)(SizeEstimator.estimate(""))
47-
expect(56)(SizeEstimator.estimate("a"))
48-
expect(56)(SizeEstimator.estimate("ab"))
49-
expect(64)(SizeEstimator.estimate("abcdefgh"))
52+
SizeEstimator.estimate("") should (equal (48) or equal (40))
53+
SizeEstimator.estimate("a") should (equal (56) or equal (48))
54+
SizeEstimator.estimate("ab") should (equal (56) or equal (48))
55+
SizeEstimator.estimate("abcdefgh") should (equal(64) or equal(56))
5056
}
5157

5258
test("primitive arrays") {
@@ -106,17 +112,21 @@ class SizeEstimatorSuite extends FunSuite with BeforeAndAfterAll with PrivateMet
106112
resetOrClear("os.arch", arch)
107113
}
108114

115+
// NOTE: The String class definition changed in JDK 7 to exclude the int fields count and length.
116+
// This means that the size of strings will be lesser by 8 bytes in JDK 7 compared to JDK 6.
117+
// http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-May/010257.html
118+
// Work around to check for either.
109119
test("64-bit arch with no compressed oops") {
110120
val arch = System.setProperty("os.arch", "amd64")
111121
val oops = System.setProperty("spark.test.useCompressedOops", "false")
112122

113123
val initialize = PrivateMethod[Unit]('initialize)
114124
SizeEstimator invokePrivate initialize()
115125

116-
expect(64)(SizeEstimator.estimate(""))
117-
expect(72)(SizeEstimator.estimate("a"))
118-
expect(72)(SizeEstimator.estimate("ab"))
119-
expect(80)(SizeEstimator.estimate("abcdefgh"))
126+
SizeEstimator.estimate("") should (equal (64) or equal (56))
127+
SizeEstimator.estimate("a") should (equal (72) or equal (64))
128+
SizeEstimator.estimate("ab") should (equal (72) or equal (64))
129+
SizeEstimator.estimate("abcdefgh") should (equal (80) or equal (72))
120130

121131
resetOrClear("os.arch", arch)
122132
resetOrClear("spark.test.useCompressedOops", oops)

0 commit comments

Comments
 (0)