Esempio n. 1
0
        public void Execute()
        {
            while (generator.TryDequeue(out var chunk))
            {
                reader.Read(readBuffer.Value, 0, chunk.source.size, chunk.source.offset);

                var compressedSize = compressor.Compress(
                    readBuffer.Value, 0, chunk.source.size,
                    compressionBuffer.Value, ChunkCompressedInfo.SIZE, compressionBuffer.Value.Length - ChunkCompressedInfo.SIZE);

                var info = new ChunkCompressedInfo(
                    compressedSize,
                    chunk.source);
                ChunkCompressedInfo.ToBinary(info, compressionBuffer.Value, 0);

                writer.Write(compressionBuffer.Value, 0, ChunkCompressedInfo.SIZE + compressedSize);
            }
        }
Esempio n. 2
0
        public void ShouldSerializeDeserialize(int size1, long offset2, int size2)
        {
            // Arrange

            var buffer = new byte[ChunkCompressedInfo.SIZE];

            var input = new ChunkCompressedInfo(size1, new ChunkInfo(offset2, size2));

            // Act

            ChunkCompressedInfo.ToBinary(input, buffer, 0);
            var result = ChunkCompressedInfo.FromBinary(buffer, 0);

            // Assert

            Assert.Equal(size1, result.size);
            Assert.Equal(offset2, result.target.offset);
            Assert.Equal(size2, result.target.size);
        }