Table of Contents

Struct VariantMetadata

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

Zero-copy reader for variant metadata: a header byte followed by a string dictionary used to look up field names in variant objects.

public ref struct VariantMetadata
Inherited Members

Remarks

Binary layout:

[header: 1 byte]
[dictionary_size: offset_size bytes]
[offsets: (dictionary_size + 1) * offset_size bytes]
[string bytes: concatenated UTF-8]

Constructors

VariantMetadata(ReadOnlySpan<byte>)

Parses variant metadata from a raw byte span.

public VariantMetadata(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

The complete metadata buffer.

Properties

DictionarySize

Gets the number of strings in the metadata dictionary.

public int DictionarySize { get; }

Property Value

int

IsSorted

Gets a value indicating whether the dictionary strings are sorted in lexicographic (UTF-8 byte) order, enabling binary search.

public bool IsSorted { get; }

Property Value

bool

Methods

FindString(ReadOnlySpan<byte>)

Finds the dictionary index of the given UTF-8 string. Returns -1 if not found.

public int FindString(ReadOnlySpan<byte> utf8)

Parameters

utf8 ReadOnlySpan<byte>

Returns

int

Remarks

Uses binary search if the dictionary is marked as sorted; otherwise falls back to linear scan.

GetString(int)

Gets the string at the given dictionary index, decoded from UTF-8.

public string GetString(int index)

Parameters

index int

Returns

string

GetStringBytes(int)

Gets the raw UTF-8 bytes of the string at the given dictionary index.

public ReadOnlySpan<byte> GetStringBytes(int index)

Parameters

index int

Returns

ReadOnlySpan<byte>