Skip to content

Commit 5d525e0

Browse files
f1yegornoorul
authored andcommitted
fix(cassandra): fix deseriazilation issue of cassandra repository (spark-jobserver#873)
* Fix deseriazilation issue of cassandra repository because order of retrieved bytes is wrong
1 parent e4758fe commit 5d525e0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

job-server/src/main/scala/spark/jobserver/io/JobCassandraDAO.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class JobCassandraDAO(config: Config) extends JobDAO with FileCacher {
223223
val tuples = JListWrapper(rows).toIndexedSeq.map { row =>
224224
(row.getInt(ChunkIndex), row.getBytes(Binary).array())
225225
}
226-
tuples.sortBy(_._1).toMap.values.foldLeft(Array[Byte]()) { _ ++ _ }
226+
tuples.map(_._2).foldLeft(Array[Byte]()) { _ ++ _ }
227227
}
228228

229229
override def getJobInfo(jobId: String): Future[Option[JobInfo]] = {

job-server/src/test/scala/spark/jobserver/io/JobCassandraDAOSpec.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class JobCassandraDAOSpec extends TestJarFinder with FunSpecLike with Matchers w
138138
jarFilePath should equal (jarFile.getAbsolutePath)
139139
val retrieved = new File(jarFilePath)
140140
jarFile.length() should equal (retrieved.length())
141+
Files.toByteArray(jarFile) should equal(Files.toByteArray(retrieved))
141142
}
142143

143144
it("should retrieve the jar binary content for remote job manager") {
@@ -150,6 +151,7 @@ class JobCassandraDAOSpec extends TestJarFinder with FunSpecLike with Matchers w
150151
// test
151152
jarFile.exists() should equal (true)
152153
jarBinaryContent.length should equal (jarBytes.length)
154+
jarBinaryContent should equal(jarBytes)
153155
}
154156
}
155157

0 commit comments

Comments
 (0)