Created
April 12, 2018 14:27
-
-
Save nsphung/2d5c2274238cf521d6208b5847cb61ae to your computer and use it in GitHub Desktop.
Kryo Scala Map Seq Serialization with Twitter Chill
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
import org.objenesis.strategy.StdInstantiatorStrategy | |
import org.scalatest.{FlatSpecLike, Matchers} | |
class MyTest extends FlatSpecLike with Matchers { | |
"the test" should "hasKnownProfiles" in { | |
import com.twitter.chill.{KryoInstantiator, KryoPool} | |
val POOL_SIZE = 10 | |
val instantiator: KryoInstantiator = new KryoInstantiator() | |
.setInstantiatorStrategy(new StdInstantiatorStrategy) | |
val kryo = KryoPool.withByteArrayOutputStream(POOL_SIZE, instantiator) | |
val scalaMap = Map("Hello" -> Seq(Map("toto" -> "caca"))) | |
val ser = kryo.toBytesWithClass(scalaMap) | |
val der = kryo.fromBytes(ser) | |
der shouldEqual (scalaMap) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment