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(); }
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); } }
public void WriteChunkLength(StreamChunk chunk, Stream stream) { var blockLength = BitConverter.GetBytes((int)chunk.Stream.Length); stream.Write(blockLength); }
public void ProcessChunk(StreamChunk chunk, Stream buffer) { using var zipStream = new GZipStream(buffer, _compressionLevel); chunk.Stream.CopyTo(zipStream); }
public void WriteChunkLength(StreamChunk chunk, Stream stream) { }
public void ProcessChunk(StreamChunk chunk, Stream buffer) { using var zipStream = new GZipStream(chunk.Stream, CompressionMode.Decompress); zipStream.CopyTo(buffer); }