Table of Contents

Struct ParallelScanCommand<T>

Namespace
DynaSharp
Assembly
DynaSharp.dll

A scan of several segments at once, from Parallel(int). All it can do is give the merged items: pages of several segments have no single key to continue from, so what PageAsync would mean does not compile. Paging across requests goes through Segment(int, int), one segment at a time.

public readonly ref struct ParallelScanCommand<T> where T : IDynamoDbDocument<T>

Type Parameters

T

How the items are read.

Inherited Members

Remarks

See GetCommand<T> for what a command is and what it cannot do.

Methods

ItemsAsync(CancellationToken)

Reads all items of all segments as they come. The order is unspecified: items of one page stay together and in the order of the page, and pages of segments mix in the order they arrive, which differs from run to run.

public IAsyncEnumerable<T> ItemsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels the read, as does WithCancellation on the result.

Returns

IAsyncEnumerable<T>

The items, which can be enumerated once; a second enumeration throws InvalidOperationException, so build the command again to read again.

Remarks

Nothing is sent until the enumeration starts. Each segment has one request in flight at a time, so there are never more requests than segments, and a segment waits with its next page while the consumer is behind, so a slow consumer keeps only about two pages per segment in memory. Each page is one call with its own span and retries, and the spans carry the segment.

The first failure of a segment stops all others and surfaces once, from MoveNextAsync, as the exception it is and not as an aggregate; items that arrived before it may still come first. Cancelling stops all segments, and so does leaving the enumeration early. In every case disposing the enumerator, which await foreach does, waits until no segment runs any more.

Exceptions

InvalidOperationException

The command was already sent, extended or rendered.