Sven, I want to make it work :)
so....the missing methods I told you that I need are:
#nextStringPut:����
#nextNumber:put:
#nextInt32Put:
#nextWordPut:
#contents
Implement #contents I guess it is something like:
ZnBufferedWriteStream >> contents
^ stream contents
Those missing methods I need are implemented PositionableStream. I took the implementation from there and� put it in ZnBufferedWriteStream.
I just added to them a first line "��� self flushBufferIfFull."
The way I am creating it is like this:
stream := ZnBufferedWriteStream on: ((FileDirectory default forceNewFileNamed: 'mariano') binary).
So...is this correct Sven?�� My tests are green :)
Still need to try benchmarks.
Thanks!
Mariano
�
On Tue, May 17, 2011 at 3:34 PM, Sven Van Caekenberghe <sven@beta9.be> wrote:
Mariano,
The disadvantage of the above is that you buffer everything before you write. Furthermore you are growing the buffer all the time (recopying contents) which is not too efficient.
On 17 May 2011, at 15:21, Mariano Martinez Peck wrote:
> Now Igor told us for example, to use a buffer like this:
>
> � � | bufferStream |
> � � bufferStream := ByteArray new writeStream.
>
> � � (FLSerializer on: bufferStream)
> � � � � serialize: anArrayToSerialize.
>
> � � aFileStream nextPutAll: bufferStream contents.
>
> and that it at least 2 times faster than we were doing.... I guess it is because it goes to the disk only once. But MultiByteFileStream uses a buffer, doesn't it ?
Some time ago we had a discussion about this and then I implemented ZnBufferedWriteStream (it should be in Core 1.3), have a look. It was just a quick hack, but it worked in speeding up writing.
Thanks Sven, what a great point you gave me. I tried it a little and I found a couple of methods missing which I used to use for a normal WriteStream.
I will play a little more when I have time and I will ask you again!!