<br><br><div class="gmail_quote">On Fri, Jun 3, 2011 at 6:30 PM, Chris Muller <span dir="ltr">&lt;<a href="mailto:ma.chris.m@gmail.com">ma.chris.m@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">&gt;&gt;  - Instantiatation / initialization of a MaObjectSerializer.<br>
&gt;&gt;  - Serialization of object graphs of various sizes.<br>
&gt;<br>
&gt; If you have by chance some code snippets to generate graphs for testing<br>
&gt; (maybe you have that in Magma) let us know :)<br>
&gt; We can a pice of code that generates binary trees...<br>
<br>
</div>Yes, see MaFixtureFactory.<br>
<br>
  MaFixtureFactory current samples<br>
<br>
or<br>
<br>
  MaFixtureFactory current knot<br>
<br>
There was a discussion recently about comparing object graphs -- you<br>
may be interested in MaObjectSerializerTester, and how it verifies<br>
serialized--&gt;remateralized object graphs of any shape against the<br>
original fixture graph.  Very useful for ensuring your serializer is<br>
_working_.  :)  See MaObjectSerializerTestCase&gt;&gt;#testSamples which<br>
sends #maEquivalentForSerializationTest: to determine that..<br>
<div class="im"><br></div></blockquote><div><br>Thanks Chris. We have looked at it (and still are).<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">
&gt;&gt; &quot;Serialization&quot;<br>
&gt;&gt; | obj ser |<br>
&gt;&gt; obj := Array with: 1 with: &#39;string&#39;.<br>
&gt;&gt; ser := MaObjectSerializer new.<br>
&gt;&gt; [ ser serializeGraph: obj ] bench<br>
&gt;&gt;<br>
&gt;<br>
&gt; With the rest of the serializers that we do is to serialize the graph into a<br>
&gt; file. How could we do this with Magma Serializer?<br>
&gt; because serializeGraph: answers a MaSerializedGraphBuffer. So, I guess I can<br>
&gt; ask the byteArray to it and do a nextPutAll: or something like that to our<br>
&gt; stream?<br>
<br>
</div>Yes. </blockquote><div><br>Ok. So if aStream is a fileStream for example, then the following two methods are correct:<br><br>&gt;&gt; serialize: anObject on: aStream<br>    <br>    | serializer graphBuffer classDefinitionsByteArray graphBufferByteArray |<br>
    aStream binary.<br>    serializer := MaObjectSerializer new.<br>    graphBuffer := serializer serializeGraph: anObject.<br>    <br>    classDefinitionsByteArray := serializer classDefinitionsByteArray.<br>    graphBufferByteArray := graphBuffer byteArray.<br>
<br>    self nextByteArrayPut: classDefinitionsByteArray on: aStream.<br>    self nextByteArrayPut: graphBufferByteArray on: aStream.<br><br><br>and<br><br>&gt;&gt; materializeFrom: aStream<br><br>    | size classDefinitionsByteArray graphBufferByteArray |<br>
    aStream binary.<br>    classDefinitionsByteArray := self nextByteArrayFrom: aStream.<br>    graphBufferByteArray := self nextByteArrayFrom: aStream.<br><br>    ^ MaObjectSerializer new<br>        classDefinitionsByteArray: classDefinitionsByteArray;<br>
        materializeGraph: graphBufferByteArray<br><br><br>&gt;&gt; nextByteArrayPut: aByteArray on: aWriteStream<br><br>    aWriteStream <br>        nextNumber: 4 put: aByteArray size;<br>        nextPutAll: aByteArray<br>
    <br><br>&gt;&gt; nextByteArrayFrom: aReadStream<br><br>    ^ aReadStream next: (aReadStream nextNumber: 4) <br><br><br>is correct?<br><br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
 I, of course, always appreciated the elegance of the notion that<br>
MaObjectSerializer could operate directly on Streams, </blockquote><div><br>what do you mean to &quot;operate directly on Streams&quot; ?<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
but the problem<br>
is that I also want a secure client-server protocol which wraps the<br>
serialized requests and responses.  So to, for example, calculate a<br>
MAC, the full byteArray of the request is required in advance.  It&#39;s<br>
ok though, serialized / materialized objects have to fit into memory<br>
anyway, so a streaming API doesn&#39;t really offer any practical<br>
advantage - just elegance.<br></blockquote><div><br>ok I understand. <br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
&gt; We also have in Fuel what we call &quot;in memory serialization&quot; that basically<br>
&gt; returns the byteArray and then we can materialize from that. So this case<br>
&gt; would be similar to this usage of Magma, wouldn&#39;t it ?<br>
<br>
</div>Yeah - similar to use of &quot;Ma object serializer&quot;.  (IOW, you don&#39;t have<br>
to load Magma to use MaObjectSerializer), you can just load MaBase.<br></blockquote><div><br>Good!! we didn&#39;t know. Martin fixed that now :)<br> </div><br clear="all"></div><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
<br>