public static IEnumerable<TResult> Batch<TSource, TBucket, TResult>(
this IEnumerable<TSource> source,
int size,
ArrayPool<TSource> pool,
Func<ICurrentBuffer<TSource>, IEnumerable<TBucket>> bucketProjectionSelector,
Func<IEnumerable<TBucket>, TResult> resultSelector
)
<ExtensionAttribute>
Public Shared Function Batch(Of TSource, TBucket, TResult) (
source As IEnumerable(Of TSource),
size As Integer,
pool As ArrayPool(Of TSource),
bucketProjectionSelector As Func(Of ICurrentBuffer(Of TSource), IEnumerable(Of TBucket)),
resultSelector As Func(Of IEnumerable(Of TBucket), TResult)
) As IEnumerable(Of TResult)
public:
[ExtensionAttribute]
generic<typename TSource, typename TBucket, typename TResult>
static IEnumerable<TResult>^ Batch(
IEnumerable<TSource>^ source,
int size,
ArrayPool<TSource>^ pool,
Func<ICurrentBuffer<TSource>^, IEnumerable<TBucket>^>^ bucketProjectionSelector,
Func<IEnumerable<TBucket>^, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member Batch :
source : IEnumerable<'TSource> *
size : int *
pool : ArrayPool<'TSource> *
bucketProjectionSelector : Func<ICurrentBuffer<'TSource>, IEnumerable<'TBucket>> *
resultSelector : Func<IEnumerable<'TBucket>, 'TResult> -> IEnumerable<'TResult>
This operator uses deferred execution and streams its results (however, each bucket is buffered).
Each bucket is backed by a rented array that may be at least size in length.
When more than one bucket is produced, all buckets except the last is guaranteed to have size elements. The last bucket may be smaller depending on the remaining elements in the source sequence.
Each bucket is pre-allocated to size elements. If size is set to a very large value, e.g. MaxValue to effectively disable batching by just hoping for a single bucket, then it can lead to memory exhaustion (OutOfMemoryException).