internal override bool Evaluate(IInternalCandidate candidate) { bool result = true; QCandidates qCandidates = candidate.Candidates(); if (qCandidates.IsTopLevel() && qCandidates.WasLoadedFromClassFieldIndex()) { if (_classMetadata.GetAncestor() != null) { BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)_classMetadata.Index(); if (index == null) { return(i_evaluator.Not(true)); } BTree btree = index.Btree(); object searchResult = btree.Search(candidate.Transaction(), candidate.Id()); result = searchResult != null; } } else { IReflectClass claxx = candidate.ClassMetadata().ClassReflector(); if (claxx == null) { result = false; } else { result = i_equal ? _claxx.Equals(claxx) : _claxx.IsAssignableFrom(claxx); } } return(i_evaluator.Not(result)); }
/// <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); } }
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); }
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 BTree Btree(ClassMetadata clazz) { return(BTreeClassIndexStrategy.Btree(clazz)); }