Пример #1
0
        public long ReadOidPosition(OID oid)
        {
            if (OdbConfiguration.IsLoggingEnabled())
            {
                DLogger.Debug("ObjectReader: Start of readOidPosition for oid " + oid);
            }

            var blockNumber   = StorageEngineConstant.GetIdBlockNumberOfOid(oid);
            var blockPosition = GetIdBlockPositionFromNumber(blockNumber);

            if (OdbConfiguration.IsLoggingEnabled())
            {
                var blockNumberAsString   = blockNumber.ToString();
                var blockPositionAsString = blockPosition.ToString();
                DLogger.Debug(string.Format("ObjectReader: Block number of oid {0} is ", oid) + blockNumberAsString +
                              " / block position = " + blockPositionAsString);
            }

            var position = blockPosition + StorageEngineConstant.BlockIdOffsetForStartOfRepetition +
                           ((oid.ObjectId - 1) % StorageEngineConstant.NbIdsPerBlock) *
                           StorageEngineConstant.IdBlockRepetitionSize;

            if (OdbConfiguration.IsLoggingEnabled())
            {
                var positionAsString = position.ToString();
                DLogger.Debug(string.Format("ObjectReader: End of readOidPosition for oid {0} returning position ", oid) + positionAsString);
            }

            return(position);
        }
Пример #2
0
        public void ReadDatabaseHeader()
        {
            var version = ReadDatabaseVersion();

            StorageEngineConstant.CheckDbVersionCompatibility(version);

            var databaseIdsArray = new long[4];

            databaseIdsArray[0] = _fsi.ReadLong();
            databaseIdsArray[1] = _fsi.ReadLong();
            databaseIdsArray[2] = _fsi.ReadLong();
            databaseIdsArray[3] = _fsi.ReadLong();
            IDatabaseId databaseId = new DatabaseId(databaseIdsArray);

            var nbClasses          = ReadNumberOfClasses();
            var firstClassPosition = ReadFirstClassOid();

            if (nbClasses < 0)
            {
                throw new CorruptedDatabaseException(
                          NDatabaseError.NegativeClassNumberInHeader.AddParameter(nbClasses).AddParameter(firstClassPosition));
            }
            ReadLastOdbCloseStatus();
            ReadDatabaseCharacterEncoding();

            var currentBlockPosition = _fsi.ReadLong();

            // Gets the current id block number
            _fsi.SetReadPosition(currentBlockPosition + StorageEngineConstant.BlockIdOffsetForBlockNumber);
            var currentBlockIdNumber = _fsi.ReadInt();
            var blockMaxId           = OIDFactory.BuildObjectOID(_fsi.ReadLong());

            _storageEngine.SetDatabaseId(databaseId);

            var currentBlockInfo = new CurrentIdBlockInfo
            {
                CurrentIdBlockPosition = currentBlockPosition,
                CurrentIdBlockNumber   = currentBlockIdNumber,
                CurrentIdBlockMaxOid   = blockMaxId
            };

            _storageEngine.SetCurrentIdBlockInfos(currentBlockInfo);
        }
Пример #3
0
        public long ReadOidPosition(OID oid)
        {
            Log4NetHelper.Instance.LogDebugMessage("ObjectReader: Start of readOidPosition for oid " + oid);

            var blockNumber   = StorageEngineConstant.GetIdBlockNumberOfOid(oid);
            var blockPosition = GetIdBlockPositionFromNumber(blockNumber);

            var blockNumberAsString   = blockNumber.ToString();
            var blockPositionAsString = blockPosition.ToString();

            Log4NetHelper.Instance.LogDebugMessage(string.Format("ObjectReader: Block number of oid {0} is ", oid) + blockNumberAsString +
                                                   " / block position = " + blockPositionAsString);

            var position = blockPosition + StorageEngineConstant.BlockIdOffsetForStartOfRepetition +
                           ((oid.ObjectId - 1) % StorageEngineConstant.NbIdsPerBlock) *
                           StorageEngineConstant.IdBlockRepetitionSize;

            var positionAsString = position.ToString();

            Log4NetHelper.Instance.LogDebugMessage(string.Format("ObjectReader: End of readOidPosition for oid {0} returning position ", oid) + positionAsString);

            return(position);
        }