Binary

The saddle-binary module offers a saddle specific fast serialization format. Its main use is as a temporary format which can be parsed very efficiently. It can serialize Vecs, Mats, Series and Frames.

The entry point of these APIs are the org.saddle.binary.Writer and Reader objects.

The scaladoc documents the serialization format.

An example:

import org.saddle._
import org.saddle.order._

val frame = Frame(
  Mat(Vec(1d, 2d), Vec(3d, 4d), Vec(5d, 6d)),
  Index("r1", "r2"),
  Index("c1", "c2", "c3")
)
// frame: Frame[String, String, Double] = [2 x 3]
//           c1     c2     c3 
//       ------ ------ ------ 
// r1 -> 1.0000 3.0000 5.0000 
// r2 -> 2.0000 4.0000 6.0000 
// 
val binaryFrame = org.saddle.binary.Writer.writeFrameIntoArray(frame)
// binaryFrame: Either[String, Array[Byte]] = Right(
//   value = Array(
//     83,
//     65,
//     68,
//     68,
//     76,
//     69,
//     1,
//     0,
//     89,
//     0,
//     0,
//     0,
//     123,
//     34,
//     100,
//     97,
//     116,
//     97,
//     116,
//     121,
//     112,
//     101,
//     34,
//     58,
//     34,
//     100,
//     111,
//     117,
//     98,
//     108,
//     101,
//     34,
//     44,
//     34,
//     99,
//     111,
//     108,
//     105,
//     120,
//     34,
//     58,
//     91,
//     34,
//     99,
//     49,
//     34,
//     44,
// ...