Mallard
Search Results for

    Show / Hide Table of Contents

    Interface IDuckDbVector<T>

    Methods to retrieve items from DuckDB vectors.

    Inherited Members
    IDuckDbVector.IsItemValid(int)
    IDuckDbVector.ValidityMask
    IDuckDbVector.Length
    IDuckDbVector.ColumnInfo
    Namespace: Mallard
    Assembly: Mallard.dll
    Syntax
    public interface IDuckDbVector<T> : IDuckDbVector where T : allows ref struct
    Type Parameters
    Name Description
    T
    Remarks

    This interface differs from IReadOnlyList<T> in two ways: firstly, there is dedicated handling of null values; and secondly, DuckDB vector readers are "ref structs" so they cannot implement enumerators without copying and converting element values to GC memory, which is obviously inefficient.

    Methods

    | Edit this page View Source

    GetItem(int)

    Retrieve a valid element of this vector.

    Declaration
    T GetItem(int index)
    Parameters
    Type Name Description
    int index

    The index of the element to select.

    Returns
    Type Description
    T

    The desired element of this vector.

    Remarks

    For the purposes of this method, an element that is missing in the DuckDB vector but is materialized as an instance of Nullable<T> is considered "valid", i.e. this method will not throw an exception.

    (Otherwise, there would be no point in substituting a nullable value type for T. Consistency would argue that nullable reference types be treated the same way, but in .NET, reference nullability are only compiler-driven annotations and not part of the run-time type system, so an implementation of this interface generally cannot detect whether T is U or U? for reference types U. So, if T is a reference type, this method throws an exception if the source element in the DuckDB vector is missing.)

    Clients that want to basically assume all the elements of the vector are valid would call this method.

    Exceptions
    Type Condition
    IndexOutOfRangeException

    The index is out of range for the vector.

    InvalidOperationException

    The requested element is invalid.

    | Edit this page View Source

    GetItemOrDefault(int)

    Retrieve an element of this vector, returning the default value if it is invalid.

    Declaration
    T? GetItemOrDefault(int index)
    Parameters
    Type Name Description
    int index

    The index of the element to select.

    Returns
    Type Description
    T

    The desired element of this vector.

    Remarks

    The "default" value refers to the default-initialized value of a variable of tyoe T.

    Exceptions
    Type Condition
    IndexOutOfRangeException

    The index is out of range for the vector.

    | Edit this page View Source

    TryGetItem(int, out T)

    Retrieve an element of this vector, or report that it is invalid.

    Declaration
    bool TryGetItem(int index, out T item)
    Parameters
    Type Name Description
    int index

    The index of the element in this vector.

    T item

    The item that is to be read out. Set to the element type's default value when the element is invalid.

    Returns
    Type Description
    bool

    Whether the element is valid.

    Exceptions
    Type Condition
    IndexOutOfRangeException

    The index is out of range for the vector.

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