internal SortedTreeTableReadSnapshot(ReadSnapshot currentTransaction, SubFileName fileName) { try { m_subStream = currentTransaction.OpenFile(fileName); m_binaryStream = new BinaryStream(m_subStream); m_tree = SortedTree <TKey, TValue> .Open(m_binaryStream); } catch { Dispose(); throw; } }
public void Test() { Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); //string file = Path.GetTempFileName(); //System.IO.File.Delete(file); try { //using (FileSystemSnapshotService service = FileSystemSnapshotService.CreateFile(file)) using (TransactionalFileStructure service = TransactionalFileStructure.CreateInMemory(BlockSize)) { using (TransactionalEdit edit = service.BeginEdit()) { SubFileStream fs = edit.CreateFile(SubFileName.CreateRandom()); BinaryStream bs = new BinaryStream(fs); bs.Write((byte)1); bs.Dispose(); fs.Dispose(); edit.CommitAndDispose(); } { ReadSnapshot read = service.Snapshot; SubFileStream f1 = read.OpenFile(0); BinaryStream bs1 = new BinaryStream(f1); if (bs1.ReadUInt8() != 1) { throw new Exception(); } using (TransactionalEdit edit = service.BeginEdit()) { SubFileStream f2 = edit.OpenFile(0); BinaryStream bs2 = new BinaryStream(f2); if (bs2.ReadUInt8() != 1) { throw new Exception(); } bs2.Write((byte)3); bs2.Dispose(); } //rollback should be issued; if (bs1.ReadUInt8() != 0) { throw new Exception(); } bs1.Dispose(); { ReadSnapshot read2 = service.Snapshot; SubFileStream f2 = read2.OpenFile(0); BinaryStream bs2 = new BinaryStream(f2); if (bs2.ReadUInt8() != 1) { throw new Exception(); } if (bs2.ReadUInt8() != 0) { throw new Exception(); } bs2.Dispose(); } } using (TransactionalEdit edit = service.BeginEdit()) { SubFileStream f2 = edit.OpenFile(0); BinaryStream bs2 = new BinaryStream(f2); bs2.Write((byte)13); bs2.Write((byte)23); bs2.Dispose(); edit.RollbackAndDispose(); } //rollback should be issued; } } finally { //System.IO.File.Delete(file); } Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0L); Assert.IsTrue(true); }
internal SortedTreeTableSnapshotInfo(TransactionalFileStructure fileStructure, SubFileName fileName) { m_fileName = fileName; m_fileStructure = fileStructure; m_currentTransaction = m_fileStructure.Snapshot; }