IronCompress 1.6.1
See the version list below for details.
dotnet add package IronCompress --version 1.6.1
NuGet\Install-Package IronCompress -Version 1.6.1
<PackageReference Include="IronCompress" Version="1.6.1" />
paket add IronCompress --version 1.6.1
#r "nuget: IronCompress, 1.6.1"
// Install IronCompress as a Cake Addin #addin nuget:?package=IronCompress&version=1.6.1 // Install IronCompress as a Cake Tool #tool nuget:?package=IronCompress&version=1.6.1
IronCompress
<img src="icon.png" width=80 height=80 align="left"/> C++ compression methods joined together in one native library, cross-compiled for multiple architectures and exposed as a .NET library. .NET has built-in support for Gzip and Brotli (which is what this library is using) but other compression methods are either available only as native libraries hard (impossible for some) to consume, or ill-ported C# alternatives. In fact, I myself wrote one of them. Using native, original implementations is the way to go if you want to keep performance, security, and features up to date.
The library supports the following formats:
- Google Snappy [source].
- Facebook's Zstandard (zstd) [source].
- Gzip [source].
- Google Brotli [source] (.net standard 2.0 build uses native version instead).
- LZO [source].
- LZ4 [source].
And following architectures:
Format | Managed | Windows | Linux | Mac OSX | βοΈ OS<br />Arch π½ | |
---|---|---|---|---|---|---|
Snappy | β <br /><sup>via Snappier </sup> | β | β | β | x32 | |
β | β | β | x64 | |||
β | β | β | ARM64 | |||
Zstd | β <br /><sup>via ZstdSharp</sup> | β | β | β | x32 | |
β | β | β | x64 | |||
β | β | β | ARM64 | |||
Gzip | β <br /><sup>part of .NET</sup> | β | β | β | x32 | |
β | β | β | x64 | |||
β | β | β | ARM64 | |||
Brotli | β <br /><sup>except on .NET Standard 2.0</sup> | β | β | β | x32 | |
β | β | β | x64 | |||
β | β | β | ARM64 | |||
LZO | β | β | β | β | x32 | |
β | β | β | x64 | |||
β | β | β | ARM64 | |||
LZ4 | β | β | β | β | x32 | |
β | β | β | x64 | |||
β | β | β | ARM64 |
I periodically update to the latest binaries. All the binaries are compiled from C/C++ source with CMake
for major systems i.e. Linux, Windows and Mac OSX. They are then wrapped safely with a .NET interface.
Logic
Although managed versions are available, they will be only used as a fallback when native library is not available, because native libraries are faster and more up to date with latest advancements.
You can check which version was used by reading IronCompressResult.NativeUsed
flag.
Using
This library only compresses buffers. It may work with streams in the future, but I am currently only interested in buffers. Essentially, you pass ReadOnlySpan<byte>
as an input, and receive Span<T>
as an output in the most efficient way.
Here is an example of how to compress buffer with snappy codec:
using IronCompress; // root namespace
// Construct library entry point and optionally pass an implementation of ArrayPool.
// I will pass default shared pool here.
var iron = new Iron();
byte[] input = ...;
using(IronCompressResult compressed = iron.Compress(Codec.Snappy, input.AsSpan())) {
// ... use data
}
Compress
and Decompress
methods actually return a Result
class which wraps byte array of compression or decompression operation. You can access the underlying result by calling to .AsSpan()
method inside the result. On dispose, Result
makes sure the underlying memory is freed up - if pooling was used, it will be returned back to the pool.
To decompress:
using (IronCompressResult uncompressed = iron.Decompress(Codec.Snappy, compressed, input.Length)) {
// ... use data
}
As with compression, this returns Result
with decompressed data. It's worth nothing one important difference - decompression needs the length of output buffer specified as third parameter (input.Length
). Although some decompressors can guess uncompressed length more or less correct, the others won't know it beforehand. In reality this problem is solved by using a framing format that adds metadata about resulting length, however many compression formats do not define that and consider compressed packets to be implementation specific.
You will need more or less recent C++ compiler, CMake
and .NET SDK 8
to build the code.
Building
See workflow file for building instructions.
Hint: To develop managed only code locally you can download the latest artifact from Actions output and put it into native/ubin
so you have binaries for all platforms.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Snappier (>= 1.1.6)
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.5)
- ZstdSharp.Port (>= 0.8.1)
-
.NETStandard 2.1
- Snappier (>= 1.1.6)
- ZstdSharp.Port (>= 0.8.1)
-
net6.0
- Snappier (>= 1.1.6)
- ZstdSharp.Port (>= 0.8.1)
-
net8.0
- Snappier (>= 1.1.6)
- ZstdSharp.Port (>= 0.8.1)
NuGet packages (62)
Showing the top 5 NuGet packages that depend on IronCompress:
Package | Downloads |
---|---|
Parquet.Net
Fully managed Apache Parquet implementation. |
|
Elsa
Bundles the most commonly-used packages when building an Elsa workflows application. |
|
Elsa.Workflows.Management
Provides workflow management functionality. |
|
Elsa.Workflows.Runtime
Provides workflow runtime functionality. |
|
Elsa.Retention
Provides retention options for workflows. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on IronCompress:
Repository | Stars |
---|---|
elsa-workflows/elsa-core
A .NET workflows library
|
|
aloneguid/parquet-dotnet
Fully managed Apache Parquet implementation
|
|
mjebrahimi/EasyCompressor
β‘An Easy-to-Use and Optimized compression library for .NET that unified several compression algorithms including LZ4, Snappy, Zstd, LZMA, Brotli, GZip, ZLib, and Deflate. This library aids in Improving Performance by Reducing Memory Usage and Bandwidth Usage. Along with a greate Performance Benchmark between different compression algorithms.
|
Version | Downloads | Last updated | |
---|---|---|---|
1.6.3 | 63,535 | 10/14/2024 | |
1.6.2 | 17,361 | 9/30/2024 | |
1.6.1 | 160 | 9/30/2024 | |
1.6.1-pre.1 | 60 | 9/27/2024 | |
1.6.0 | 292 | 9/24/2024 | |
1.6.0-pre.1 | 57 | 9/24/2024 | |
1.5.2 | 425,569 | 5/22/2024 | |
1.5.2-pre.1 | 80 | 5/22/2024 | |
1.5.1 | 1,822,280 | 8/3/2023 | |
1.5.0 | 213 | 8/3/2023 | |
1.4.0 | 479,057 | 5/10/2023 | |
1.3.0 | 591,330 | 1/27/2023 | |
1.2.8 | 335 | 1/26/2023 | |
1.2.7 | 9,024 | 1/23/2023 | |
1.2.6 | 12,381 | 1/11/2023 | |
1.2.5 | 83,575 | 12/21/2022 | |
1.2.4 | 29,351 | 11/24/2022 | |
1.2.3 | 137,873 | 11/10/2022 | |
1.2.2 | 370 | 11/10/2022 | |
1.2.0 | 389 | 11/9/2022 | |
1.1.5 | 235,809 | 10/13/2022 | |
1.1.4 | 419 | 10/12/2022 | |
1.1.3 | 426 | 10/12/2022 | |
1.1.2 | 401 | 10/12/2022 | |
1.1.1 | 389 | 10/12/2022 | |
1.1.0 | 420 | 10/11/2022 | |
1.0.0 | 622 | 9/26/2022 | |
1.0.0-preview-03 | 193 | 9/26/2022 | |
1.0.0-preview-02 | 271 | 1/12/2022 | |
1.0.0-preview-01 | 441 | 1/12/2022 |