[Pharo-project] Fuel serialization - feature/bug
Mariano Martinez Peck
marianopeck at gmail.com
Tue Jun 14 03:35:55 EDT 2011
On Tue, Jun 14, 2011 at 12:56 AM, Yanni Chiu <yanni at rogers.com> wrote:
> On 13/06/11 5:49 PM, Mariano Martinez Peck wrote:
>> Why the following is not enought?
>> (FLSerializer on: myStream) serialize: myPRKernel.
>> (FLMaterializer on: myStream) materialize
> Yes, that's pretty much the code. Except that it's in a test case that uses
> FSMemoryStore. The tests run a lot faster when writing to memory, instead of
> to disk.
Yes, but if you want to serialize in memory you can also use for example:
myStream := (MultiByteBinaryOrTextStream on: '').
(FLSerializer on: myStream) serialize: myPRKernel.
(FLMaterializer on: myStream) materialize
That would use a stream in memory.
And even more, you can serialize in memory with Fuel this way:
| byteArray materializedObject |
byteArray := FLSerializer serializeInMemory: 'mariano'.
materializedObject := FLMaterializer materializeFromByteArray:
self assert: materializedObject equals: 'mariano'.
> The FSMemoryStore holds the "file" bytes in a ByteArray. During
>> serialization, I got a stack trace with KeyNotFound due to
>> FLSerializer>>nextPutReferenceTo: when the object is the "file"
>> Since this ByteArray is where the serialization is being written to,
>> mmmmmm so you are using a stream to serialize and such stream is also
>> being refenced from the object to serialize?
> Yes, that's it - except that the stream is an FSWriteStream on a
> FSMemoryStore "file", which I think is an issue here. The PRKernel is
> holding an instance of PRFuelPersistency, which holds an FSReference. That
> FSReference happens to refer to a memory-based "file".
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-dev