Skip to content

IPgParallelCustomScan<TState, TShared>

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Runs a custom scan in parallel: PostgreSQL’s workers and the leader each read part of the rows, coordinating through shared memory the provider lays out as TShared.

public interface IPgParallelCustomScan<TState, TShared> : IPgCustomScan<TState> where TState : class where TShared : unmanaged

Type parameters:

TState

The per-scan state, one in each process that runs the scan.

TShared

The shared memory’s layout. Use PgAtomicValue<T> fields for values processes update concurrently.

Offer parallel paths with AddParallelPath(PgCustomScanPath, int). A provider that implements this interface declares that its scans can run in parallel workers, so its other paths can run there too. PostgreSQL can still run a parallel plan without workers, for example inside a cursor; the scan then gets no shared memory and must produce all the rows itself.

AttachShared(TState, PgCustomScanSharedMemory<TShared>)

Section titled “AttachShared(TState, PgCustomScanSharedMemory<TShared>)”

Gives a process’s scan the shared memory before its first read, in the leader after InitializeShared(TState, ref TShared) and in each worker after Begin(PgCustomScanContext).

public static abstract void AttachShared(TState state, PgCustomScanSharedMemory<TShared> memory)

Parameters:

state — TState

This process’s state.

memory — PgCustomScanSharedMemory<TShared>

The shared memory, valid until the scan ends.

Initializes the shared memory in the leader before workers start, and again before a rescan starts new ones.

public static abstract void InitializeShared(TState state, ref TShared memory)

Parameters:

state — TState

The leader’s state.

memory — TShared

The shared memory, zeroed each time.