On Thu, Jun 9, 2011 at 10:43 PM, Chris Muller <asqueaker@gmail.com> wrote:
> Ok. So if aStream is a fileStream for example, then the following two
> methods are correct:
>
>>> serialize: anObject on: aStream
> ....
> and
>
>>> materializeFrom: aStream
>
>     | size classDefinitionsByteArray graphBufferByteArray |
> ...
>
> is correct?

Hmm, well, that might work, but you should just use the helper methods
that are already provided for this, and which essentially do exactly
the same thing.

To serialize an object to a file, you may use
MaObjectSerializer>>#fileOut:toFileNamed:in:, which calls
MaObjectSerializer>>#object:toStream: (operates on any binary
WriteStream).

For materialization, use MaObjectSerializer class>>#fileIn:, which
calls MaObjectSerializer class>>#objectFromStream: (operates on any
binary ReadStream).  BTW, I just noticed these two methods are
incorrectly categorized under 'debugging', they should be under their
own category called 'file' or something..

Thanks Chris. In fact, those methods was the kind of thing I was looking for :)
 

These are just convenience methods for saving / loading users work to
a single file.  If you would need to load multiple files where
performance is concerned, you would want to try to instantiate only
one serializer and use it for all of them.

I am not sure if I understood. In our benchmarks, we have a list of samples and each sample is at the same time an array of objects that we serialize/materialize. For each sample we create instantiate a serializer and a materializer.

I understood now that we should reuse the same serializer/materialize instance for all samples?  if true, why I don't use a Singleton ? I mean...it is not clear for me when to instantiate a serializer.
 
Thanks Chris

--
Mariano
http://marianopeck.wordpress.com