예제 #1
0
        private void SplitIncomingStreamByChunks()
        {
            var chunkIndex = 0;

            while (_zipProcessor.TryReadNextChunk(_incomingStream, out var sequence))
            {
                var chunk = new StreamChunk(chunkIndex, sequence);
                _chunksToProcess.TryAdd(chunk);

                chunkIndex++;
            }

            _chunksToProcess.CompleteAdding();
        }
예제 #2
0
        private void ProcessChunks()
        {
            while (_chunksToProcess.TryTake(out var chunk))
            {
                var sequence = new Sequence <byte>(ArrayPool <byte> .Shared);
                using (chunk)
                {
                    using var buffer = sequence.AsStream();
                    _zipProcessor.ProcessChunk(chunk, buffer);
                }

                var processedChunk = new StreamChunk(chunk.Index, sequence);

                _chunksToWrite.TryAdd(processedChunk);
            }
        }
예제 #3
0
            public void WriteChunkLength(StreamChunk chunk, Stream stream)
            {
                var blockLength = BitConverter.GetBytes((int)chunk.Stream.Length);

                stream.Write(blockLength);
            }
예제 #4
0
 public void ProcessChunk(StreamChunk chunk, Stream buffer)
 {
     using var zipStream = new GZipStream(buffer, _compressionLevel);
     chunk.Stream.CopyTo(zipStream);
 }
예제 #5
0
 public void WriteChunkLength(StreamChunk chunk, Stream stream)
 {
 }
예제 #6
0
 public void ProcessChunk(StreamChunk chunk, Stream buffer)
 {
     using var zipStream = new GZipStream(chunk.Stream, CompressionMode.Decompress);
     zipStream.CopyTo(buffer);
 }