https://github.com/johnynek/maniclass
Generate unique classes for each unique scala type.
https://github.com/johnynek/maniclass
Last synced: 11 months ago
JSON representation
Generate unique classes for each unique scala type.
- Host: GitHub
- URL: https://github.com/johnynek/maniclass
- Owner: johnynek
- Created: 2013-02-17T00:42:59.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-02-17T00:50:14.000Z (over 13 years ago)
- Last Synced: 2025-01-20T00:48:18.387Z (over 1 year ago)
- Language: Scala
- Size: 113 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
maniclass
=========
Generate unique classes for each unique scala type.
An example goes a long ways:
```scala
scala> import org.bykn.maniclass.Maniclass
import org.bykn.maniclass.Maniclass
scala> val mc = Maniclass()
mc: org.bykn.maniclass.Maniclass = org.bykn.maniclass.Maniclass@4658ef71
scala> mc.wrap(List(1,2,3,4))
res0: org.bykn.maniclass.Gettable = org.bykn.maniclass.Gettable0@12dbd81
scala> res0.get
res1: java.lang.Object = List(1, 2, 3, 4)
scala> mc.unwrap[List[Int]](res0)
res2: Option[List[Int]] = Some(List(1, 2, 3, 4))
scala> mc.unwrap[List[Any]](res0)
res3: Option[List[Any]] = Some(List(1, 2, 3, 4))
scala> mc.unwrap[List[String]](res0)
res4: Option[List[String]] = None
```
The motivation here is to deal with Hadoop serialization which switches on Class. This allows us to
wrap each object with an instance of `org.bykn.maniclass.Gettable` whose getName is sufficient to
lookup the original Manifest. This should give more efficient type-safe serialization of scala
objects.