Skip to content

Commit bcb00be

Browse files
LantaoJinkai-chi
authored andcommitted
[SPARK-27216][CORE][BACKPORT-2.4] Upgrade RoaringBitmap to 0.7.45 to fix Kryo unsafe ser/dser issue
## What changes were proposed in this pull request? Back-port of apache#24264 to branch-2.4. HighlyCompressedMapStatus uses RoaringBitmap to record the empty blocks. But RoaringBitmap couldn't be ser/deser with unsafe KryoSerializer. It's a bug of RoaringBitmap-0.5.11 and fixed in latest version. ## How was this patch tested? Add a UT Closes apache#24290 from LantaoJin/SPARK-27216_BACKPORT-2.4. Authored-by: LantaoJin <[email protected]> Signed-off-by: Sean Owen <[email protected]>
1 parent 8074204 commit bcb00be

5 files changed

Lines changed: 16 additions & 30 deletions

File tree

core/src/test/scala/org/apache/spark/serializer/KryoSerializerSuite.scala

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.apache.spark.serializer
1919

20-
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, FileInputStream, FileOutputStream}
20+
import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
2121
import java.nio.ByteBuffer
2222

2323
import scala.collection.JavaConverters._
@@ -32,7 +32,6 @@ import org.apache.spark.{SharedSparkContext, SparkConf, SparkFunSuite}
3232
import org.apache.spark.scheduler.HighlyCompressedMapStatus
3333
import org.apache.spark.serializer.KryoTest._
3434
import org.apache.spark.storage.BlockManagerId
35-
import org.apache.spark.util.Utils
3635

3736
class KryoSerializerSuite extends SparkFunSuite with SharedSparkContext {
3837
conf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
@@ -365,30 +364,6 @@ class KryoSerializerSuite extends SparkFunSuite with SharedSparkContext {
365364
assert(thrown.getCause.isInstanceOf[KryoException])
366365
}
367366

368-
test("SPARK-12222: deserialize RoaringBitmap throw Buffer underflow exception") {
369-
val dir = Utils.createTempDir()
370-
val tmpfile = dir.toString + "/RoaringBitmap"
371-
val outStream = new FileOutputStream(tmpfile)
372-
val output = new KryoOutput(outStream)
373-
val bitmap = new RoaringBitmap
374-
bitmap.add(1)
375-
bitmap.add(3)
376-
bitmap.add(5)
377-
// Ignore Kryo because it doesn't use writeObject
378-
bitmap.serialize(new KryoOutputObjectOutputBridge(null, output))
379-
output.flush()
380-
output.close()
381-
382-
val inStream = new FileInputStream(tmpfile)
383-
val input = new KryoInput(inStream)
384-
val ret = new RoaringBitmap
385-
// Ignore Kryo because it doesn't use readObject
386-
ret.deserialize(new KryoInputObjectInputBridge(null, input))
387-
input.close()
388-
assert(ret == bitmap)
389-
Utils.deleteRecursively(dir)
390-
}
391-
392367
test("KryoOutputObjectOutputBridge.writeObject and KryoInputObjectInputBridge.readObject") {
393368
val kryo = new KryoSerializer(conf).newKryo()
394369

@@ -462,6 +437,14 @@ class KryoSerializerSuite extends SparkFunSuite with SharedSparkContext {
462437
testSerializerInstanceReuse(autoReset = autoReset, referenceTracking = referenceTracking)
463438
}
464439
}
440+
441+
test("SPARK-27216: test RoaringBitmap ser/dser with Kryo") {
442+
val expected = new RoaringBitmap()
443+
expected.add(1787)
444+
val ser = new KryoSerializer(conf).newInstance()
445+
val actual: RoaringBitmap = ser.deserialize(ser.serialize(expected))
446+
assert(actual === expected)
447+
}
465448
}
466449

467450
class KryoSerializerAutoResetDisabledSuite extends SparkFunSuite with SharedSparkContext {

dev/deps/spark-deps-hadoop-2.6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
JavaEWAH-0.3.2.jar
2-
RoaringBitmap-0.5.11.jar
2+
RoaringBitmap-0.7.45.jar
33
ST4-4.0.4.jar
44
activation-1.1.1.jar
55
aircompressor-0.10.jar
@@ -176,6 +176,7 @@ scala-parser-combinators_2.11-1.1.0.jar
176176
scala-reflect-2.11.12.jar
177177
scala-xml_2.11-1.0.5.jar
178178
shapeless_2.11-2.3.2.jar
179+
shims-0.7.45.jar
179180
slf4j-api-1.7.16.jar
180181
slf4j-log4j12-1.7.16.jar
181182
snakeyaml-1.15.jar

dev/deps/spark-deps-hadoop-2.7

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
JavaEWAH-0.3.2.jar
2-
RoaringBitmap-0.5.11.jar
2+
RoaringBitmap-0.7.45.jar
33
ST4-4.0.4.jar
44
activation-1.1.1.jar
55
aircompressor-0.10.jar
@@ -177,6 +177,7 @@ scala-parser-combinators_2.11-1.1.0.jar
177177
scala-reflect-2.11.12.jar
178178
scala-xml_2.11-1.0.5.jar
179179
shapeless_2.11-2.3.2.jar
180+
shims-0.7.45.jar
180181
slf4j-api-1.7.16.jar
181182
slf4j-log4j12-1.7.16.jar
182183
snakeyaml-1.15.jar

dev/deps/spark-deps-hadoop-3.1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
HikariCP-java7-2.4.12.jar
22
JavaEWAH-0.3.2.jar
3-
RoaringBitmap-0.5.11.jar
3+
RoaringBitmap-0.7.45.jar
44
ST4-4.0.4.jar
55
accessors-smart-1.2.jar
66
activation-1.1.1.jar
@@ -196,6 +196,7 @@ scala-parser-combinators_2.11-1.1.0.jar
196196
scala-reflect-2.11.12.jar
197197
scala-xml_2.11-1.0.5.jar
198198
shapeless_2.11-2.3.2.jar
199+
shims-0.7.45.jar
199200
slf4j-api-1.7.16.jar
200201
slf4j-log4j12-1.7.16.jar
201202
snakeyaml-1.15.jar

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@
586586
<dependency>
587587
<groupId>org.roaringbitmap</groupId>
588588
<artifactId>RoaringBitmap</artifactId>
589-
<version>0.5.11</version>
589+
<version>0.7.45</version>
590590
</dependency>
591591
<dependency>
592592
<groupId>commons-net</groupId>

0 commit comments

Comments
 (0)