Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnynek/maniclass
Generate unique classes for each unique scala type.
https://github.com/johnynek/maniclass
Last synced: about 1 month 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 (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-02-17T00:50:14.000Z (almost 12 years ago)
- Last Synced: 2024-10-13T13:28:22.130Z (2 months 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.Maniclassscala> val mc = Maniclass()
mc: org.bykn.maniclass.Maniclass = org.bykn.maniclass.Maniclass@4658ef71scala> mc.wrap(List(1,2,3,4))
res0: org.bykn.maniclass.Gettable = org.bykn.maniclass.Gettable0@12dbd81scala> 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.