Created
May 12, 2017 14:29
-
-
Save stefanobaghino/5c5b01bdd273f64f181303f768ab008a to your computer and use it in GitHub Desktop.
scalameter PrimitivePickler for generic use cases
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
case class Point(x: Double, y: Double) |
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
final class PointPickler extends PrimitivePickler[Point] { | |
override protected def bits: Int = java.lang.Double.SIZE * 2 | |
override protected def unwrap(from: ByteBuffer): Point = Point(from.getDouble, from.getDouble) | |
override def pickle(x: Point): Array[Byte] = byteBuffer.putDouble(x.x).putDouble(x.y).array() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment