Пример #1
0
        private void LoadWriteActions(string filename, bool apply)
        {
            Log4NetHelper.Instance.LogDebugMessage(string.Format("OdbTransaction: Load write actions of {0}", filename));

            CheckFileAccess(filename);
            _fsi.SetReadPosition(0);
            _isCommited       = _fsi.ReadByte() == 1;
            _creationDateTime = _fsi.ReadLong();
            var totalNumberOfWriteActions = _fsi.ReadLong();

            Log4NetHelper.Instance.LogInfoMessage(string.Concat("OdbTransaction: ", _writeActions.Count.ToString(), " write actions in file"));

            for (var i = 0; i < totalNumberOfWriteActions; i++)
            {
                var defaultWriteAction = WriteAction.Read(_fsi);

                if (apply)
                {
                    defaultWriteAction.ApplyTo(_fsiToApplyWriteActions);
                    defaultWriteAction.Clear();
                }
                else
                {
                    AddWriteAction(defaultWriteAction, false);
                }
            }

            if (apply)
            {
                _fsiToApplyWriteActions.Flush();
            }
        }
Пример #2
0
        /// <summary>
        ///   Returns information about all OIDs of the database
        /// </summary>
        /// <param name="idType"> </param>
        /// <returns> @ </returns>
        public IList <long> GetAllIds(byte idType)
        {
            IList <long> ids = new List <long>(5000);
            long         currentBlockPosition = StorageEngineConstant.DatabaseHeaderFirstIdBlockPosition;

            while (currentBlockPosition != -1)
            {
                // Gets the next block position
                _fsi.SetReadPosition(currentBlockPosition + StorageEngineConstant.BlockIdOffsetForNextBlock);
                var nextBlockPosition = _fsi.ReadLong();
                // Gets the block max id
                _fsi.SetReadPosition(currentBlockPosition + StorageEngineConstant.BlockIdOffsetForMaxId);
                var  blockMaxId = _fsi.ReadLong();
                long currentId;
                do
                {
                    var nextRepetitionPosition = _fsi.GetPosition() + StorageEngineConstant.IdBlockRepetitionSize;
                    var idTypeRead             = _fsi.ReadByte();
                    currentId = _fsi.ReadLong();
                    var idStatus = _fsi.ReadByte();
                    if (idType == idTypeRead && IDStatus.IsActive(idStatus))
                    {
                        ids.Add(currentId);
                    }
                    _fsi.SetReadPosition(nextRepetitionPosition);
                } while (currentId != blockMaxId);
                currentBlockPosition = nextBlockPosition;
            }
            return(ids);
        }
Пример #3
0
        private void LoadWriteActions(string filename, bool apply)
        {
            if (OdbConfiguration.IsLoggingEnabled())
            {
                DLogger.Debug(string.Format("OdbTransaction: Load write actions of {0}", filename));
            }

            CheckFileAccess(filename);
            _fsi.SetReadPosition(0);
            _isCommited       = _fsi.ReadByte() == 1;
            _creationDateTime = _fsi.ReadLong();
            var totalNumberOfWriteActions = _fsi.ReadLong();

            if (OdbConfiguration.IsLoggingEnabled())
            {
                DLogger.Info(string.Concat("OdbTransaction: ", _writeActions.Count.ToString(), " write actions in file"));
            }

            for (var i = 0; i < totalNumberOfWriteActions; i++)
            {
                var defaultWriteAction = WriteAction.Read(_fsi);

                if (apply)
                {
                    defaultWriteAction.ApplyTo(_fsiToApplyWriteActions);
                    defaultWriteAction.Clear();
                }
                else
                {
                    AddWriteAction(defaultWriteAction, false);
                }
            }

            if (apply)
            {
                _fsiToApplyWriteActions.Flush();
            }
        }