Table of Contents

Struct VariantObjectReader

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

Zero-copy reader for a variant object value. Provides access to field names (via the metadata dictionary) and field values.

public ref struct VariantObjectReader
Inherited Members

Remarks

Binary layout (after the header byte):

[num_fields: 1 or 4 bytes depending on is_large]
[field_ids: num_fields * field_id_size bytes]
[offsets: (num_fields + 1) * offset_size bytes]
[field values: concatenated variant values]

Field IDs index into the metadata string dictionary. Field IDs must be sorted by the lexicographic order of their corresponding field names in the metadata dictionary.

Constructors

VariantObjectReader(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Creates an object reader from the metadata and the object value buffer.

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

Parameters

metadata ReadOnlySpan<byte>
value ReadOnlySpan<byte>

Properties

FieldCount

Gets the number of fields in this object.

public int FieldCount { get; }

Property Value

int

Methods

GetFieldId(int)

Gets the metadata dictionary field ID for the field at the given index.

public int GetFieldId(int index)

Parameters

index int

Returns

int

GetFieldName(int)

Gets the field name for the field at the given index by looking up the field ID in the metadata dictionary.

public string GetFieldName(int index)

Parameters

index int

Returns

string

GetFieldNameBytes(int)

Gets the raw UTF-8 bytes of the field name at the given index.

public ReadOnlySpan<byte> GetFieldNameBytes(int index)

Parameters

index int

Returns

ReadOnlySpan<byte>

GetFieldValue(int)

Gets a VariantReader for the field value at the given index.

public VariantReader GetFieldValue(int index)

Parameters

index int

Returns

VariantReader

TryGetField(scoped ReadOnlySpan<byte>, out VariantReader)

Tries to find a field by name and returns a reader for its value.

public bool TryGetField(scoped ReadOnlySpan<byte> name, out VariantReader value)

Parameters

name ReadOnlySpan<byte>

The UTF-8 bytes of the field name to look for.

value VariantReader

The reader for the field value, if found.

Returns

bool

True if the field was found; false otherwise.

TryGetField(string, out VariantReader)

Tries to find a field by name (string) and returns a reader for its value.

public bool TryGetField(string name, out VariantReader value)

Parameters

name string
value VariantReader

Returns

bool