예제 #1
0
        public void CanSetString()
        {
            var page = _fileManager.ResolvePage();

            var block = new Block(RandomFilename, 0);

            page.Read(block);
            page.SetString(0, "default string");
            page.Write(block);

            _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6);
            var buffer = _bufferManager.Pin(block);

            var lsn = _recoveryManager.SetString(buffer, 0, "not default string");

            _logManager.Flush(lsn);

            _bufferManager.Unpin(buffer);
            _bufferManager.FlushAll(6);

            var enumerator = _logManager.GetEnumerator();

            var record        = enumerator.Current;
            var setBoolRecord = new SetStringRecord(_logManager, _bufferManager, record);

            Assert.AreEqual(LogRecordType.SetString, setBoolRecord.Type);
            Assert.AreEqual(0, setBoolRecord.Block.Id);
            Assert.AreEqual(0, setBoolRecord.Offset);
            Assert.AreEqual("default string", setBoolRecord.Value);
            Assert.AreEqual(6, setBoolRecord.TransactionNumber);
        }
예제 #2
0
        public bool SetString(Block block, int offset, string value)
        {
            _concurrencyManager.ExclusiveLock(block);
            var buffer = _bufferList.GetBuffer(block);
            int lsn    = _recoveryManager.SetString(buffer, offset, value);

            return(buffer.SetString(offset, value, _transactionNumber, lsn));
        }
예제 #3
0
        public void CanSetTempString()
        {
            var page = _fileManager.ResolvePage();

            var block = new Block("temp" + RandomFilename, 0);

            page.Read(block);
            page.SetString(0, "default string");
            page.Write(block);

            _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6);
            var buffer = _bufferManager.Pin(block);

            var lsn = _recoveryManager.SetString(buffer, 0, "string default");

            Assert.AreEqual(-1, lsn);
        }