tag:blogger.com,1999:blog-5569894.post4733268298667107098..comments2023-11-08T13:18:07.006+00:00Comments on Distributed Memory: Generalized IEnumerable to chunked IEnumerableSteve Gilhamhttp://www.blogger.com/profile/03622573187942388226noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-5569894.post-19498622587903413422011-05-28T12:11:39.835+01:002011-05-28T12:11:39.835+01:00Thanks for the suggestion: it was exactly the prob...Thanks for the suggestion: it was exactly the problem. With a wrapper in place, it's then possible to watch the enumerator's Dispose() method being called after each .Take() (or .ToArray()).bill seddonnoreply@blogger.comtag:blogger.com,1999:blog-5569894.post-60401838046583607112011-05-27T15:00:13.720+01:002011-05-27T15:00:13.720+01:00It looks like the SKipIterator is showing the same...It looks like the SKipIterator is showing the same behaviour as I observed with F# sequence expressions -- the iteration is being Dispose()d and rendered non-functional after the first chunk is extracted.<br /><br />The workround is to add an extra helper class that implements IEnumerator<T> and forwards all the calls except that to Dispose() to the real IEnumerator<T>, and return an instance of that class from the GetEnumerator() method of Ratchet -- equivalent to the F# Controlled type in <a href="http://stevegilham.blogspot.com/2011/04/generalized-ienumerable-to-chunked_12.html" rel="nofollow">the next post</a>.Steve Gilhamhttps://www.blogger.com/profile/03622573187942388226noreply@blogger.comtag:blogger.com,1999:blog-5569894.post-49702081662211776652011-05-26T20:08:43.717+01:002011-05-26T20:08:43.717+01:00Steve, thanks for the example. I've come acro...Steve, thanks for the example. I've come across some behaviour I don't understand and wonder if you've any insight.<br /><br />Imagine you want to skip the first few bytes of an array and chunk the rest. It's natural to .Skip(). However then the Window mechanism will only ever return one window - the first.<br /><br />A solution is to .Skip(n).ToArray() but this will create yet another copy of the array.<br /><br />I have been able to work around the issue by adding a parameter to the Window() extension method which represents the number of elements to skip. This value is used to advance the iterator stored in the ratchet by calling it's MoveNext method. It works and I understand why it works. But I don't understand why calling .Skip() causes a problem. Skip() returns a SkipIterator instance rather than the input array iterator. This must be part of the problem but why?bill seddonhttp://www.lyquidity.comnoreply@blogger.com