Custom serialization problem (marshal_dump, marshal_load)

Hi,

I have a problem with the marshal_dump and marshal_load…
I built two classes XXX, YYY and implemented both methods like this:

class YYY
@data = “string”
@version = 1

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

class XXX
@data = Array of YYY
@version = 1

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 serialization works correctly when the number of objects YYY is
small, but when it got more than 5000, the serialization doesn’t work.
(the serializaed file has more and less 1 meg)

When I try to not to use marshal_dump and marshal_load. the
serialization works again???

Can someone tell me, where is the difference between customized
serialization and no-customized one???

Thanks you very much

Sayoyo

On 21 May 2008, at 18:52, sayoyo Sayoyo wrote:

The serialization works correctly when the number of objects YYY is
small, but when it got more than 5000, the serialization doesn’t work.
(the serializaed file has more and less 1 meg)

Asking smart questions, lesson 1. Never say “it doesn’t work”. Do say
exactly what happens and how that differs from what you expected.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs