Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from ryan-williams/h
move JavaSerialization to test-utils
- Loading branch information
Showing
8 changed files
with
107 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
name := "spark-tests" | ||
|
||
version := "2.1.0" | ||
version := "2.2.0" | ||
|
||
deps ++= Seq( | ||
paths % "1.2.0", | ||
scalatest, | ||
spark, | ||
spark_util % "1.2.1", | ||
spark_util % "1.3.0", | ||
testUtils | ||
) | ||
|
||
testUtilsVersion := "1.3.0" | ||
|
||
// Don't include default parent-plugin test-deps | ||
testDeps := Nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
addSbtPlugin("org.hammerlab" % "sbt-parent" % "3.0.0") | ||
addSbtPlugin("org.hammerlab" % "sbt-parent" % "3.1.1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
log4j.rootLogger = WARN, out | ||
|
||
log4j.appender.out = org.apache.log4j.ConsoleAppender | ||
log4j.appender.out.layout = org.apache.log4j.PatternLayout | ||
log4j.appender.out.layout.ConversionPattern = %d (%t) [%p] %m%n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/main/scala/org/hammerlab/spark/test/serde/JavaSerialization.scala
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
src/test/scala/org/hammerlab/spark/test/rdd/RDDSerializationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.hammerlab.spark.test.rdd | ||
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream } | ||
|
||
import org.apache.hadoop.io.{ BytesWritable, NullWritable } | ||
import org.apache.hadoop.mapred.SequenceFileOutputFormat | ||
import org.apache.spark.rdd.RDD | ||
import org.hammerlab.hadoop.splits.UnsplittableSequenceFileInputFormat | ||
import org.hammerlab.paths.Path | ||
|
||
import scala.reflect.ClassTag | ||
|
||
class RDDSerializationTest | ||
extends RDDSerialization { | ||
override protected def serializeRDD[T: ClassTag](rdd: RDD[T], | ||
path: Path): RDD[T] = { | ||
rdd | ||
.map { | ||
t ⇒ | ||
NullWritable.get → { | ||
val bos = new ByteArrayOutputStream() | ||
val oos = new ObjectOutputStream(bos) | ||
oos.writeObject(t) | ||
oos.close() | ||
new BytesWritable(bos.toByteArray) | ||
} | ||
} | ||
.saveAsHadoopFile[ | ||
SequenceFileOutputFormat[ | ||
NullWritable, | ||
BytesWritable | ||
] | ||
]( | ||
path.toString | ||
) | ||
|
||
rdd | ||
} | ||
|
||
override protected def deserializeRDD[T: ClassTag](path: Path): RDD[T] = | ||
sc | ||
.hadoopFile[ | ||
NullWritable, | ||
BytesWritable, | ||
UnsplittableSequenceFileInputFormat[ | ||
NullWritable, | ||
BytesWritable | ||
] | ||
]( | ||
path.toString | ||
) | ||
.values | ||
.map { | ||
bytes ⇒ | ||
val bis = new ByteArrayInputStream(bytes.getBytes) | ||
val ois = new ObjectInputStream(bis) | ||
val t = ois.readObject().asInstanceOf[T] | ||
ois.close() | ||
t | ||
} | ||
|
||
test("ints round trip") { | ||
verifyFileSizesAndSerde(1 to 1000, 23565) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/test/scala/org/hammerlab/spark/test/serde/SerializationSizeTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters