Skip to content

PgFlatArray<T>

Namespace: Ankus

Assembly: Ankus.Runtime.dll

A flat PostgreSQL array of fixed-size scalars allocated in a memory context and filled in place, as pgrx’s FlatArray is.

public sealed class PgFlatArray<T> where T : unmanaged

Type parameters:

T

The element: sbyte (“char”), short, int, long, uint (oid), float, double or bool.

The storage uses PostgreSQL’s native array layout without a NULL bitmap, so every element is present and starts at zero. It lives until its memory context resets or is deleted. Build arrays with SQL NULL elements with PgArray<T>: PostgreSQL does not store NULL elements, so their positions cannot be filled in place. Return the array from a function through PgArrayView<T> over Datum.

Inheritance: object

Gets the number of elements.

public int Count { get; }

Value: int

Gets the array datum, whose lifetime is the owning memory context.

public PgDatum Datum { get; }

Value: PgDatum

Gets the length of each dimension.

public ReadOnlySpan<int> Lengths { get; }

Value: ReadOnlySpan<int>

Gets the lower bound of each dimension.

public ReadOnlySpan<int> LowerBounds { get; }

Value: ReadOnlySpan<int>

Gets the number of dimensions; an empty array has none.

public int Rank { get; }

Value: int

Borrows the elements in row-major order for reading and writing.

public Span<T> DangerousGetSpan()

Returns: Span<T>

The native element storage.

Ownership is checked when acquiring the span. Stop using it before the memory context resets or is deleted, the callback ends or the thread changes.