Esempio n. 1
0
        public void Restore(Transaction tx)
        {
            // read all the freed transactions to memory, we expect this
            // number to be pretty small, so we don't worry about holding it all
            // in memory
            using (var it = _env.FreeSpaceRoot.Iterate(tx))
            {
                it.RequiredPrefix = _txPrefix;

                if (it.Seek(_txPrefix) == false)
                {
                    return;
                }

                do
                {
                    var freedTransaction = new FreedTransaction
                    {
                        Key   = it.CurrentKey.Clone(),
                        Pages = new List <long>()
                    };

                    var size = it.GetCurrentDataSize() / sizeof(long);

                    Debug.Assert(size > 1);


                    using (var stream = it.CreateStreamForCurrent())
                        using (var reader = new BinaryReader(stream))
                        {
                            freedTransaction.Id = reader.ReadInt64();
                            for (var i = 1; i < size; i++)
                            {
                                freedTransaction.Pages.Add(reader.ReadInt64());
                            }
                        }

                    _freedTransactions.AddLast(freedTransaction);
                } while (it.MoveNext());
            }
        }
Esempio n. 2
0
        public void Restore(Transaction tx)
        {
            // read all the freed transactions to memory, we expect this
            // number to be pretty small, so we don't worry about holding it all 
            // in memory
			using (var it = _env.State.FreeSpaceRoot.Iterate(tx))
            {
                it.RequiredPrefix = _txPrefix;

                if (it.Seek(_txPrefix) == false)
                    return;

                do
                {
                    var freedTransaction = new FreedTransaction
                        {
                            Key = it.CurrentKey.Clone(),
                            Pages = new List<long>()
                        };

                    var size = it.GetCurrentDataSize() / sizeof(long);

                    Debug.Assert(size > 1);


                    using (var stream = it.CreateStreamForCurrent())
                    using (var reader = new BinaryReader(stream))
                    {
                        freedTransaction.Id = reader.ReadInt64();
                        for (var i = 1; i < size; i++)
                        {
                            freedTransaction.Pages.Add(reader.ReadInt64());
                        }
                    }

                    _freedTransactions.AddLast(freedTransaction);
                } while (it.MoveNext());
            }
        }