Hi,
I have a strange problem with the customized serialization...
I have a large object which is built by several classes and each class
has its own marshal_dump and marshal_load, like:
class YYY
attr_reader :data, :version
def initialize
@data = "different objects"
@version = 1
end
def marshal_dump()
return [@version,@data]
end
def marshal_load(var)
@version = var[0]
case @version
when 1
@data = var[1]
else
#do something else
end
end
end
The problem I find out is the serialization works randomly, sometime the
object is serialized correctly and sometime not.(since I'm not able to
deserialize the object, some of the attributes of the objects become
nil) also I find out the size of serialized file is different each time.
and I try to put the serialized data in memory, the size of the memory
is also different each time. like this:
dumpStr = Marshal.dump(mainResults)
puts dumpStr.length.to_s()
mainResults2 = Marshal.load(dumpStr)
Does someone know anything about the customized serialization? There is
not a lot of doc about this....
Thanks you very much
Sayoyo
···
--
Posted via http://www.ruby-forum.com/.