Table of Contents

Class AsyncBatchConfigurationBuilder<TBatch>

Namespace
AiDotNet.Extensions
Assembly
AiDotNet.dll

Builder for configuring async batch iteration with a fluent API.

public class AsyncBatchConfigurationBuilder<TBatch> : IAsyncEnumerable<TBatch>

Type Parameters

TBatch

The type of batch returned by iteration.

Inheritance
AsyncBatchConfigurationBuilder<TBatch>
Implements
Inherited Members

Remarks

This builder allows chaining configuration methods before async iteration. Implements IAsyncEnumerable to support await foreach loops.

Constructors

AsyncBatchConfigurationBuilder(IBatchIterable<TBatch>, int?, int)

Initializes a new instance of the AsyncBatchConfigurationBuilder.

public AsyncBatchConfigurationBuilder(IBatchIterable<TBatch> source, int? batchSize, int prefetchCount)

Parameters

source IBatchIterable<TBatch>

The batch iterable source.

batchSize int?

Optional batch size override.

prefetchCount int

Number of batches to prefetch.

Methods

DropLast()

Drops the last incomplete batch if the dataset doesn't divide evenly.

public AsyncBatchConfigurationBuilder<TBatch> DropLast()

Returns

AsyncBatchConfigurationBuilder<TBatch>

This builder for method chaining.

GetAsyncEnumerator(CancellationToken)

Returns an async enumerator that iterates through the batches.

public IAsyncEnumerator<TBatch> GetAsyncEnumerator(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Token to cancel the iteration.

Returns

IAsyncEnumerator<TBatch>

An async enumerator for the batch sequence.

KeepLast()

Keeps the last batch even if incomplete.

public AsyncBatchConfigurationBuilder<TBatch> KeepLast()

Returns

AsyncBatchConfigurationBuilder<TBatch>

This builder for method chaining.

NoShuffle()

Disables shuffling of data before batching.

public AsyncBatchConfigurationBuilder<TBatch> NoShuffle()

Returns

AsyncBatchConfigurationBuilder<TBatch>

This builder for method chaining.

Shuffled()

Enables shuffling of data before batching.

public AsyncBatchConfigurationBuilder<TBatch> Shuffled()

Returns

AsyncBatchConfigurationBuilder<TBatch>

This builder for method chaining.

WithSeed(int)

Sets a random seed for reproducible shuffling.

public AsyncBatchConfigurationBuilder<TBatch> WithSeed(int seed)

Parameters

seed int

The random seed value.

Returns

AsyncBatchConfigurationBuilder<TBatch>

This builder for method chaining.