public void CanSetBlob() { var page = _fileManager.ResolvePage(); var block = new Block(RandomFilename, 0); page.Read(block); page.SetBlob(0, new byte[] { 1, 2, 3 }); page.Write(block); _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6); var buffer = _bufferManager.Pin(block); var lsn = _recoveryManager.SetBlob(buffer, 0, new byte[] { 3, 2, 1 }); _logManager.Flush(lsn); _bufferManager.Unpin(buffer); _bufferManager.FlushAll(6); var enumerator = _logManager.GetEnumerator(); var record = enumerator.Current; var setBoolRecord = new SetBlobRecord(_logManager, _bufferManager, record); Assert.AreEqual(LogRecordType.SetBlob, setBoolRecord.Type); Assert.AreEqual(0, setBoolRecord.Block.Id); Assert.AreEqual(0, setBoolRecord.Offset); Assert.AreEqual(new byte[] { 1, 2, 3 }, setBoolRecord.Value); Assert.AreEqual(6, setBoolRecord.TransactionNumber); }
public bool SetBlob(Block block, int offset, byte[] value) { _concurrencyManager.ExclusiveLock(block); var buffer = _bufferList.GetBuffer(block); int lsn = _recoveryManager.SetBlob(buffer, offset, value); return(buffer.SetBlob(offset, value, _transactionNumber, lsn)); }
public void CanSetTempBlob() { var page = _fileManager.ResolvePage(); var block = new Block("temp" + RandomFilename, 0); page.Read(block); page.SetBlob(0, new byte[] { 1, 2, 3 }); page.Write(block); _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6); var buffer = _bufferManager.Pin(block); var lsn = _recoveryManager.SetBlob(buffer, 0, new byte[] { 3, 2, 1 }); Assert.AreEqual(-1, lsn); }