Class VariantArrayShreddingExtensions
Shredding-aware extensions on VariantArray. Provides both transparent materialization (GetLogicalVariantValue(VariantArray, int)) and a reader-style API (GetShreddedVariant(VariantArray, int)) that exposes typed columns and residual bytes side-by-side.
public static class VariantArrayShreddingExtensions
- Inheritance
-
VariantArrayShreddingExtensions
- Inherited Members
Methods
GetLogicalVariantValue(VariantArray, int)
Materializes the element at index into a logical
VariantValue, transparently merging shredded columns and
residual bytes. Works for both shredded and unshredded columns.
public static VariantValue GetLogicalVariantValue(this VariantArray array, int index)
Parameters
arrayVariantArrayindexint
Returns
GetShredSchema(VariantArray)
Gets the ShredSchema for a variant array, derived from its Arrow storage type. Returns Unshredded() for unshredded columns.
public static ShredSchema GetShredSchema(this VariantArray array)
Parameters
arrayVariantArray
Returns
GetShreddedVariant(VariantArray, int)
Gets a ShreddedVariant reader for the element at the given index. Exposes typed-column access and residual bytes without materializing the full logical variant. Works for both shredded and unshredded columns.
public static ShreddedVariant GetShreddedVariant(this VariantArray array, int index)
Parameters
arrayVariantArrayindexint
Returns
Exceptions
- InvalidOperationException
If the element is null.
InferShredSchema(VariantArray, ShredOptions)
Infers a ShredSchema from the logical values of a variant array. Null elements are ignored. Works for both shredded and unshredded columns.
public static ShredSchema InferShredSchema(this VariantArray array, ShredOptions options = null)
Parameters
arrayVariantArrayoptionsShredOptions
Returns
Remarks
When writing a column in batches (e.g. Parquet row groups), infer once over a representative batch and pass the result to Shred(VariantArray, ShredSchema, MemoryAllocator) for every batch, so that all batches share one layout.
Reassemble(VariantArray, MemoryAllocator)
Converts a shredded variant array into its unshredded equivalent, in which every element is stored as self-contained metadata and value bytes. Null elements remain null. An unshredded input is returned unchanged.
public static VariantArray Reassemble(this VariantArray array, MemoryAllocator allocator = null)
Parameters
arrayVariantArrayThe variant array to reassemble.
allocatorMemoryAllocatorArrow memory allocator, or default if null.
Returns
Shred(VariantArray, ShredSchema, MemoryAllocator)
Shreds a variant array into the layout described by schema.
The input may itself be shredded (under any schema); its logical values are
re-shredded. Null elements remain null.
public static VariantArray Shred(this VariantArray array, ShredSchema schema, MemoryAllocator allocator = null)
Parameters
arrayVariantArrayThe variant array to shred.
schemaShredSchemaThe target shredding schema.
allocatorMemoryAllocatorArrow memory allocator, or default if null.
Returns
TryShred(VariantArray, ShredOptions, out VariantArray, MemoryAllocator)
Infers a shredding schema from array and, if it produces a
shredded layout, shreds the array into it.
public static bool TryShred(this VariantArray array, ShredOptions options, out VariantArray shredded, MemoryAllocator allocator = null)
Parameters
arrayVariantArrayThe variant array to shred.
optionsShredOptionsInference options, or Default if null.
shreddedVariantArrayThe shredded array, or null when this method returns false.
allocatorMemoryAllocatorArrow memory allocator, or default if null.
Returns
- bool
True if a shredded layout was inferred; false if the values have no layout worth shredding (the inferred schema is Unshredded()).