Skip to content

Instantly share code, notes, and snippets.

@nsphung
Created April 12, 2018 14:27
Show Gist options
  • Save nsphung/2d5c2274238cf521d6208b5847cb61ae to your computer and use it in GitHub Desktop.
Save nsphung/2d5c2274238cf521d6208b5847cb61ae to your computer and use it in GitHub Desktop.
Kryo Scala Map Seq Serialization with Twitter Chill
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