Zarr.NET  0.6.1
Zarr reader and writer in .NET
Loading...
Searching...
No Matches
ZarrNET.ZarrArrayMetadata Class Referencesealed

Typed metadata for a Zarr array node. Knows everything needed to read/write chunks — shape, data type, chunk layout, codec pipeline configuration. No OME-Zarr knowledge here. More...

Static Public Member Functions

static ZarrArrayMetadata FromDocument (ZarrJsonDocument doc)
 
static ZarrArrayMetadata FromV2Document (ZarrV2ArrayDocument arrayDoc, JsonElement? attributes, string? separatorOverride=null)
 Creates array metadata from a Zarr v2 .zarray document.
 

Properties

long[] Shape [get]
 
int[] ChunkShape [get]
 
ZarrDataType DataType [get]
 
string ChunkKeySeparator [get]
 
CodecInfo[] Codecs [get]
 
string?[] DimensionNames [get]
 
JsonElement? RawAttributes [get]
 
int ZarrVersion [get]
 
ShardingConfigSharding [get, set]
 Non-null when the codec pipeline contains a sharding_indexed codec. In this case, the outer ChunkShape represents the shard shape and actual data chunks are the inner chunks within each shard.
 
int Rank [get]
 

Detailed Description

Typed metadata for a Zarr array node. Knows everything needed to read/write chunks — shape, data type, chunk layout, codec pipeline configuration. No OME-Zarr knowledge here.

Member Function Documentation

◆ FromDocument()

static ZarrArrayMetadata ZarrNET.ZarrArrayMetadata.FromDocument ( ZarrJsonDocument doc)
static
57 {
58 if (doc.NodeType != "array")
59 throw new InvalidOperationException(
60 $"Expected node_type 'array', got '{doc.NodeType}'.");
61
62 if (doc.Shape is null)
63 throw new InvalidOperationException("Array zarr.json is missing 'shape'.");
64
65 if (doc.DataType is null)
66 throw new InvalidOperationException("Array zarr.json is missing 'data_type'.");
67
68 var shape = doc.Shape;
69 var dataType = ZarrDataType.Parse(doc.DataType);
70 var chunkShape = ResolveChunkShape(doc);
71 var separator = doc.ChunkKeyEncoding?.Configuration?.Separator ?? "/";
72 var codecs = ResolveCodecs(doc);
73
74 return new ZarrArrayMetadata(
75 shape,
76 chunkShape,
77 dataType,
78 separator,
79 codecs,
80 doc.DimensionNames,
81 doc.Attributes,
82 zarrVersion: 3);
83 }
Typed metadata for a Zarr array node. Knows everything needed to read/write chunks — shape,...
Definition ZarrNodeMetadata.cs:13
Typed representation of a Zarr v3 data type string (e.g. "uint8", "float32"). Resolves element size i...
Definition ZarrDataType.cs:9
long?[] Shape
Present on array nodes. Null on group nodes.
Definition ZarrJsonDocument.cs:23
JsonElement? Attributes
Freeform attributes — this is where OME-Zarr metadata lives. Kept as a raw JsonElement so the OME lay...
Definition ZarrJsonDocument.cs:48

◆ FromV2Document()

static ZarrArrayMetadata ZarrNET.ZarrArrayMetadata.FromV2Document ( ZarrV2ArrayDocument arrayDoc,
JsonElement? attributes,
string? separatorOverride = null )
static

Creates array metadata from a Zarr v2 .zarray document.

Parameters
arrayDocParsed .zarray contents.
attributesParsed .zattrs contents (optional).
separatorOverrideIf provided, overrides the dimension separator regardless of what .zarray declares. Used by the chunk-key probing logic when .zarray omits dimension_separator and the store is found to use "/" (nested) chunk keys.
103 {
104 if (arrayDoc.ZarrFormat != 2)
105 throw new InvalidOperationException(
106 $"Expected zarr_format 2, got {arrayDoc.ZarrFormat}.");
107
108 var (dataType, byteOrder) = NumpyDtypeParser.Parse(arrayDoc.Dtype);
109
110 var separator = separatorOverride
111 ?? arrayDoc.DimensionSeparator
112 ?? ".";
113
114 var codecs = CodecFactory.BuildV2CodecPipeline(arrayDoc.Compressor, byteOrder);
115
116 return new ZarrArrayMetadata(
117 arrayDoc.Shape,
118 arrayDoc.Chunks,
119 dataType,
120 separator,
121 codecs,
122 dimensionNames: null, // v2 doesn't have dimension_names
123 attributes,
124 zarrVersion: 2);
125 }
string Dtype
Numpy-style dtype string, e.g. "<u2" (little-endian uint16), ">f4" (big-endian float32).
Definition ZarrV2Document.cs:29
ZarrV2CompressorDocument? Compressor
Compressor configuration. Null means no compression. Example: { "id": "gzip", "level": 5 }...
Definition ZarrV2Document.cs:36

Property Documentation

◆ ChunkKeySeparator

string ZarrNET.ZarrArrayMetadata.ChunkKeySeparator
get
17{ get; }

◆ ChunkShape

int [] ZarrNET.ZarrArrayMetadata.ChunkShape
get
15{ get; }

◆ Codecs

CodecInfo [] ZarrNET.ZarrArrayMetadata.Codecs
get
18{ get; }

◆ DataType

ZarrDataType ZarrNET.ZarrArrayMetadata.DataType
get
16{ get; }

◆ DimensionNames

string? [] ZarrNET.ZarrArrayMetadata.DimensionNames
get
19{ get; }

◆ RawAttributes

JsonElement? ZarrNET.ZarrArrayMetadata.RawAttributes
get
20{ get; }

◆ Shape

long [] ZarrNET.ZarrArrayMetadata.Shape
get
14{ get; }

◆ Sharding

ShardingConfig? ZarrNET.ZarrArrayMetadata.Sharding
getset

Non-null when the codec pipeline contains a sharding_indexed codec. In this case, the outer ChunkShape represents the shard shape and actual data chunks are the inner chunks within each shard.

28{ get; internal set; }

◆ ZarrVersion

int ZarrNET.ZarrArrayMetadata.ZarrVersion
get
21{ get; } // 2 or 3 — drives chunk key format

The documentation for this class was generated from the following file: