Table of Contents

Struct VariantReader

Namespace
Apache.Arrow.Scalars.Variant
Assembly
Apache.Arrow.Scalars.dll

Zero-copy reader for a single variant value. Provides type inspection and typed accessors for primitives, short strings, objects, and arrays.

public ref struct VariantReader
Inherited Members

Constructors

VariantReader(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Creates a reader over a variant value.

public VariantReader(ReadOnlySpan<byte> metadata, ReadOnlySpan<byte> value)

Parameters

metadata ReadOnlySpan<byte>

The variant metadata buffer (shared across all values in a column).

value ReadOnlySpan<byte>

The variant value buffer for this specific value.

Properties

BasicType

Gets the basic type of this value.

public VariantBasicType BasicType { get; }

Property Value

VariantBasicType

Header

Gets the header byte of this value.

public byte Header { get; }

Property Value

byte

IsArray

Returns true if this value is an array.

public bool IsArray { get; }

Property Value

bool

IsBoolean

Returns true if this value is a boolean (true or false).

public bool IsBoolean { get; }

Property Value

bool

IsNull

Returns true if this value is null.

public bool IsNull { get; }

Property Value

bool

IsNumeric

Returns true if this value is a numeric type (any integer, float, double, or decimal).

public bool IsNumeric { get; }

Property Value

bool

IsObject

Returns true if this value is an object.

public bool IsObject { get; }

Property Value

bool

IsString

Returns true if this value is a string (either short string or long string primitive).

public bool IsString { get; }

Property Value

bool

Metadata

Gets the full metadata span.

public ReadOnlySpan<byte> Metadata { get; }

Property Value

ReadOnlySpan<byte>

PrimitiveType

Gets the primitive type when BasicType is Primitive.

public VariantPrimitiveType? PrimitiveType { get; }

Property Value

VariantPrimitiveType?

Value

Gets the full value span.

public ReadOnlySpan<byte> Value { get; }

Property Value

ReadOnlySpan<byte>

Methods

GetBinary()

Gets the binary value as a byte span.

public ReadOnlySpan<byte> GetBinary()

Returns

ReadOnlySpan<byte>

GetBoolean()

Gets the boolean value.

public bool GetBoolean()

Returns

bool

GetDate()

Gets the date as a DateTime.

public DateTime GetDate()

Returns

DateTime

GetDateDays()

Gets the date as days since Unix epoch (1970-01-01).

public int GetDateDays()

Returns

int

GetDecimal16()

Attempts to get a Decimal16 value as a decimal. This may throw OverflowException if the value exceeds 96 bits.

public decimal GetDecimal16()

Returns

decimal

GetDecimal16Raw(out byte)

Gets the raw scale and 16-byte unscaled value for a Decimal16. The 16-byte integer may exceed decimal range.

public ReadOnlySpan<byte> GetDecimal16Raw(out byte scale)

Parameters

scale byte

The scale (number of decimal digits after the point).

Returns

ReadOnlySpan<byte>

The 16-byte unscaled value in little-endian byte order.

GetDecimal4()

Gets a Decimal4 value (1-byte scale + 4-byte unscaled integer).

public decimal GetDecimal4()

Returns

decimal

GetDecimal8()

Gets a Decimal8 value (1-byte scale + 8-byte unscaled integer).

public decimal GetDecimal8()

Returns

decimal

GetDouble()

Gets a double value.

public double GetDouble()

Returns

double

GetFloat()

Gets a float (Float) value.

public float GetFloat()

Returns

float

GetInt16()

Gets an Int16 value.

public short GetInt16()

Returns

short

GetInt32()

Gets an Int32 value.

public int GetInt32()

Returns

int

GetInt64()

Gets an Int64 value.

public long GetInt64()

Returns

long

GetInt8()

Gets an Int8 value.

public sbyte GetInt8()

Returns

sbyte

GetSqlDecimal()

Gets a decimal value as a SqlDecimal. Works for Decimal4, Decimal8, and Decimal16 types. Unlike GetDecimal16(), this method does not throw OverflowException for values exceeding 96 bits.

public SqlDecimal GetSqlDecimal()

Returns

SqlDecimal

GetString()

Gets the string value decoded from UTF-8. Works for both short strings and long string primitives (type 16).

public string GetString()

Returns

string

GetStringBytes()

Gets the raw UTF-8 bytes of the string value. Works for both short strings and long string primitives (type 16).

public ReadOnlySpan<byte> GetStringBytes()

Returns

ReadOnlySpan<byte>

GetTimeNtzMicros()

Gets a TimeNTZ value as microseconds since midnight.

public long GetTimeNtzMicros()

Returns

long

GetTimestamp()

Gets a Timestamp as a DateTimeOffset (UTC).

public DateTimeOffset GetTimestamp()

Returns

DateTimeOffset

GetTimestampMicros()

Gets a Timestamp value as microseconds since Unix epoch (UTC).

public long GetTimestampMicros()

Returns

long

GetTimestampNtz()

Gets a TimestampNTZ as a DateTime (Unspecified kind).

public DateTime GetTimestampNtz()

Returns

DateTime

GetTimestampNtzMicros()

Gets a TimestampNTZ value as microseconds since epoch (no timezone).

public long GetTimestampNtzMicros()

Returns

long

GetTimestampNtzNanos()

Gets a TimestampNtzNanos value as nanoseconds since epoch (no timezone).

public long GetTimestampNtzNanos()

Returns

long

GetTimestampTzNanos()

Gets a TimestampTzNanos value as nanoseconds since Unix epoch (UTC).

public long GetTimestampTzNanos()

Returns

long

GetUuid()

Gets the UUID value. The variant encoding stores UUIDs as 16 bytes in big-endian (RFC 4122) byte order.

public Guid GetUuid()

Returns

Guid

GetUuidBytes()

Gets the raw 16 UUID bytes in big-endian (RFC 4122) order.

public ReadOnlySpan<byte> GetUuidBytes()

Returns

ReadOnlySpan<byte>

ToVariantValue()

Materializes this variant value into a VariantValue object. Recursively materializes objects and arrays.

public VariantValue ToVariantValue()

Returns

VariantValue

TryGetDecimal16(out decimal)

Attempts to get a Decimal16 value as a decimal. Returns false if the value exceeds 96 bits instead of throwing.

public bool TryGetDecimal16(out decimal value)

Parameters

value decimal

Returns

bool