public static Sharpen.Util.ISet BuildHierarchy(ClassMetadataRepository repository ) { ClassMetadataIterator classIter = repository.Iterator(); IDictionary nodes = new Hashtable(); Sharpen.Util.ISet roots = new HashSet(); while (classIter.MoveNext()) { Db4objects.Db4o.Internal.ClassMetadata clazz = classIter.CurrentClass(); Db4objects.Db4o.Filestats.ClassNode node = new Db4objects.Db4o.Filestats.ClassNode (clazz); nodes[clazz.GetName()] = node; if (clazz.GetAncestor() == null) { roots.Add(node); } } for (IEnumerator nodeIter = nodes.Values.GetEnumerator(); nodeIter.MoveNext();) { Db4objects.Db4o.Filestats.ClassNode node = ((Db4objects.Db4o.Filestats.ClassNode) nodeIter.Current); Db4objects.Db4o.Internal.ClassMetadata ancestor = node.ClassMetadata().GetAncestor (); if (ancestor != null) { ((Db4objects.Db4o.Filestats.ClassNode)nodes[ancestor.GetName()]).AddSubClass(node ); } } return(roots); }
private static void ReindexDateTimeFields(ConversionStage stage) { var reindexer = new FieldReindexer <DateTime>(); ClassMetadataIterator i = stage.File().ClassCollection().Iterator(); while (i.MoveNext()) { ClassMetadata classmetadata = i.CurrentClass(); classmetadata.TraverseDeclaredFields(reindexer); } }
private IList CheckFieldIndices() { IList invalidIds = new ArrayList(); ClassMetadataIterator clazzIter = _db.ClassCollection().Iterator(); while (clazzIter.MoveNext()) { ClassMetadata clazz = clazzIter.CurrentClass(); clazz.TraverseDeclaredFields(new _IProcedure4_159(this, invalidIds, clazz)); } return(invalidIds); }
public static IDictionary TypesFor(LocalObjectContainer db, Sharpen.Util.ISet ids ) { IDictionary id2clazzes = new Hashtable(); ClassMetadataIterator iter = db.ClassCollection().Iterator(); while (iter.MoveNext()) { for (IEnumerator idIter = ids.GetEnumerator(); idIter.MoveNext();) { int id = ((int)idIter.Current); ClassMetadata clazz = iter.CurrentClass(); BTree btree = BTreeClassIndexStrategy.Btree(clazz); if (btree.Search(db.SystemTransaction(), id) != null) { Sharpen.Util.ISet clazzes = ((Sharpen.Util.ISet)id2clazzes[id]); if (clazzes == null) { clazzes = new HashSet(); id2clazzes[id] = clazzes; } clazzes.Add(clazz); } } } IDictionary id2clazz = new Hashtable(); for (IEnumerator idIter = id2clazzes.Keys.GetEnumerator(); idIter.MoveNext();) { int id = ((int)idIter.Current); Sharpen.Util.ISet clazzes = ((Sharpen.Util.ISet)id2clazzes[id]); ClassMetadata mostSpecific = null; for (IEnumerator curClazzIter = clazzes.GetEnumerator(); curClazzIter.MoveNext();) { ClassMetadata curClazz = ((ClassMetadata)curClazzIter.Current); for (IEnumerator cmpClazzIter = clazzes.GetEnumerator(); cmpClazzIter.MoveNext();) { ClassMetadata cmpClazz = ((ClassMetadata)cmpClazzIter.Current); if (curClazz.Equals(cmpClazz._ancestor)) { goto OUTER_continue; } } mostSpecific = curClazz; break; OUTER_continue :; } OUTER_break :; id2clazz[id] = mostSpecific; } return(id2clazz); }
private void RebuildUUIDIndex(LocalObjectContainer file) { UUIDFieldMetadata uuid = file.UUIDIndex(); ClassMetadataIterator i = file.ClassCollection().Iterator(); while (i.MoveNext()) { ClassMetadata clazz = i.CurrentClass(); if (clazz.GenerateUUIDs()) { uuid.RebuildIndexForClass(file, clazz); } } }
public override void Convert(ConversionStage.SystemUpStage stage) { LocalObjectContainer file = stage.File(); ClassMetadataIterator i = file.ClassCollection().Iterator(); while (i.MoveNext()) { ClassMetadata classmetadata = i.CurrentClass(); if (Accept(classmetadata)) { classmetadata.DropClassIndex(); } } }
private void BuildCommitTimestampIndex(LocalObjectContainer container) { versionFieldMetadata = container.Handlers.Indexes()._version; ClassMetadataIterator i = container.ClassCollection().Iterator(); while (i.MoveNext()) { ClassMetadata clazz = i.CurrentClass(); if (clazz.HasVersionField() && !clazz.IsStruct()) { RebuildIndexForClass(container, clazz); } } }
public override void LoadFromClassIndexes(ClassMetadataIterator iter) { // duplicates because of inheritance hierarchies ByRef duplicates = new ByRef(); while (iter.MoveNext()) { ClassMetadata classMetadata = iter.CurrentClass(); if (classMetadata.GetName() != null) { IReflectClass claxx = classMetadata.ClassReflector(); if (claxx == null || !(Stream()._handlers.IclassInternal.IsAssignableFrom(claxx))) { IClassIndexStrategy index = classMetadata.Index(); index.TraverseAll(_transaction, new _IVisitor4_130(this, duplicates)); } } } }
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); }
private IList CheckClassIndices() { IList invalidIds = new ArrayList(); IIdSystem idSystem = _db.IdSystem(); if (!(idSystem is BTreeIdSystem)) { return(invalidIds); } ClassMetadataIterator clazzIter = _db.ClassCollection().Iterator(); while (clazzIter.MoveNext()) { ClassMetadata clazz = clazzIter.CurrentClass(); if (!clazz.HasClassIndex()) { continue; } BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)clazz.Index(); index.TraverseAll(_db.SystemTransaction(), new _IVisitor4_143(this, invalidIds, clazz )); } return(invalidIds); }
public override void LoadFromClassIndexes(ClassMetadataIterator iter) { // duplicates because of inheritance hierarchies var duplicates = new ByRef(); while (iter.MoveNext()) { var classMetadata = iter.CurrentClass(); if (classMetadata.GetName() != null) { var claxx = classMetadata.ClassReflector(); if (claxx == null || !(Stream()._handlers.IclassInternal.IsAssignableFrom(claxx))) { var index = classMetadata.Index(); index.TraverseAll(_transaction, new _IVisitor4_130(this, duplicates)); } } } }