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

Gzip bytes-to-bytes codec. Wraps System.IO.Compression — no native dependencies. Configuration mirrors the zarr.json "gzip" codec configuration object. More...

Inheritance diagram for ZarrNET.GzipCodec:
ZarrNET.IZarrCodec

Public Member Functions

 GzipCodec (int level=6)
 
async Task< byte[]> DecodeAsync (byte[] input, CancellationToken ct=default)
 Decodes bytes produced by the previous codec step.
 
async Task< byte[]> EncodeAsync (byte[] input, CancellationToken ct=default)
 Encodes bytes for the next codec step.
 
- Public Member Functions inherited from ZarrNET.IZarrCodec

Properties

string Name [get]
 Codec name as it appears in zarr.json (e.g. "gzip", "zstd", "bytes").
 
- Properties inherited from ZarrNET.IZarrCodec

Detailed Description

Gzip bytes-to-bytes codec. Wraps System.IO.Compression — no native dependencies. Configuration mirrors the zarr.json "gzip" codec configuration object.

Constructor & Destructor Documentation

◆ GzipCodec()

ZarrNET.GzipCodec.GzipCodec ( int level = 6)
16 {
17 _compressionLevel = level switch
18 {
19 0 => CompressionLevel.NoCompression,
20 1 => CompressionLevel.Fastest,
21 >= 7 => CompressionLevel.SmallestSize,
22 _ => CompressionLevel.Optimal
23 };
24 }

Member Function Documentation

◆ DecodeAsync()

async Task< byte[]> ZarrNET.GzipCodec.DecodeAsync ( byte[] input,
CancellationToken ct = default )

Decodes bytes produced by the previous codec step.

Implements ZarrNET.IZarrCodec.

31 {
32 await using var inputStream = new MemoryStream(input);
33 await using var gzipStream = new GZipStream(inputStream, CompressionMode.Decompress);
34 await using var outputStream = new MemoryStream();
35
36 await gzipStream.CopyToAsync(outputStream, ct).ConfigureAwait(false);
37
38 return outputStream.ToArray();
39 }

◆ EncodeAsync()

async Task< byte[]> ZarrNET.GzipCodec.EncodeAsync ( byte[] input,
CancellationToken ct = default )

Encodes bytes for the next codec step.

Implements ZarrNET.IZarrCodec.

42 {
43 await using var outputStream = new MemoryStream();
44
45 await using (var gzipStream = new GZipStream(outputStream, _compressionLevel, leaveOpen: true))
46 {
47 await gzipStream.WriteAsync(input, ct).ConfigureAwait(false);
48 }
49
50 return outputStream.ToArray();
51 }

Property Documentation

◆ Name

string ZarrNET.GzipCodec.Name
get

Codec name as it appears in zarr.json (e.g. "gzip", "zstd", "bytes").

Implements ZarrNET.IZarrCodec.


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