public StreamData Decompress(StreamData data) { _compStream.Position = 0; _compStream.Write(data.Array, data.Offset, data.Count); _compStream.Position = 0; var unzipStream = new GZipStream(_compStream, CompressionMode.Decompress, true); const int Size = INIT_CAPACITY; _decompStream.Position = 0; while (true) { int count = unzipStream.Read(_outBuffer, 0, Size); if (count == 0) { break; } _decompStream.Write(_outBuffer, 0, count); } unzipStream.Close(); return(ReadStreamData(_decompStream)); }
public StreamData Process(StreamMode mode, StreamData data) { try { OCProfiler.Start(); if (mode == StreamMode.Compress) { return(Compress(data)); } else { return(Decompress(data)); } } finally { var elasped = (int)OCProfiler.Stop(); if (mode == StreamMode.Compress) { _stats.CompressTime += elasped; } else { _stats.DecompressTime += elasped; } } }
public void Process(StreamMode mode, StreamData data, Action <byte[], int> callback) { if (!_disposed) { var request = new AsyncStreamRequest(mode, data, callback); var task = new StreamTask(GetIdleUnit(), request); ThreadPool.QueueUserWorkItem(_ => { task.Run(); }); } }
public StreamData Compress(StreamData data) { _compStream.Position = 0; var zipStream = new GZipStream(_compStream, CompressionMode.Compress, true); zipStream.Write(data.Array, data.Offset, data.Count); zipStream.Close(); return(ReadStreamData(_compStream)); }
public StreamData Decompress(StreamData data) { return(data); }
public AsyncStreamRequest(StreamMode mode, StreamData data, Action <byte[], int> callback) { Mode = mode; Data = data; Callback = callback; }
public void Process(StreamMode mode, StreamData data, Action <byte[], int> callback) { var output = _streamUnit.Process(mode, data); callback(output.Array, output.Count); }
private StreamData Decompress(StreamData data) { return(_algorithm.Decompress(data)); }