<br><br><div class="gmail_quote">On Fri, Jun 3, 2011 at 6:30 PM, Chris Muller <span dir="ltr"><<a href="mailto:ma.chris.m@gmail.com">ma.chris.m@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">>> - Instantiatation / initialization of a MaObjectSerializer.<br>
>> - Serialization of object graphs of various sizes.<br>
><br>
> If you have by chance some code snippets to generate graphs for testing<br>
> (maybe you have that in Magma) let us know :)<br>
> 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-->remateralized object graphs of any shape against the<br>
original fixture graph. Very useful for ensuring your serializer is<br>
_working_. :) See MaObjectSerializerTestCase>>#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">
>> "Serialization"<br>
>> | obj ser |<br>
>> obj := Array with: 1 with: 'string'.<br>
>> ser := MaObjectSerializer new.<br>
>> [ ser serializeGraph: obj ] bench<br>
>><br>
><br>
> With the rest of the serializers that we do is to serialize the graph into a<br>
> file. How could we do this with Magma Serializer?<br>
> because serializeGraph: answers a MaSerializedGraphBuffer. So, I guess I can<br>
> ask the byteArray to it and do a nextPutAll: or something like that to our<br>
> 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>>> 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>>> 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>>> nextByteArrayPut: aByteArray on: aWriteStream<br><br> aWriteStream <br> nextNumber: 4 put: aByteArray size;<br> nextPutAll: aByteArray<br>
<br><br>>> 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 "operate directly on Streams" ?<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's<br>
ok though, serialized / materialized objects have to fit into memory<br>
anyway, so a streaming API doesn'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>
> We also have in Fuel what we call "in memory serialization" that basically<br>
> returns the byteArray and then we can materialize from that. So this case<br>
> would be similar to this usage of Magma, wouldn't it ?<br>
<br>
</div>Yeah - similar to use of "Ma object serializer". (IOW, you don't have<br>
to load Magma to use MaObjectSerializer), you can just load MaBase.<br></blockquote><div><br>Good!! we didn'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>