Mallard
Search Results for

    Show / Hide Table of Contents

    Class DuckDbVectorDelegateReader

    Provides access to a column of DuckDbResultChunk.

    Inheritance
    object
    DuckDbVectorDelegateReader
    Implements
    IDuckDbVector
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Mallard
    Assembly: Mallard.dll
    Syntax
    public class DuckDbVectorDelegateReader : IDuckDbVector
    Remarks

    This type essentially provides the functionality of DuckDbVectorReader<T>, but without incorporating the vector element type as a generic parameter, and without the restrictions of "ref structs". It is necessary to fit some API shapes, in particular ADO.NET. Naturally, it has worse performance characteristics (in order to maintain the same level of memory safety), so DuckDbVectorReader<T> remains the preferred approach to reading DuckDB vectors.

    The word "delegate" in the name of this type refers to its instances being like delegates (in the .NET sense of the term) to the chunk's column/vector.

    Because the .NET type for the vector elements does not get specified (at construction), instances of this class assume the default type (mapping) as decided by this library.

    Constructors

    | Edit this page View Source

    DuckDbVectorDelegateReader(DuckDbResultChunk, int)

    Obtains read access to a column (vector) in a result chunk coming from DuckDB.

    Declaration
    public DuckDbVectorDelegateReader(DuckDbResultChunk chunk, int columnIndex)
    Parameters
    Type Name Description
    DuckDbResultChunk chunk

    The target chunk. To enforce memory safety (in the presence of potentially multi-threaded access), the chunk can no longer be explicitly disposed once any reference to a column is taken using this class. Subsequent calls to Dispose() will be silently ignored.

    int columnIndex

    The index of the desired column. Must be between 0 (inclusive) and ColumnCount (exclusive).

    Properties

    | Edit this page View Source

    ColumnInfo

    Information about the column that this vector is part of.

    Declaration
    public DuckDbColumnInfo ColumnInfo { get; }
    Property Value
    Type Description
    DuckDbColumnInfo
    | Edit this page View Source

    ElementType

    The .NET type that the elements in the DuckDB column are mapped to.

    Declaration
    public Type ElementType { get; }
    Property Value
    Type Description
    Type
    | Edit this page View Source

    Length

    The length (number of rows) inherited from the result chunk this vector is part of.

    Declaration
    public int Length { get; }
    Property Value
    Type Description
    int

    Methods

    | Edit this page View Source

    GetByteLength(int)

    Get the length in bytes of a blob, string or bit string.

    Declaration
    public int GetByteLength(int rowIndex)
    Parameters
    Type Name Description
    int rowIndex

    The (row) index of the element that is a blob, string or bit string.

    Returns
    Type Description
    int
    | Edit this page View Source

    GetByteStream(int)

    Get a read-only stream over the bytes of a blob, string, or bit string.

    Declaration
    public Stream GetByteStream(int rowIndex)
    Parameters
    Type Name Description
    int rowIndex

    The (row) index of the element that is a blob, string or bit string.

    Returns
    Type Description
    Stream
    | Edit this page View Source

    GetBytes(int, Span<byte>, out int, int)

    Copy out a sub-span of bytes from a blob, string, or bit string.

    Declaration
    public int GetBytes(int rowIndex, Span<byte> destination, out int totalBytes, int offset = 0)
    Parameters
    Type Name Description
    int rowIndex

    The (row) index of the element that is a blob, string or bit string.

    Span<byte> destination

    Buffer where the bytes will be copied to.

    int totalBytes

    The number of bytes that would be copied (given the same offset) if destination is big enough.

    int offset

    The offset, measured in byte units from the beginning of the blob, string or bit string, to start copying from.

    Returns
    Type Description
    int

    The number of bytes written to the beginning of destination.

    Remarks

    For a vector element that is a string, its byte content is the UTF-8 encoding of the string.

    For a vector element that is a bit string, the byte content is the little-endian encoding as accepted by BitArray. (See also GetSegment(Span<byte>, int, int).

    This method is primarily intended for implementing GetBytes(int, long, byte[], int, int).

    Exceptions
    Type Condition
    InvalidOperationException

    The element type of this DuckDB vector is not a blob, string or bit string.

    | Edit this page View Source

    GetChars(int, Span<char>, int)

    Copy out a sub-span of UTF-16 code units from a string.

    Declaration
    public int GetChars(int rowIndex, Span<char> destination, int charOffset = 0)
    Parameters
    Type Name Description
    int rowIndex

    The (row) index of the element that is a blob, string or bit string.

    Span<char> destination

    Buffer where the bytes will be copied to.

    int charOffset

    The offset, measured in UTF-16 code units from the beginning of the string to start copying from.

    Returns
    Type Description
    int

    The number of UTF-16 code units written to the beginning of destination.

    Remarks

    This method is primarily intended for implementing GetChars(int, long, char[], int, int).

    Exceptions
    Type Condition
    InvalidOperationException

    The element type of this DuckDB vector is not a string.

    | Edit this page View Source

    GetObject(int)

    Get an item in the vector, cast into object.

    Declaration
    public object GetObject(int rowIndex)
    Parameters
    Type Name Description
    int rowIndex

    The (row) index of the element of the vector.

    Returns
    Type Description
    object
    | Edit this page View Source

    GetObjectOrNull(int)

    Get an item in the vector, cast into object, or null if the selected item is invalid.

    Declaration
    public object? GetObjectOrNull(int rowIndex)
    Parameters
    Type Name Description
    int rowIndex

    The (row) index of the element of the vector.

    Returns
    Type Description
    object
    | Edit this page View Source

    GetValue<T>(int)

    Get an item in the vector in its default .NET type (without boxing it).

    Declaration
    public T GetValue<T>(int rowIndex)
    Parameters
    Type Name Description
    int rowIndex
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    The .NET type of the column, required to be specified since it has been "type-erased" from the type identity of this class. However, it must still match, at run-time, the actual type that the elements in the DuckDB column have been mapped to by default, as indicated by ElementType. (For reference types, a base class or interface can also match.)

    This type should not be a nullable value type; it would never match ElementType. There is no "notnull" constraint on T only because some APIs that would be implemented with this class do not have that shape.

    | Edit this page View Source

    IsItemValid(int)

    Return whether an element of this vector is valid (not null).

    Declaration
    public bool IsItemValid(int index)
    Parameters
    Type Name Description
    int index

    The index of the element of the vector.

    Returns
    Type Description
    bool

    True if valid (non-null), false if invalid (null).

    Exceptions
    Type Condition
    IndexOutOfRangeException

    The index is out of range for the vector.

    Implements

    IDuckDbVector
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX