Table of Contents

Method From

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

From(ReadOnlySpan<T>)

Makes a finished buffer from rows you already have, as if a read had produced them.

public static PooledBuffer<T> From(ReadOnlySpan<T> rows)

Parameters

rows ReadOnlySpan<T>

The rows. They are copied: the buffer does not keep this span.

Returns

PooledBuffer<T>

The finished buffer.

Remarks

For code that needs a buffer without a database. One array is rented from Shared and the rows are copied into it. Nothing runs in the background and Items is complete at once. Disposing the buffer returns the array to the pool. Rows that are references are cleared when it goes back, as for a read. No rows give Empty and rent nothing.

Exceptions

ArgumentOutOfRangeException

There are more than 2^30 rows.

From(ReadOnlySpan<T>, ArrayPool<T>, bool)

Makes a finished buffer from rows you already have, with an array from a pool you choose.

public static PooledBuffer<T> From(ReadOnlySpan<T> rows, ArrayPool<T> pool, bool clearOnReturn)

Parameters

rows ReadOnlySpan<T>

The rows. They are copied: the buffer does not keep this span.

pool ArrayPool<T>

The pool the array comes from and goes back to.

clearOnReturn bool

Whether the rows are cleared when the array goes back.

Returns

PooledBuffer<T>

The finished buffer.

Remarks

The same as From(ReadOnlySpan<T>), except that the one array is rented from pool and goes back to it when the buffer is disposed. Rows that are references are always cleared when it goes back; other rows are cleared when clearOnReturn is true.

Exceptions

ArgumentNullException

pool is null.

ArgumentOutOfRangeException

There are more than 2^30 rows.