Table of Contents

Class AsyncDataPipeline<T>

Namespace
AiDotNet.Data.Pipeline
Assembly
AiDotNet.dll

Provides async data pipeline operations with prefetching support.

public class AsyncDataPipeline<T> : IAsyncEnumerable<T>

Type Parameters

T

The type of data in the pipeline.

Inheritance
AsyncDataPipeline<T>
Implements
Inherited Members

Methods

Batch(int, bool)

Groups elements into batches.

public AsyncDataPipeline<T[]> Batch(int batchSize, bool dropRemainder = false)

Parameters

batchSize int

Number of elements per batch.

dropRemainder bool

Whether to drop the last incomplete batch.

Returns

AsyncDataPipeline<T[]>

A new AsyncDataPipeline of batched elements.

Filter(Func<T, bool>)

Filters elements based on a predicate.

public AsyncDataPipeline<T> Filter(Func<T, bool> predicate)

Parameters

predicate Func<T, bool>

The filter predicate.

Returns

AsyncDataPipeline<T>

A new AsyncDataPipeline with filtered elements.

GetAsyncEnumerator(CancellationToken)

Returns an enumerator that iterates asynchronously through the collection.

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

Parameters

cancellationToken CancellationToken

A CancellationToken that may be used to cancel the asynchronous iteration.

Returns

IAsyncEnumerator<T>

An enumerator that can be used to iterate asynchronously through the collection.

MapAsync<TResult>(Func<T, CancellationToken, Task<TResult>>)

Applies an async transformation function to each element.

public AsyncDataPipeline<TResult> MapAsync<TResult>(Func<T, CancellationToken, Task<TResult>> selector)

Parameters

selector Func<T, CancellationToken, Task<TResult>>

The async transformation function.

Returns

AsyncDataPipeline<TResult>

A new AsyncDataPipeline with transformed elements.

Type Parameters

TResult

The type of the transformed elements.

Map<TResult>(Func<T, TResult>)

Applies a transformation function to each element.

public AsyncDataPipeline<TResult> Map<TResult>(Func<T, TResult> selector)

Parameters

selector Func<T, TResult>

The transformation function.

Returns

AsyncDataPipeline<TResult>

A new AsyncDataPipeline with transformed elements.

Type Parameters

TResult

The type of the transformed elements.

Prefetch(int)

Prefetches elements in the background for improved performance.

public AsyncDataPipeline<T> Prefetch(int bufferSize = 2)

Parameters

bufferSize int

Number of elements to prefetch.

Returns

AsyncDataPipeline<T>

A new AsyncDataPipeline with prefetching.

Take(int)

Takes only the first N elements.

public AsyncDataPipeline<T> Take(int count)

Parameters

count int

Number of elements to take.

Returns

AsyncDataPipeline<T>

A new AsyncDataPipeline with limited elements.