Hi Nicolas 2018-03-29 17:44 GMT+02:00 Nicolas Cellier < [email protected]>:
> There are two different questions: > - expressiveness > - efficiency > > Real efficiency of transfer (without any intermediate copy) is only > guaranteed in very rare cases > (if the target collection of write stream is same species as source > collection of read stream, and there are no transform in any of the > intermediate wrapper streams, then a direct bulk transfer of the form > targetCollection replaceFrom:to:with: sourceCollection startingAt: is > possible) > I'm not at all convinced that we should focus too much on such > optimization. > > The fact that we have at least two choices, let the readStream drive the > operation, or let the writeStream do it, is a smell. > It sounds like we could provide the two: > aReadStream writeContentsTo: aWriteStream. > aWriteStream readContentsFrom: aReadStream. > ... and then let the programmer decide (maybe there is a more optimal > path). > ... or provide a way to negotiate the transfer (size of chunked buffers, > etc...) > I like this idea. > > Unless there is a more symetrical solution. > It's a long time since I did not check Xtreams, but wasn't there a reified > Buffer that could/would be the effective actor of such transfer? > Xtreams provides nice API to "pipe" multiple streams. But as I remember the Buffer was internal detail hidden from your. Idea was to reuse internal stream arrays to minimize garbage (or something like this). > > > Nicolas > > > 2018-03-29 15:02 GMT+02:00 Denis Kudriashov <[email protected]>: > >> 2018-03-29 14:40 GMT+02:00 Sven Van Caekenberghe <[email protected]>: >> >>> >>> >>> > On 29 Mar 2018, at 14:34, Denis Kudriashov <[email protected]> >>> wrote: >>> > >>> > >>> > 2018-03-29 11:45 GMT+02:00 Sven Van Caekenberghe <[email protected]>: >>> > ZnUtils class>>#streamFrom:to: ? >>> > >>> > Yes, it gives feature which I want. But it's too Java style. >>> > What you think to move it to stream itself? And with what message name? >>> >>> This was written in a specific context, to be efficient. I don't know if >>> it is general enough for broad use. Yes it could be more OO to not make it >>> a utility method, but on the other hand, where would you put it ? >> >> >> In read streams we already have: >> >> >> readInto: aCollection startingAt: startIndex count: n >> >> >> So I would put new method in ReadStream (#readIntoStream: ?). >> >> >>> I am hesitant to make the Stream API bigger ;-) >>> >> >> We already have this method in Utils class. So it is here but in strange >> hidden place. >> >> >>> > > On 29 Mar 2018, at 11:22, Denis Kudriashov <[email protected]> >>> wrote: >>> > > >>> > > Hi. >>> > > >>> > > Do we have simple method to write data between streams? >>> > > >>> > > I want something like: >>> > > >>> > > writeStream nextPutAllFrom: readStream >>> > > >>> > > I always used loop for this. But maybe we have something suitable. >>> Otherwise lets introduce it. >>> > > >>> > > Best regards, >>> > > Denis >>> > >>> > >>> > >>> >>> >>> >> >
