public void RoundtripGoldenData() { byte[] goldenRaw = File.ReadAllBytes("TestData/Mark.Twain-Tom.Sawyer.txt"); byte[] compressed = Snappy.Encode(goldenRaw); byte[] uncompressed = Snappy.Decode(compressed); Assert.Equal(goldenRaw.Length, uncompressed.Length); Assert.Equal(goldenRaw, uncompressed); }
internal override byte[] Compress(byte[] uncompressedData) { var compressedData = Snappy.Encode(uncompressedData); uint checksumUint = Crc32.Get(compressedData); byte[] checksumBytes = BitConverter.GetBytes(checksumUint); byte[] result = compressedData.Concat(checksumBytes).ToArray(); return(result); }
public void EncodeGoldenInput() { byte[] got = Snappy.Encode(File.ReadAllBytes("TestData/Mark.Twain-Tom.Sawyer.txt")); byte[] want = File.ReadAllBytes("TestData/Mark.Twain-Tom.Sawyer.rawsnappy.txt"); Assert.Equal(want.Length, got.Length); Assert.Equal(want, got); }
private void UpdateDocumentFromModel(CompanyDocuments target, ImagePickerResult source) { target.CompanyBlobId = source.blobId; target.CompanyGuid = source.guid; target.FileBlob = Snappy.Encode(source.ImageBytes); target.FileName = source.FileName; target.FileType = source.ContentType; target.FileCategoryId = source.FileCategoryId; target.UploadTime = DateTime.Now; target.FileLength = source.Size; }
public void RoundtripEncodeBytes() { byte[] bytes = File.ReadAllBytes("TestData/Mark.Shanghai-skyyearxp.bytes"); byte[] wants = File.ReadAllBytes("TestData/Mark.Shanghai-skyyearxp.snappy.bytes"); byte[] compressed = Snappy.Encode(bytes); Assert.Equal(wants.Length, compressed.Length); Assert.Equal(wants, compressed); byte[] uncompressed = Snappy.Decode(compressed); Assert.Equal(bytes.Length, uncompressed.Length); Assert.Equal(bytes, uncompressed); }
public void Write(byte[] buffer, Stream destination) { byte[] compressed = Snappy.Encode(buffer); destination.Write(compressed, 0, buffer.Length); }