コード例 #1
0
        public virtual long CollectFor(LocalObjectContainer db, int id, ISlotMap slotMap)
        {
            object bigSet = db.GetByID(id);

            db.Activate(bigSet, 1);
            BTree btree = (BTree)Reflection4.GetFieldValue(bigSet, "_bTree");

            return(FileUsageStatsCollector.BTreeUsage(db, btree, slotMap));
        }
コード例 #2
0
        public virtual void ReadIdentity(LocalTransaction trans)
        {
            LocalObjectContainer file     = trans.LocalContainer();
            Db4oDatabase         identity = Debug4.staticIdentity ?
                                            Db4oDatabase.StaticIdentity :
                                            (Db4oDatabase)file.GetByID(trans, SystemData().IdentityId());

            if (null != identity)
            {
                file.Activate(trans, identity, new FixedActivationDepth(2));
                SystemData().Identity(identity);
            }
        }
コード例 #3
0
        public virtual void ReplaceClassMetadataRepository()
        {
            Db4objects.Db4o.Internal.Transaction systemTransaction = _targetDb.SystemTransaction
                                                                         ();
            // Can't use strictMappedID because the repository ID can
            // be lower than HandlerRegisrtry _highestBuiltinTypeID and
            // the ClassRepository ID would be treated as a system handler
            // and the unmapped ID would be returned.
            int newRepositoryId   = _mapping.MappedId(SourceClassCollectionID());
            int sourceIdentityID  = DatabaseIdentityID(DefragmentServicesImpl.Sourcedb);
            int targetIdentityID  = _mapping.MappedId(sourceIdentityID);
            int targetUuidIndexID = _mapping.MappedId(SourceUuidIndexID());
            int oldIdentityId     = _targetDb.SystemData().Identity().GetID(systemTransaction);
            int oldRepositoryId   = _targetDb.ClassCollection().GetID();
            ClassMetadataRepository oldRepository = _targetDb.ClassCollection();
            ClassMetadataRepository newRepository = new ClassMetadataRepository(systemTransaction
                                                                                );

            newRepository.SetID(newRepositoryId);
            newRepository.Read(systemTransaction);
            newRepository.InitOnUp(systemTransaction);
            _targetDb.SystemData().ClassCollectionID(newRepositoryId);
            _targetDb.ReplaceClassMetadataRepository(newRepository);
            _targetDb.SystemData().UuidIndexId(targetUuidIndexID);
            Db4oDatabase identity = (Db4oDatabase)_targetDb.GetByID(systemTransaction, targetIdentityID
                                                                    );

            _targetDb.SetIdentity(identity);
            ClassMetadataIterator iterator = oldRepository.Iterator();

            while (iterator.MoveNext())
            {
                ClassMetadata           classMetadata = iterator.CurrentClass();
                BTreeClassIndexStrategy index         = (BTreeClassIndexStrategy)classMetadata.Index();
                index.Btree().Free(_targetDb.LocalSystemTransaction());
                FreeById(classMetadata.GetID());
            }
            FreeById(oldIdentityId);
            FreeById(oldRepositoryId);
        }