--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
---
You received this message because you are subscribed to the Google Groups "kryo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kryo-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Nate / Martin (and other helpful people here),In Spark we are thinking about taking the bytes serialized by writeClassAndObject and move it around. Since what we are about to do isn't part of Kryo's contract, it would be great to have somebody more familiar with Kryo to confirm.What we are hoping to do is similar to the following:1. writeClassAndObject(a)2. flush()3.writeClassAndObject(b)4. flush()and then swap the bytes written by the two writeClassAndObject calls to swap the ordering of a and b (i.e. upon deserialization, we want to get b, followed by a).
I took a quick look at writeClassAndObject's source code, and did some basic experiments. It seems to me that one invocation of that method is independent of another invocation. One place that concerned me was the following on the readme page: "Subsequent appearances of that object type within the same object graph are written using a variable length int." However, based on my experiment, it seems like subsequent appearances in a stream does not belong in the "same object graph" -- if I'm understanding this correctly, an object graph does not apply to multiple objects in a stream, but rather only applies to the serialization of a single object (and its children).
On Mon, Mar 23, 2015 at 5:33 AM, Reynold Xin <rx...@databricks.com> wrote:Hi Nate / Martin (and other helpful people here),In Spark we are thinking about taking the bytes serialized by writeClassAndObject and move it around. Since what we are about to do isn't part of Kryo's contract, it would be great to have somebody more familiar with Kryo to confirm.What we are hoping to do is similar to the following:1. writeClassAndObject(a)2. flush()3.writeClassAndObject(b)4. flush()and then swap the bytes written by the two writeClassAndObject calls to swap the ordering of a and b (i.e. upon deserialization, we want to get b, followed by a).Output is similar to ByteBuffer (has a position, capacity, etc) + DataOutputStream (convenience methods). If the same Output is used for multiple serializations (ie calls to writeClassAndObject) then the Output's byte[] will contain the bytes for each (assuming they fit).
What is "flush()" in your example? Output#flush is only useful when the Output has an OutputStream. In that case the Output is emptied into the stream and the position is set to 0.
What specifically are you doing that isn't part of Kryo's contract?
I took a quick look at writeClassAndObject's source code, and did some basic experiments. It seems to me that one invocation of that method is independent of another invocation. One place that concerned me was the following on the readme page: "Subsequent appearances of that object type within the same object graph are written using a variable length int." However, based on my experiment, it seems like subsequent appearances in a stream does not belong in the "same object graph" -- if I'm understanding this correctly, an object graph does not apply to multiple objects in a stream, but rather only applies to the serialization of a single object (and its children).
See Kryo#setAutoReset. You can set it to false if you want the varint ordinals written for object references to be shared for multiple calls to writeClassAndObject. Default is true.
-Nate
--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
---
You received this message because you are subscribed to a topic in the Google Groups "kryo-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kryo-users/6ZUSyfjjtdo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kryo-users+...@googlegroups.com.
You received this message because you are subscribed to the Google Groups "kryo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kryo-users+...@googlegroups.com.