コード例 #1
0
        /// <summary>
        /// Compression of a block method that is used as callback for <see cref="CollectionProcessorThreadPool{T}"/>
        /// </summary>
        /// <param name="block">Processing block</param>
        protected override void ProcessBlock(ByteBlock block)
        {
            if (block == null || IsAborted)
            {
                return;
            }

            using (var memoryStream = new MemoryStream())
            {
                using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Compress))
                {
                    gZipStream.Write(block.Buffer, 0, block.Buffer.Length);
                }

                var compressedBlock = memoryStream.ToArray().AddByteBlockLengthHeader();
                OutputBlocks.Add(block.BlockNumber, compressedBlock);
            }
        }
コード例 #2
0
        /// <summary>
        /// Decompression of a block method that is used as callback for <see cref="CollectionProcessorThreadPool{T}"/>
        /// </summary>
        /// <param name="block">Processing block</param>
        protected override void ProcessBlock(ByteBlock block)
        {
            if (block == null || IsAborted)
            {
                return;
            }

            using (var memoryStream = new MemoryStream(block.Buffer))
            {
                var decompressedBlock = block.IsLast ? new byte[OriginalLastBlockLength] : new byte[OriginalBlockSize];

                using (var gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
                {
                    gZipStream.Read(decompressedBlock, 0, decompressedBlock.Length);
                }

                OutputBlocks.Add(block.BlockNumber, decompressedBlock);
            }
        }
コード例 #3
0
 /// <summary>
 /// Procession of a block method that is used as callback for <see cref="CollectionProcessorThreadPool{T}"/>
 /// </summary>
 /// <param name="block">Processing block</param>
 protected abstract void ProcessBlock(ByteBlock block);