Mallard
Search Results for

    Show / Hide Table of Contents

    Struct DuckDbString

    Represents a string in DuckDB, as an element in some vector.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Mallard.Types
    Assembly: Mallard.dll
    Syntax
    public readonly ref struct DuckDbString
    Remarks

    This type is only used for reading elements from a DuckDB vector. (In DuckDB's C API, it corresponds to duckdb_string_t.) It is a "ref struct" as it may internally point to natively-allocated memory, which must be scoped to the lifetime of the vector (DuckDbVectorReader<T>).

    Semantically, this structure is nothing more than ReadOnlySpan<byte> on the UTF-8 data which can be accessed through the property Utf8.

    This type is not used for sending values from .NET to DuckDB, since DuckDB needs to allocate and manage the memory blocks used to hold variable-length data, and such operations cannot be surfaced safely using .NET structures alone.

    Properties

    | Edit this page View Source

    Utf8

    The UTF-8 bytes of the string.

    Declaration
    public ReadOnlySpan<byte> Utf8 { get; }
    Property Value
    Type Description
    ReadOnlySpan<byte>
    Remarks

    There is an inlined buffer within DuckDbString for short strings which the returned span may point to. So this instance must outlive the span, enforced by this property being marked to be an "unscoped reference".

    Methods

    | Edit this page View Source

    ToString()

    Convert the UTF-8 string from DuckDB into a .NET string (in UTF-16).

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The string in UTF-16 encoding.

    Overrides
    ValueType.ToString()
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX