returns Some if the size is cheap to calculate.
returns Some if the size is cheap to calculate. otherwise the caller should just serialize into an ByteArrayOutputStream
If all items have a static size, this returns Some, else None NOTE: lawful implementations that return Some here much return Some on dynamicSize so callers don't need to check both when they have an instance.
This is a base Input/OutputStream-based serialization typeclass This is useful for value serialization in hadoop when we don't need to do key sorting for partitioning.
This serialization typeclass must serialize equivalent objects identically to be lawful. Serialization should be the same on all JVMs run at any time, in other words, Serialization is a pure function. Given that constraint, we can always get an Equiv and Hashing from a Serialization (by doing byte-wise equivalence or byte-wise hashing).
A serialization always gives a hash because one can just serialize and then hash the bytes. You might prefer another implementation. This must satisfy: (!equiv(a, b)) || (hash(a) == hash(b))