SnappyLib 1.1.7

This is the PInvoke wrapper over the implementation of the compression / decompression algorithm in the c ++ library from Google

Install-Package SnappyLib -Version 1.1.7
dotnet add package SnappyLib --version 1.1.7
<PackageReference Include="SnappyLib" Version="1.1.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SnappyLib --version 1.1.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SnappyLib, 1.1.7"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SnappyLib as a Cake Addin
#addin nuget:?package=SnappyLib&version=1.1.7

// Install SnappyLib as a Cake Tool
#tool nuget:?package=SnappyLib&version=1.1.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Snappy, a fast compressor/decompressor.

This is the PInvoke wrapper over the implementation of the compression / decompression algorithm in the c ++ library from Google (https://github.com/google/snappy version 1.1.7).

Basic usage

var source = "У попа была собака он её любил, она съела кусок мяса он её убил.";
var sourceData = System.Text.Encoding.UTF8.GetBytes(source);
var compressData = new byte[1024];
var uncompressData = new byte[1024];

var compressedSize = SnappyLib.Snappy.Compress(sourceData, 0, sourceData.Length, compressData, 0, compressData.Length);
Assert.AreEqual(100, compressedSize);

var uncompressedSize = SnappyLib.Snappy.Uncompress(compressData, 0, compressedSize, uncompressData, 0, uncompressData.Length);
Assert.AreEqual(sourceData.Length, uncompressedSize);
Assert.IsTrue(new Span<byte>(sourceData).SequenceEqual(new Span<byte>(uncompressData, 0, uncompressedSize)));

var maxCompressedSize = SnappyLib.Snappy.MaxCompressedLength(sourceData.Length);
Assert.IsTrue(maxCompressedSize >= compressedSize);

var calculatedUncompressedSize = SnappyLib.Snappy.UncompressedLength(compressData, 0, compressedSize);
Assert.AreEqual(sourceData.Length, calculatedUncompressedSize);

var dcompressedDataValidationStatus = SnappyLib.Snappy.ValidateCompressedBuffer(compressData, 0, compressedSize);
Assert.AreEqual(dcompressedDataValidationStatus, SnappyLib.SnappyStatusEnum.SNAPPY_OK);

Snappy, a fast compressor/decompressor.

This is the PInvoke wrapper over the implementation of the compression / decompression algorithm in the c ++ library from Google (https://github.com/google/snappy version 1.1.7).

Basic usage

var source = "У попа была собака он её любил, она съела кусок мяса он её убил.";
var sourceData = System.Text.Encoding.UTF8.GetBytes(source);
var compressData = new byte[1024];
var uncompressData = new byte[1024];

var compressedSize = SnappyLib.Snappy.Compress(sourceData, 0, sourceData.Length, compressData, 0, compressData.Length);
Assert.AreEqual(100, compressedSize);

var uncompressedSize = SnappyLib.Snappy.Uncompress(compressData, 0, compressedSize, uncompressData, 0, uncompressData.Length);
Assert.AreEqual(sourceData.Length, uncompressedSize);
Assert.IsTrue(new Span<byte>(sourceData).SequenceEqual(new Span<byte>(uncompressData, 0, uncompressedSize)));

var maxCompressedSize = SnappyLib.Snappy.MaxCompressedLength(sourceData.Length);
Assert.IsTrue(maxCompressedSize >= compressedSize);

var calculatedUncompressedSize = SnappyLib.Snappy.UncompressedLength(compressData, 0, compressedSize);
Assert.AreEqual(sourceData.Length, calculatedUncompressedSize);

var dcompressedDataValidationStatus = SnappyLib.Snappy.ValidateCompressedBuffer(compressData, 0, compressedSize);
Assert.AreEqual(dcompressedDataValidationStatus, SnappyLib.SnappyStatusEnum.SNAPPY_OK);

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SnappyLib:

Package Downloads
CappedLog.loki
Extension for fixed size tagged log located in memory with Grafana Loki API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.7 2,592 10/8/2019