Beispiel #1
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);
        }
Beispiel #2
0
        internal static WriteAction Read(IFileSystemInterface fsi)
        {
            try
            {
                var position    = fsi.ReadLong();
                var size        = fsi.ReadInt();
                var bytes       = fsi.ReadBytes(size);
                var writeAction = new WriteAction(position, bytes);

                Log4NetHelper.Instance.LogDebugMessage(string.Format("Transaction WriteAction: Loading Write Action at {0} => {1}", fsi.GetPosition(), writeAction));

                return(writeAction);
            }
            catch (OdbRuntimeException)
            {
                Log4NetHelper.Instance.LogErrorMessage(string.Format("Transaction WriteAction: error reading write action at position {0}", fsi.GetPosition()));
                throw;
            }
        }
Beispiel #3
0
        internal static WriteAction Read(IFileSystemInterface fsi)
        {
            try
            {
                var position    = fsi.ReadLong();
                var size        = fsi.ReadInt();
                var bytes       = fsi.ReadBytes(size);
                var writeAction = new WriteAction(position, bytes);

                if (OdbConfiguration.IsLoggingEnabled())
                {
                    DLogger.Debug(string.Format("Transaction WriteAction: Loading Write Action at {0} => {1}", fsi.GetPosition(), writeAction));
                }

                return(writeAction);
            }
            catch (OdbRuntimeException)
            {
                DLogger.Error(string.Format("Transaction WriteAction: error reading write action at position {0}", fsi.GetPosition()));
                throw;
            }
        }
Beispiel #4
0
        internal static WriteAction Read(IFileSystemInterface fsi)
        {
            try
            {
                var position = fsi.ReadLong();
                var size = fsi.ReadInt();
                var bytes = fsi.ReadBytes(size);
                var writeAction = new WriteAction(position, bytes);

                if (OdbConfiguration.IsLoggingEnabled())
                    DLogger.Debug(string.Format("Transaction WriteAction: Loading Write Action at {0} => {1}", fsi.GetPosition(), writeAction));

                return writeAction;
            }
            catch (OdbRuntimeException)
            {
                DLogger.Error(string.Format("Transaction WriteAction: error reading write action at position {0}", fsi.GetPosition()));
                throw;
            }
        }