scala-pickling

scala-pickling in POJO in scala 2.11 - Is it really simple?

让人想犯罪 __ 提交于 2019-12-24 11:27:51
问题 I'm trying to use scala-pickling because at site github it seems so easy and clean. But, I'm failing in use it in this simple REPL : scala> import scala.pickling._ import scala.pickling._ scala> import scala.pickling.Defaults._ import scala.pickling.Defaults._ scala> import binary._ import binary._ scala> class Xpto { var a = 0D; var b = 0 } defined class Xpto scala> val v = new Xpto { a = 1.23; b = 5 } v: Xpto = $anon$1@636d2b03 scala> v.pickle <console>:19: error: type mismatch; found : v

Scala pickling: Simple custom pickler for my own class?

荒凉一梦 提交于 2019-12-14 02:18:38
问题 I am trying to pickle some relatively-simple-structured but large-and-slow-to-create classes in a Scala NLP (natural language processing) app of mine. Because there's lots of data, it needs to pickle and esp. unpickle quickly and without bloat. Java serialization evidently sucks in this regard. I know about Kryo but I've never used it. I've also run into Apache Avro, which seems similar although I'm not quite sure why it's not normally mentioned as a suitable solution. Neither is Scala

Conflicting cross-version suffixes in: org.scalamacros:quasiquotes

有些话、适合烂在心里 提交于 2019-12-12 14:24:48
问题 I am trying to use scala-pickling in one of my projects. I tried to mimic the build file of macroid which seems to use pickling too but I keep getting this error on sbt test : [error] Modules were resolved with conflicting cross-version suffixes in dijon: [error] org.scalamacros:quasiquotes _2.10, _2.10.3 java.lang.RuntimeException: Conflicting cross-version suffixes in: org.scalamacros:quasiquotes at scala.sys.package$.error(package.scala:27) at sbt.ConflictWarning$.processCrossVersioned

Out of memory error during Scala compilation

孤者浪人 提交于 2019-12-11 05:59:20
问题 I'm using the macro-heavy scala-pickling along with shapeless , and I keep crashing the Scala 2.10.3 compiler with an apparent out of memory error. The tail of the error message looks like this: [error] <tpt> // tree.tpe=tasks.anonfun$218 [error] Block( // tree.tpe=Unit [error] Apply( // def <init>(): scala.runtime.AbstractFunction1 in class AbstractFunction1, tree.tpe=scala.runtime.AbstractFunction1 [error] SimpleMiddlebury$$anonfun$218.super."<init>" // def <init>(): scala.runtime

Scala pickling: how?

心不动则不痛 提交于 2019-12-10 02:21:21
问题 I'm trying to use "pickling" serialization is Scala, and I see the same example demonstrating it: import scala.pickling._ import json._ val pckl = List(1, 2, 3, 4).pickle Unpickling is just as easy as pickling: val lst = pckl.unpickle[List[Int]] This example raises some question. First of all, it skips converting of object to string. Apparently you need to call pckl.value to get json string representation. Unpickling is even more confusing. Deserialization is an act of turning string (or

Scala Pickling: Writing a custom pickler / unpickler for nested structures

爱⌒轻易说出口 提交于 2019-12-07 06:20:00
问题 I'm trying to write a custom SPickler / Unpickler pair to work around some the current limitations of scala-pickling. The data type I'm trying to pickle is a case class, where some of the fields already have their own SPickler and Unpickler instances. I'd like to use these instances in my custom pickler, but I don't know how. Here's an example of what I mean: // Here's a class for which I want a custom SPickler / Unpickler. // One of its fields can already be pickled, so I'd like to reuse

Scala Pickling: Writing a custom pickler / unpickler for nested structures

最后都变了- 提交于 2019-12-05 10:16:50
I'm trying to write a custom SPickler / Unpickler pair to work around some the current limitations of scala-pickling. The data type I'm trying to pickle is a case class, where some of the fields already have their own SPickler and Unpickler instances. I'd like to use these instances in my custom pickler, but I don't know how. Here's an example of what I mean: // Here's a class for which I want a custom SPickler / Unpickler. // One of its fields can already be pickled, so I'd like to reuse that logic. case class MyClass[A: SPickler: Unpickler: FastTypeTag](myString: String, a: A) // Here's my

Scala pickling: how?

淺唱寂寞╮ 提交于 2019-12-05 02:28:48
I'm trying to use "pickling" serialization is Scala, and I see the same example demonstrating it: import scala.pickling._ import json._ val pckl = List(1, 2, 3, 4).pickle Unpickling is just as easy as pickling: val lst = pckl.unpickle[List[Int]] This example raises some question. First of all, it skips converting of object to string. Apparently you need to call pckl.value to get json string representation. Unpickling is even more confusing. Deserialization is an act of turning string (or bytes) into an object. How come this "example" demonstrates deserialization if there is no string/binry

Scala Pickling and type parameters

独自空忆成欢 提交于 2019-12-04 09:33:49
问题 I'm using Scala Pickling, an automatic serialization framework for Scala. According to the author's slides, any type T can be pickled as long as there is an implicit Pickler[T] in scope. Here, I'm assuming she means scala.tools.nsc.io.Pickler . However, the following does not compile: import scala.pickling._ import scala.pickling.binary._ import scala.tools.nsc.io.Pickler object Foo { def bar[T: Pickler](t: T) = t.pickle } The error is: [error] exception during macro expansion: [error] scala

Scala Pickling and type parameters

六月ゝ 毕业季﹏ 提交于 2019-12-03 03:18:00
I'm using Scala Pickling , an automatic serialization framework for Scala. According to the author's slides , any type T can be pickled as long as there is an implicit Pickler[T] in scope. Here, I'm assuming she means scala.tools.nsc.io.Pickler . However, the following does not compile: import scala.pickling._ import scala.pickling.binary._ import scala.tools.nsc.io.Pickler object Foo { def bar[T: Pickler](t: T) = t.pickle } The error is: [error] exception during macro expansion: [error] scala.ScalaReflectionException: type T is not a class [error] at scala.reflect.api.Symbols$SymbolApi$class