示例#1
0
 /// <summary>
 /// write compressed data to stream
 /// </summary>
 /// <param name="data">compressed data</param>
 public void WriteData(Block data)
 {
     lock (locker)
     {
         outputStream.Write(data.Number);
         outputStream.Write(data.Data.Length);
         outputStream.Write(data.Data);
     }
     BlockPool.ReturnObject(data);
 }
示例#2
0
        /// <summary>
        /// writing decompressed data to file
        /// </summary>
        /// <param name="data">decompressed data</param>
        public void WriteData(Block data)
        {
            lock (locker)
            {
                if (data.Number < position || dictToWrite.ContainsKey(data.Number))
                {
                    throw new Exception($"Duplicate key to write {data.Number}");
                }

                dictToWrite.Add(data.Number, data.Data);

                while (dictToWrite.ContainsKey(position))
                {
                    outputStream.Write(dictToWrite[position]);
                    dictToWrite.Remove(position++);
                }
                BlockPool.ReturnObject(data);
            }
        }