Skip to content

Commit 38fef1d

Browse files
committed
add a test for bigint on scala side
1 parent 08139a3 commit 38fef1d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

core/src/test/scala/org/apache/spark/api/r/RBackendSuite.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.spark.api.r
1919

20+
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, DataInputStream, DataOutputStream}
21+
2022
import org.apache.spark.SparkFunSuite
2123

2224
class RBackendSuite extends SparkFunSuite {
@@ -28,4 +30,21 @@ class RBackendSuite extends SparkFunSuite {
2830
assert(tracker.get(id) === None)
2931
assert(tracker.size === 0)
3032
}
33+
34+
test("read and write bigint in the buffer") {
35+
val bos = new ByteArrayOutputStream()
36+
val dos = new DataOutputStream(bos)
37+
val tracker = new JVMObjectTracker
38+
SerDe.writeObject(dos, 1380742793415240L.asInstanceOf[Object],
39+
tracker)
40+
val buf = bos.toByteArray
41+
val bis = new ByteArrayInputStream(buf)
42+
val dis = new DataInputStream(bis)
43+
val data = SerDe.readObject(dis, tracker)
44+
assert(data.asInstanceOf[Double] === 1380742793415240L)
45+
bos.close()
46+
bis.close()
47+
dos.close()
48+
dis.close()
49+
}
3150
}

0 commit comments

Comments
 (0)