public void Setup() { _stream = null; const int pageSizeInBytes = 5; _appendOnlyStore = new AppendOnlyStream(pageSizeInBytes, (o, s) => { if (s.Length > 0) { if (_stream == null) _stream = new MemoryStream(); s.Position = 0; var bytes = new byte[s.Length]; s.Read(bytes, 0, (int) s.Length); _stream.Position = o; _stream.Write(bytes, 0, bytes.Length); } } , 100); }
public void Close() { _closed = true; if (_currentWriter == null) return; var tmp = _currentWriter; _currentWriter = null; tmp.Dispose(); }
void EnsureWriterExists(long version) { if (_currentWriter != null) return; var fileName = string.Format("{0:00000000}-{1:yyyy-MM-dd-HHmmss}.dat", version, DateTime.UtcNow); var blob = _container.GetPageBlobReference(fileName); blob.Create(_pageSizeMultiplier); _currentWriter = new AppendOnlyStream(512, (i, bytes) => blob.WritePages(bytes, i), _pageSizeMultiplier); }
void CloseWriter() { _currentWriter.Dispose(); _currentWriter = null; }