public _IVisitor4_336(DefragmentServicesImpl _enclosing, CommitTimestampSupport target , LocalTransaction targetTransaction) { this._enclosing = _enclosing; this.target = target; this.targetTransaction = targetTransaction; }
public _IVisitor4_284(IPassCommand command, DefragmentServicesImpl context, ClassMetadata curClass) { this.command = command; this.context = context; this.curClass = curClass; }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> public void ProcessObjectSlot(DefragmentServicesImpl services, ClassMetadata classMetadata , int id) { ByteArrayBuffer sourceBuffer = services.SourceBufferByID(id); DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_43(this, services ), sourceBuffer); }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> private static void Pass(DefragmentServicesImpl context, DefragmentConfig config, IPassCommand command) { command.ProcessClassCollection(context); IStoredClass[] classes = context.StoredClasses(DefragmentServicesImpl.Sourcedb); for (int classIdx = 0; classIdx < classes.Length; classIdx++) { ClassMetadata classMetadata = (ClassMetadata)classes[classIdx]; if (!config.StoredClassFilter().Accept(classMetadata)) { continue; } ProcessClass(context, classMetadata, command); command.Flush(context); if (config.ObjectCommitFrequency() > 0) { context.TargetCommit(); } } BTree uuidIndex = context.SourceUuidIndex(); if (uuidIndex != null) { command.ProcessBTree(context, uuidIndex); } command.Flush(context); context.TargetCommit(); }
internal virtual void CreateIDMapping(DefragmentServicesImpl context, int objectID , bool isClassID) { if (BatchFull()) { Flush(context); } _ids = TreeInt.Add(_ids, (isClassID ? -objectID : objectID)); }
/// <exception cref="System.IO.IOException"></exception> public override void Open() { _mappingDb = DefragmentServicesImpl.FreshTempFile(_fileName, 1); _idTree = (_treeSpec == null ? new BTree(Trans(), 0, new MappedIDPairHandler()) : new BTree(Trans(), 0, new MappedIDPairHandler(), _treeSpec.NodeSize())); _slotTree = (_treeSpec == null ? new BTree(Trans(), 0, new BTreeIdSystem.IdSlotMappingHandler ()) : new BTree(Trans(), 0, new BTreeIdSystem.IdSlotMappingHandler(), _treeSpec. NodeSize())); }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> public void ProcessClass(DefragmentServicesImpl services, ClassMetadata classMetadata , int id, int classIndexID) { if (services.MappedID(id, -1) == -1) { Sharpen.Runtime.Err.WriteLine("MAPPING NOT FOUND: " + id); } DefragmentContextImpl.ProcessCopy(services, id, new _ISlotCopyHandler_34(classMetadata , classIndexID)); }
private static void DefragUnindexed(DefragmentServicesImpl services) { IdSource unindexedIDs = services.UnindexedIDs(); while (unindexedIDs.HasMoreIds()) { int origID = unindexedIDs.NextId(); DefragmentContextImpl.ProcessCopy(services, origID, new _ISlotCopyHandler_208()); } }
// TODO order of class index/object slot processing is crucial: // - object slots before field indices (object slots register addresses for // use by string indices) // - class index before object slots, otherwise phantom btree entries from // deletions appear in the source class index?!? // reproducable with SelectiveCascadingDeleteTestCase and ObjectSetTestCase // - investigate. /// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> private static void ProcessClass(DefragmentServicesImpl context, ClassMetadata curClass , IPassCommand command) { ProcessClassIndex(context, curClass, command); if (!ParentHasIndex(curClass)) { ProcessObjectsForClass(context, curClass, command); } ProcessClassAndFieldIndices(context, curClass, command); }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> private static void ProcessClassIndex(DefragmentServicesImpl context, ClassMetadata curClass, IPassCommand command) { if (curClass.HasClassIndex()) { BTreeClassIndexStrategy indexStrategy = (BTreeClassIndexStrategy)curClass.Index(); BTree btree = indexStrategy.Btree(); command.ProcessBTree(context, btree); } }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> private static void ProcessClassAndFieldIndices(DefragmentServicesImpl context, ClassMetadata curClass, IPassCommand command) { int sourceClassIndexID = 0; int targetClassIndexID = 0; if (curClass.HasClassIndex()) { sourceClassIndexID = curClass.Index().Id(); targetClassIndexID = context.MappedID(sourceClassIndexID, -1); } command.ProcessClass(context, curClass, curClass.GetID(), targetClassIndexID); }
/// <summary> /// Renames the file at the configured original path to the configured backup /// path and then builds a defragmented version of the file in the original /// place. /// </summary> /// <remarks> /// Renames the file at the configured original path to the configured backup /// path and then builds a defragmented version of the file in the original /// place. /// </remarks> /// <param name="config">The configuration for this defragmentation run.</param> /// <param name="listener"> /// A listener for status notifications during the defragmentation /// process. /// </param> /// <exception cref="System.IO.IOException">if the original file cannot be moved to the backup location /// </exception> public static void Defrag(DefragmentConfig config, IDefragmentListener listener) { IStorage storage = config.Db4oConfig().Storage; EnsureFileExists(storage, config.OrigPath()); IStorage backupStorage = config.BackupStorage(); if (backupStorage.Exists(config.BackupPath())) { if (!config.ForceBackupDelete()) { throw new IOException("Could not use '" + config.BackupPath() + "' as backup path - file exists." ); } } // Always delete, because !exists can indicate length == 0 backupStorage.Delete(config.BackupPath()); MoveToBackup(config); if (config.FileNeedsUpgrade()) { UpgradeFile(config); } DefragmentServicesImpl services = new DefragmentServicesImpl(config, listener); try { FirstPass(services, config); services.CommitIds(); SecondPass(services, config); services.CommitIds(); DefragUnindexed(services); services.CommitIds(); services.DefragIdToTimestampBtree(); services.ReplaceClassMetadataRepository(); } catch (CorruptionException exc) { Sharpen.Runtime.PrintStackTrace(exc); } finally { services.Close(); } }
public virtual void Flush(DefragmentServicesImpl context) { if (_ids == null) { return; } IEnumerator idIter = new TreeKeyIterator(_ids); while (idIter.MoveNext()) { var objectID = ((int) idIter.Current); var isClassID = false; if (objectID < 0) { objectID = -objectID; isClassID = true; } // seen object ids don't come by here anymore - any other candidates? context.MapIDs(objectID, context.TargetNewId(), isClassID); } context.Mapping().Commit(); _ids = null; }
public virtual void Flush(DefragmentServicesImpl context) { if (_ids == null) { return; } IEnumerator idIter = new TreeKeyIterator(_ids); while (idIter.MoveNext()) { int objectID = ((int)idIter.Current); bool isClassID = false; if (objectID < 0) { objectID = -objectID; isClassID = true; } // seen object ids don't come by here anymore - any other candidates? context.MapIDs(objectID, context.TargetNewId(), isClassID); } context.Mapping().Commit(); _ids = null; }
public _ISlotCopyHandler_59(DefragmentServicesImpl services) { this.services = services; }
public _ISlotCopyHandler_43(SecondPassCommand _enclosing, DefragmentServicesImpl services) { this._enclosing = _enclosing; this.services = services; }
public void ProcessObjectSlot(DefragmentServicesImpl context, ClassMetadata classMetadata , int sourceID) { _collector.CreateIDMapping(context, sourceID, false); }
public void ProcessClass(DefragmentServicesImpl context, ClassMetadata classMetadata , int id, int classIndexID) { _collector.CreateIDMapping(context, id, true); classMetadata.TraverseAllAspects(new _TraverseFieldCommand_24(this, context)); }
public void Flush(DefragmentServicesImpl context) { }
internal abstract LocalObjectContainer Db(DefragmentServicesImpl context);
public void Flush(DefragmentServicesImpl context) { _collector.Flush(context); }
public void ProcessBTree(DefragmentServicesImpl context, BTree btree) { context.RegisterBTreeIDs(btree, _collector); }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> public void ProcessClassCollection(DefragmentServicesImpl context) { _collector.CreateIDMapping(context, context.SourceClassCollectionID(), false); }
public _TraverseFieldCommand_24(FirstPassCommand _enclosing, DefragmentServicesImpl context) { this._enclosing = _enclosing; this.context = context; }
public virtual ByteArrayBuffer BufferByID(DefragmentServicesImpl.DbSelector selector , int id) { Slot slot = CommittedSlot(selector, id); return BufferByAddress(selector, slot.Address(), slot.Length()); }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> public void ProcessBTree(DefragmentServicesImpl context, BTree btree) { btree.DefragBTree(context); }
public virtual ByteArrayBuffer BufferByAddress(DefragmentServicesImpl.DbSelector selector, int address, int length) { return selector.Db(this).DecryptedBufferByAddress(address, length); }
internal virtual Db4objects.Db4o.Internal.Transaction Transaction(DefragmentServicesImpl context) { return(Db(context).SystemTransaction()); }
public _IVisitor4_244(DefragmentServicesImpl _enclosing, IDMappingCollector collector ) { this._enclosing = _enclosing; this.collector = collector; }
private Slot CommittedSlot(DefragmentServicesImpl.DbSelector selector, int id) { return selector.Db(this).IdSystem().CommittedSlot(id); }
public virtual IStoredClass[] StoredClasses(DefragmentServicesImpl.DbSelector selector ) { LocalObjectContainer db = selector.Db(this); db.ShowInternalClasses(true); try { return db.ClassCollection().StoredClasses(); } finally { db.ShowInternalClasses(false); } }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> public void ProcessClassCollection(DefragmentServicesImpl services) { DefragmentContextImpl.ProcessCopy(services, services.SourceClassCollectionID(), new _ISlotCopyHandler_59(services)); }
public virtual int DatabaseIdentityID(DefragmentServicesImpl.DbSelector selector) { LocalObjectContainer db = selector.Db(this); Db4oDatabase identity = db.Identity(); if (identity == null) { return 0; } return identity.GetID(selector.Transaction(this)); }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> private static void FirstPass(DefragmentServicesImpl context, DefragmentConfig config ) { // System.out.println("FIRST"); Pass(context, config, new FirstPassCommand()); }
internal virtual Db4objects.Db4o.Internal.Transaction Transaction(DefragmentServicesImpl context) { return Db(context).SystemTransaction(); }
internal override LocalObjectContainer Db(DefragmentServicesImpl context) { return context._targetDb; }
private static void ProcessObjectsForClass(DefragmentServicesImpl context, ClassMetadata curClass, IPassCommand command) { context.TraverseAll(curClass, new _IVisitor4_284(command, context, curClass)); }
/// <exception cref="Db4objects.Db4o.CorruptionException"></exception> /// <exception cref="System.IO.IOException"></exception> private static void SecondPass(DefragmentServicesImpl context, DefragmentConfig config ) { // System.out.println("SECOND"); Pass(context, config, new SecondPassCommand(config.ObjectCommitFrequency())); }
internal override LocalObjectContainer Db(DefragmentServicesImpl context) { return(context._targetDb); }