示例#1
0
		internal QConClass(Transaction trans, QCon parent, QField field, IReflectClass claxx
			) : base(trans, parent, field, null)
		{
			// C/S
			if (claxx != null)
			{
				ObjectContainerBase container = trans.Container();
				_classMetadata = container.ClassMetadataForReflectClass(claxx);
				if (_classMetadata == null)
				{
					// could be an aliased class, try to resolve.
					string className = claxx.GetName();
					string aliasRunTimeName = container.Config().ResolveAliasStoredName(className);
					if (!className.Equals(aliasRunTimeName))
					{
						_classMetadata = container.ClassMetadataForName(aliasRunTimeName);
					}
				}
				if (claxx.Equals(container._handlers.IclassObject))
				{
					_classMetadata = (ClassMetadata)_classMetadata.TypeHandler();
				}
			}
			_claxx = claxx;
		}
示例#2
0
        public bool FitsIntoExistingConstraintHierarchy(QCon constraint)
        {
            if (_field != null)
            {
                QField qf = constraint.GetField();
                if (qf != null)
                {
                    if (_field.Name() != null && !_field.Name().Equals(qf.Name()))
                    {
                        return(false);
                    }
                }
            }
            if (i_classMetadata == null || constraint.IsNullConstraint())
            {
                return(true);
            }
            ClassMetadata classMetadata = constraint.GetYapClass();

            if (classMetadata == null)
            {
                return(false);
            }
            classMetadata = i_classMetadata.GetHigherOrCommonHierarchy(classMetadata);
            if (classMetadata == null)
            {
                return(false);
            }
            i_classMetadata = classMetadata;
            return(true);
        }
示例#3
0
 internal QConClass(Transaction trans, QCon parent, QField field, IReflectClass claxx
                    ) : base(trans, parent, field, null)
 {
     // C/S
     if (claxx != null)
     {
         ObjectContainerBase container = trans.Container();
         _classMetadata = container.ClassMetadataForReflectClass(claxx);
         if (_classMetadata == null)
         {
             // could be an aliased class, try to resolve.
             string className        = claxx.GetName();
             string aliasRunTimeName = container.Config().ResolveAliasStoredName(className);
             if (!className.Equals(aliasRunTimeName))
             {
                 _classMetadata = container.ClassMetadataForName(aliasRunTimeName);
             }
         }
         if (claxx.Equals(container._handlers.IclassObject))
         {
             _classMetadata = (ClassMetadata)_classMetadata.TypeHandler();
         }
     }
     _claxx = claxx;
 }
示例#4
0
            public void Apply(object arg)
            {
                QCon qCon = (QCon)arg;

                qCon.SetCandidates(this._enclosing);
                qCon.EvaluateSelf();
            }
示例#5
0
        public virtual QQueryBase.CreateCandidateCollectionResult CreateCandidateCollection
            ()
        {
            List4       candidatesList  = CreateQCandidatesList();
            bool        checkDuplicates = false;
            bool        topLevel        = true;
            IEnumerator i = IterateConstraints();

            while (i.MoveNext())
            {
                QCon constraint = (QCon)i.Current;
                QCon old        = constraint;
                constraint = constraint.GetRoot();
                if (constraint != old)
                {
                    checkDuplicates = true;
                    topLevel        = false;
                }
                ClassMetadata classMetadata = constraint.GetYapClass();
                if (classMetadata == null)
                {
                    break;
                }
                AddConstraintToCandidatesList(candidatesList, constraint);
            }
            return(new QQueryBase.CreateCandidateCollectionResult(candidatesList, checkDuplicates
                                                                  , topLevel));
        }
示例#6
0
            public object Apply(object obj)
            {
                QCon constr = (QCon)obj;

                constr.i_joins = null;
                return(false);
            }
示例#7
0
        private bool ForEachConstraintRecursively(IFunction4 block)
        {
            IQueue4     queue      = new NoDuplicatesQueue(new NonblockingQueue());
            IEnumerator constrIter = IterateConstraints();

            while (constrIter.MoveNext())
            {
                queue.Add(constrIter.Current);
            }
            while (queue.HasNext())
            {
                QCon constr = (QCon)queue.Next();
                bool cancel = (bool)block.Apply(constr);
                if (cancel)
                {
                    return(true);
                }
                IEnumerator childIter = constr.IterateChildren();
                while (childIter.MoveNext())
                {
                    queue.Add(childIter.Current);
                }
                IEnumerator joinIter = constr.IterateJoins();
                while (joinIter.MoveNext())
                {
                    queue.Add(joinIter.Current);
                }
            }
            return(false);
        }
示例#8
0
        private bool AttachToExistingConstraints(Collection4 newConstraintsCollector, object
                                                 obj, bool onlyForPaths)
        {
            bool        found = false;
            IEnumerator j     = IterateConstraints();

            while (j.MoveNext())
            {
                QCon         existingConstraint = (QCon)j.Current;
                BooleanByRef removeExisting     = new BooleanByRef(false);
                if (!onlyForPaths || (existingConstraint is QConPath))
                {
                    QCon newConstraint = existingConstraint.ShareParent(obj, removeExisting);
                    if (newConstraint != null)
                    {
                        newConstraintsCollector.Add(newConstraint);
                        AddConstraint(newConstraint);
                        if (removeExisting.value)
                        {
                            RemoveConstraint(existingConstraint);
                        }
                        found = true;
                        if (!onlyForPaths)
                        {
                            break;
                        }
                    }
                }
            }
            return(found);
        }
示例#9
0
        // FIXME: This method should go completely.
        //        We changed the code to create the QCandidates graph in two steps:
        //        (1) call fitsIntoExistingConstraintHierarchy to determine whether
        //            or not we need more QCandidates objects
        //        (2) add all constraints
        //        This method tries to do both in one, which results in missing
        //        constraints. Not all are added to all QCandiates.
        //        Right methodology is in
        //        QQueryBase#createCandidateCollection
        //        and
        //        QQueryBase#createQCandidatesList
        internal bool TryAddConstraint(QCon a_constraint)
        {
            if (_field != null)
            {
                QField qf = a_constraint.GetField();
                if (qf != null)
                {
                    if (_field.Name() != null && !_field.Name().Equals(qf.Name()))
                    {
                        return(false);
                    }
                }
            }
            if (i_classMetadata == null || a_constraint.IsNullConstraint())
            {
                AddConstraint(a_constraint);
                return(true);
            }
            ClassMetadata yc = a_constraint.GetYapClass();

            if (yc != null)
            {
                yc = i_classMetadata.GetHigherOrCommonHierarchy(yc);
                if (yc != null)
                {
                    i_classMetadata = yc;
                    AddConstraint(a_constraint);
                    return(true);
                }
            }
            AddConstraint(a_constraint);
            return(false);
        }
示例#10
0
文件: QPending.cs 项目: masroore/db4o
 internal QPending(QConJoin a_join, QCon a_constraint, bool a_firstResult)
 {
     // Constants, so QConJoin.evaluatePending is made easy:
     _join = a_join;
     _constraint = a_constraint;
     _result = a_firstResult ? True : False;
 }
示例#11
0
 internal QPending(QConJoin a_join, QCon a_constraint, bool a_firstResult)
 {
     // Constants, so QConJoin.evaluatePending is made easy:
     _join       = a_join;
     _constraint = a_constraint;
     _result     = a_firstResult ? True : False;
 }
示例#12
0
 public override bool OnSameFieldAs(QCon other)
 {
     if (!(other is Db4objects.Db4o.Internal.Query.Processor.QConObject))
     {
         return(false);
     }
     return(i_field == ((Db4objects.Db4o.Internal.Query.Processor.QConObject)other).i_field);
 }
示例#13
0
		internal QConPath(Transaction a_trans, QCon a_parent, QField a_field) : base(a_trans
			, a_parent, a_field, null)
		{
			if (a_field != null)
			{
				_classMetadata = a_field.GetFieldType();
			}
		}
示例#14
0
 internal QConPath(Transaction a_trans, QCon a_parent, QField a_field) : base(a_trans
                                                                              , a_parent, a_field, null)
 {
     if (a_field != null)
     {
         _classMetadata = a_field.GetFieldType();
     }
 }
示例#15
0
 public override bool OnSameFieldAs(QCon other)
 {
     if (!(other is QConObject))
     {
         return(false);
     }
     return(i_field == ((QConObject)other).i_field);
 }
示例#16
0
        private bool CreateChildForDescendable(QCandidates parentCandidates, ITypeHandler4
                                               handler, QueryingReadContext queryingReadContext, ITypeHandler4 arrayElementHandler
                                               )
        {
            int  offset   = queryingReadContext.Offset();
            bool outerRes = true;
            // The following construct is worse than not ideal. For each constraint it completely reads the
            // underlying structure again. The structure could be kept fairly easy. TODO: Optimize!
            IEnumerator i = parentCandidates.IterateConstraints();

            while (i.MoveNext())
            {
                QCon   qcon = (QCon)i.Current;
                QField qf   = qcon.GetField();
                if (qf != null && !qf.Name().Equals(_fieldMetadata.GetName()))
                {
                    continue;
                }
                QCon tempParent = qcon.Parent();
                qcon.SetParent(null);
                QCandidates candidates = new QCandidates(parentCandidates.i_trans, null, qf, false
                                                         );
                candidates.AddConstraint(qcon);
                qcon.SetCandidates(candidates);
                ReadArrayCandidates(handler, queryingReadContext.Buffer(), arrayElementHandler, candidates
                                    );
                queryingReadContext.Seek(offset);
                bool isNot = qcon.IsNot();
                if (isNot)
                {
                    qcon.RemoveNot();
                }
                candidates.Evaluate();
                ByRef        pending  = ByRef.NewInstance();
                BooleanByRef innerRes = new BooleanByRef(isNot);
                candidates.Traverse(new QCandidate.CreateDescendChildTraversingVisitor(pending, innerRes
                                                                                       , isNot));
                if (isNot)
                {
                    qcon.Not();
                }
                // In case we had pending subresults, we need to communicate them up to our root.
                if (((Tree)pending.value) != null)
                {
                    ((Tree)pending.value).Traverse(new _IVisitor4_168(this));
                }
                if (!innerRes.value)
                {
                    // Again this could be double triggering.
                    //
                    // We want to clean up the "No route" at some stage.
                    qcon.Visit(GetRoot(), qcon.Evaluator().Not(false));
                    outerRes = false;
                }
                qcon.SetParent(tempParent);
            }
            return(outerRes);
        }
示例#17
0
		internal QConJoin(Transaction a_trans, QCon a_c1, QCon a_c2, bool a_and) : base(a_trans
			)
		{
			// FIELDS MUST BE PUBLIC TO BE REFLECTED ON UNDER JDK <= 1.1
			// C/S
			i_constraint1 = a_c1;
			i_constraint2 = a_c2;
			i_and = a_and;
		}
示例#18
0
 public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint)
 {
     if (!CanFollowParent(constraint))
     {
         return null;
     }
     return new IndexedPath((QConObject) constraint
         .Parent(), next);
 }
示例#19
0
		public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint)
		{
			if (!CanFollowParent(constraint))
			{
				return null;
			}
			return new Db4objects.Db4o.Internal.Fieldindex.IndexedPath((QConObject)constraint
				.Parent(), next);
		}
示例#20
0
 internal QConJoin(Transaction a_trans, QCon a_c1, QCon a_c2, bool a_and) : base(a_trans
                                                                                 )
 {
     // FIELDS MUST BE PUBLIC TO BE REFLECTED ON UNDER JDK <= 1.1
     // C/S
     i_constraint1 = a_c1;
     i_constraint2 = a_c2;
     i_and         = a_and;
 }
示例#21
0
		private static FieldMetadata GetYapField(QCon con)
		{
			QField field = con.GetField();
			if (null == field)
			{
				return null;
			}
			return field.GetFieldMetadata();
		}
示例#22
0
        internal virtual bool Attach(QQuery query, string a_field)
        {
            Db4objects.Db4o.Internal.Query.Processor.QCon qcon = this;
            ClassMetadata yc = GetYapClass();

            bool[] foundField = new bool[] { false };
            ForEachChildField(a_field, new _IVisitor4_101(foundField, query));
            if (foundField[0])
            {
                return(true);
            }
            QField qf = null;

            if (yc == null || yc.HoldsAnyClass())
            {
                int[]           count = new int[] { 0 };
                FieldMetadata[] yfs   = new FieldMetadata[] { null };
                i_trans.Container().ClassCollection().AttachQueryNode(a_field, new _IVisitor4_119
                                                                          (yfs, count));
                if (count[0] == 0)
                {
                    return(false);
                }
                if (count[0] == 1)
                {
                    qf = yfs[0].QField(i_trans);
                }
                else
                {
                    qf = new QField(i_trans, a_field, null, 0, 0);
                }
            }
            else
            {
                if (yc.IsTranslated())
                {
                    i_trans.Container()._handlers.DiagnosticProcessor().DescendIntoTranslator(yc, a_field
                                                                                              );
                }
                FieldMetadata yf = yc.FieldMetadataForName(a_field);
                if (yf != null)
                {
                    qf = yf.QField(i_trans);
                }
                if (qf == null)
                {
                    qf = new QField(i_trans, a_field, null, 0, 0);
                }
            }
            QConPath qcp = new QConPath(i_trans, qcon, qf);

            query.AddConstraint(qcp);
            qcon.AddConstraint(qcp);
            return(true);
        }
示例#23
0
		public JoinedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IBTreeRange range
			)
		{
			if (null == constraint || null == leaf1 || null == range)
			{
				throw new ArgumentNullException();
			}
			_constraint = constraint;
			_leaf1 = leaf1;
			_range = range;
		}
示例#24
0
文件: QConJoin.cs 项目: pondyond/db4o
 public virtual QCon GetOtherConstraint(QCon a_constraint)
 {
     if (a_constraint == Constraint1())
     {
         return(Constraint2());
     }
     if (a_constraint == Constraint2())
     {
         return(Constraint1());
     }
     throw new ArgumentException();
 }
示例#25
0
 internal virtual bool RemoveForParent(QCon a_constraint)
 {
     if (i_and)
     {
         QCon other = GetOtherConstraint(a_constraint);
         other.RemoveJoin(this);
         // prevents circular call
         other.Remove();
         return(true);
     }
     return(false);
 }
示例#26
0
		internal override void ExchangeConstraint(QCon a_exchange, QCon a_with)
		{
			base.ExchangeConstraint(a_exchange, a_with);
			if (a_exchange == Constraint1())
			{
				i_constraint1 = a_with;
			}
			if (a_exchange == Constraint2())
			{
				i_constraint2 = a_with;
			}
		}
示例#27
0
 internal override void ExchangeConstraint(QCon a_exchange, QCon a_with)
 {
     base.ExchangeConstraint(a_exchange, a_with);
     if (a_exchange == Constraint1())
     {
         i_constraint1 = a_with;
     }
     if (a_exchange == Constraint2())
     {
         i_constraint2 = a_with;
     }
 }
示例#28
0
        internal void Collect(Db4objects.Db4o.Internal.Query.Processor.QCandidates a_candidates
                              )
        {
            IEnumerator i = IterateConstraints();

            while (i.MoveNext())
            {
                QCon qCon = (QCon)i.Current;
                SetCurrentConstraint(qCon);
                qCon.Collect(a_candidates);
            }
            SetCurrentConstraint(null);
        }
示例#29
0
        private void ForEachConstraint(IProcedure4 proc)
        {
            IEnumerator i = IterateConstraints();

            while (i.MoveNext())
            {
                QCon constraint = (QCon)i.Current;
                if (!constraint.ProcessedByIndex())
                {
                    proc.Apply(constraint);
                }
            }
        }
示例#30
0
        private void AddConstraintToCandidatesList(List4 candidatesList, QCon qcon)
        {
            if (candidatesList == null)
            {
                return;
            }
            IEnumerator j = new Iterator4Impl(candidatesList);

            while (j.MoveNext())
            {
                QCandidates candidates = (QCandidates)j.Current;
                candidates.AddConstraint(qcon);
            }
        }
示例#31
0
		internal QConClass(Transaction a_trans, QCon a_parent, QField a_field, IReflectClass
			 claxx) : base(a_trans, a_parent, a_field, null)
		{
			// C/S
			if (claxx != null)
			{
				_classMetadata = a_trans.Container().ProduceClassMetadata(claxx);
				if (claxx.Equals(a_trans.Container()._handlers.IclassObject))
				{
					_classMetadata = (ClassMetadata)_classMetadata.TypeHandler();
				}
			}
			_claxx = claxx;
		}
示例#32
0
 internal QConClass(Transaction a_trans, QCon a_parent, QField a_field, IReflectClass
                    claxx) : base(a_trans, a_parent, a_field, null)
 {
     // C/S
     if (claxx != null)
     {
         _classMetadata = a_trans.Container().ProduceClassMetadata(claxx);
         if (claxx.Equals(a_trans.Container()._handlers.IclassObject))
         {
             _classMetadata = (ClassMetadata)_classMetadata.TypeHandler();
         }
     }
     _claxx = claxx;
 }
示例#33
0
            public object Apply(object obj)
            {
                QCon        constr   = (QCon)obj;
                IEnumerator joinIter = constr.IterateJoins();

                while (joinIter.MoveNext())
                {
                    QConJoin join = (QConJoin)joinIter.Current;
                    if (join.IsOr())
                    {
                        return(true);
                    }
                }
                return(false);
            }
示例#34
0
        private bool ConstraintCanBeAddedToExisting(List4 candidatesList, QCon constraint
                                                    )
        {
            IEnumerator j = new Iterator4Impl(candidatesList);

            while (j.MoveNext())
            {
                QCandidates candidates = (QCandidates)j.Current;
                if (candidates.FitsIntoExistingConstraintHierarchy(constraint))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#35
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("QQueryBase\n");
            IEnumerator i = IterateConstraints();

            while (i.MoveNext())
            {
                QCon constraint = (QCon)i.Current;
                sb.Append(constraint);
                sb.Append("\n");
            }
            return(sb.ToString());
        }
示例#36
0
        internal virtual void EvaluateCreateChildrenCandidates()
        {
            i_childrenCandidates = new Collection4();
            IEnumerator i = IterateChildren();

            while (i.MoveNext())
            {
                Db4objects.Db4o.Internal.Query.Processor.QCon constraint = (Db4objects.Db4o.Internal.Query.Processor.QCon
                                                                            )i.Current;
                if (!constraint.ResolvedByIndex())
                {
                    constraint.CreateCandidates(i_childrenCandidates);
                }
            }
        }
示例#37
0
        // Our QConPath objects are just placeholders to fields,
        // so the parents are reachable.
        // If we find a "real" constraint, we throw the QPath
        // out and replace it with the other constraint.
        private void Morph(BooleanByRef removeExisting, QCon newConstraint, IReflectClass
                           claxx)
        {
            bool mayMorph = true;

            if (claxx != null)
            {
                ClassMetadata yc = i_trans.Container().ProduceClassMetadata(claxx);
                if (yc != null)
                {
                    IEnumerator i = IterateChildren();
                    while (i.MoveNext())
                    {
                        QField qf = ((QCon)i.Current).GetField();
                        if (!yc.HasField(i_trans.Container(), qf.Name()))
                        {
                            mayMorph = false;
                            break;
                        }
                    }
                }
            }
            // }
            if (mayMorph)
            {
                IEnumerator j = IterateChildren();
                while (j.MoveNext())
                {
                    newConstraint.AddConstraint((QCon)j.Current);
                }
                if (HasJoins())
                {
                    IEnumerator k = IterateJoins();
                    while (k.MoveNext())
                    {
                        QConJoin qcj = (QConJoin)k.Current;
                        qcj.ExchangeConstraint(this, newConstraint);
                        newConstraint.AddJoin(qcj);
                    }
                }
                i_parent.ExchangeConstraint(this, newConstraint);
                removeExisting.value = true;
            }
            else
            {
                i_parent.AddConstraint(newConstraint);
            }
        }
		private bool HasJoins(QCon con)
		{
			if (con.HasJoins())
			{
				return true;
			}
			IEnumerator childIter = con.IterateChildren();
			while (childIter.MoveNext())
			{
				if (HasJoins((QCon)childIter.Current))
				{
					return true;
				}
			}
			return false;
		}
示例#39
0
		public QConObject(Transaction a_trans, QCon a_parent, QField a_field, object a_object
			) : base(a_trans)
		{
			// the constraining object
			// cache for the db4o object ID
			// the YapClass
			// needed for marshalling the request
			// C/S only
			i_parent = a_parent;
			if (a_object is ICompare)
			{
				a_object = ((ICompare)a_object).Compare();
			}
			i_object = a_object;
			i_field = a_field;
		}
示例#40
0
		private static bool CanFollowParent(QCon con)
		{
			QCon parent = con.Parent();
			FieldMetadata parentField = GetYapField(parent);
			if (null == parentField)
			{
				return false;
			}
			FieldMetadata conField = GetYapField(con);
			if (null == conField)
			{
				return false;
			}
			return parentField.HasIndex() && parentField.FieldType().IsAssignableFrom(conField
				.ContainingClass());
		}
示例#41
0
 public QConObject(Transaction a_trans, QCon a_parent, QField a_field, object a_object
                   ) : base(a_trans)
 {
     // the constraining object
     // cache for the db4o object ID
     // the YapClass
     // needed for marshalling the request
     // C/S only
     i_parent = a_parent;
     if (a_object is ICompare)
     {
         a_object = ((ICompare)a_object).Compare();
     }
     i_object = a_object;
     i_field  = a_field;
 }
示例#42
0
        internal virtual void EvaluateSimpleChildren()
        {
            // TODO: sort the constraints for YapFields first,
            // so we stay with the same YapField
            if (_children == null)
            {
                return;
            }
            IEnumerator i = IterateChildren();

            while (i.MoveNext())
            {
                Db4objects.Db4o.Internal.Query.Processor.QCon qcon = (Db4objects.Db4o.Internal.Query.Processor.QCon
                                                                      )i.Current;
                i_candidates.SetCurrentConstraint(qcon);
                qcon.SetCandidates(i_candidates);
                qcon.EvaluateSimpleExec(i_candidates);
            }
            i_candidates.SetCurrentConstraint(null);
        }
示例#43
0
 internal virtual void Visit1(QCandidate root, Db4objects.Db4o.Internal.Query.Processor.QCon
                              reason, bool res)
 {
     // The a_reason parameter makes it eays to distinguish
     // between calls from above (a_reason == this) and below.
     if (HasJoins())
     {
         // this should probably be on the Join
         IEnumerator i = IterateJoins();
         while (i.MoveNext())
         {
             root.Evaluate(new QPending((QConJoin)i.Current, this, res));
         }
     }
     else
     {
         if (!res)
         {
             DoNotInclude(root);
         }
     }
 }
示例#44
0
		private void CollectLeavesFromJoinConstraint(Collection4 leaves, QCon constraint)
		{
			if (constraint is QConJoin)
			{
				CollectLeavesFromJoin(leaves, (QConJoin)constraint);
			}
			else
			{
				if (!leaves.ContainsByIdentity(constraint))
				{
					leaves.Add(constraint);
				}
			}
		}
示例#45
0
		private void CollectTopLevelJoins(Collection4 joins, QCon constraintWithJoins)
		{
			IEnumerator i = constraintWithJoins.IterateJoins();
			while (i.MoveNext())
			{
				QConJoin join = (QConJoin)i.Current;
				if (!join.HasJoins())
				{
					if (!joins.ContainsByIdentity(join))
					{
						joins.Add(join);
					}
				}
				else
				{
					CollectTopLevelJoins(joins, join);
				}
			}
		}
示例#46
0
		// Our QConPath objects are just placeholders to fields,
		// so the parents are reachable.
		// If we find a "real" constraint, we throw the QPath
		// out and replace it with the other constraint. 
		private void Morph(BooleanByRef removeExisting, QCon newConstraint, IReflectClass
			 claxx)
		{
			bool mayMorph = true;
			if (claxx != null)
			{
				ClassMetadata yc = i_trans.Container().ProduceClassMetadata(claxx);
				if (yc != null)
				{
					IEnumerator i = IterateChildren();
					while (i.MoveNext())
					{
						QField qf = ((QCon)i.Current).GetField();
						if (!yc.HasField(i_trans.Container(), qf.Name()))
						{
							mayMorph = false;
							break;
						}
					}
				}
			}
			// }
			if (mayMorph)
			{
				IEnumerator j = IterateChildren();
				while (j.MoveNext())
				{
					newConstraint.AddConstraint((QCon)j.Current);
				}
				if (HasJoins())
				{
					IEnumerator k = IterateJoins();
					while (k.MoveNext())
					{
						QConJoin qcj = (QConJoin)k.Current;
						qcj.ExchangeConstraint(this, newConstraint);
						newConstraint.AddJoin(qcj);
					}
				}
				i_parent.ExchangeConstraint(this, newConstraint);
				removeExisting.value = true;
			}
			else
			{
				i_parent.AddConstraint(newConstraint);
			}
		}
示例#47
0
		private IIndexedNodeWithRange NodeForConstraint(QCon con)
		{
			IIndexedNodeWithRange node = (IIndexedNodeWithRange)_nodeCache.Get(con);
			if (null != node || _nodeCache.ContainsKey(con))
			{
				return node;
			}
			node = NewNodeForConstraint(con);
			_nodeCache.Put(con, node);
			return node;
		}
示例#48
0
		private IIndexedNodeWithRange NewNodeForConstraint(QCon con)
		{
			if (con is QConJoin)
			{
				return NewNodeForConstraint((QConJoin)con);
			}
			return new IndexedLeaf((QConObject)con);
		}
示例#49
0
		private void CollectImplicitAnd(QCon constraint, IIndexedNodeWithRange x, IIndexedNodeWithRange
			 y)
		{
			_nodes.Remove(x);
			_nodes.Remove(y);
			_nodes.Add(new AndIndexedLeaf(constraint, x, y));
		}
示例#50
0
		internal void AddConstraint(QCon a_constraint)
		{
			_constraints = new List4(_constraints, a_constraint);
		}
示例#51
0
		public virtual QCon GetOtherConstraint(QCon a_constraint)
		{
			if (a_constraint == Constraint1())
			{
				return Constraint2();
			}
			else
			{
				if (a_constraint == Constraint2())
				{
					return Constraint1();
				}
			}
			throw new ArgumentException();
		}
示例#52
0
		internal virtual bool RemoveForParent(QCon a_constraint)
		{
			if (i_and)
			{
				QCon other = GetOtherConstraint(a_constraint);
				other.RemoveJoin(this);
				// prevents circular call
				other.Remove();
				return true;
			}
			return false;
		}
示例#53
0
文件: QPending.cs 项目: masroore/db4o
 internal virtual void ChangeConstraint()
 {
     _constraint = _join.GetOtherConstraint(_constraint);
 }
示例#54
0
文件: QCon.cs 项目: Galigator/db4o
		internal virtual void SetParent(Db4objects.Db4o.Internal.Query.Processor.QCon a_newParent
			)
		{
			i_parent = a_newParent;
		}
示例#55
0
		private bool HaveSamePath(QCon x, QCon y)
		{
			if (x == y)
			{
				return true;
			}
			if (!x.OnSameFieldAs(y))
			{
				return false;
			}
			if (!x.HasParent())
			{
				return !y.HasParent();
			}
			return HaveSamePath(x.Parent(), y.Parent());
		}
示例#56
0
		private bool IsLeaf(QCon qcon)
		{
			return !qcon.HasChildren();
		}
示例#57
0
		internal void SetCurrentConstraint(QCon a_constraint)
		{
			i_currentConstraint = a_constraint;
		}
示例#58
0
		public bool FitsIntoExistingConstraintHierarchy(QCon constraint)
		{
			if (_field != null)
			{
				QField qf = constraint.GetField();
				if (qf != null)
				{
					if (_field.Name() != null && !_field.Name().Equals(qf.Name()))
					{
						return false;
					}
				}
			}
			if (i_classMetadata == null || constraint.IsNullConstraint())
			{
				return true;
			}
			ClassMetadata classMetadata = constraint.GetYapClass();
			if (classMetadata == null)
			{
				return false;
			}
			classMetadata = i_classMetadata.GetHigherOrCommonHierarchy(classMetadata);
			if (classMetadata == null)
			{
				return false;
			}
			i_classMetadata = classMetadata;
			return true;
		}
示例#59
0
		public AndIndexedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IIndexedNodeWithRange
			 leaf2) : base(constraint, leaf1, leaf1.GetRange().Intersect(leaf2.GetRange()))
		{
		}
示例#60
0
		// FIXME: This method should go completely.
		//        We changed the code to create the QCandidates graph in two steps:
		//        (1) call fitsIntoExistingConstraintHierarchy to determine whether
		//            or not we need more QCandidates objects
		//        (2) add all constraints
		//        This method tries to do both in one, which results in missing
		//        constraints. Not all are added to all QCandiates.
		//        Right methodology is in 
		//        QQueryBase#createCandidateCollection
		//        and
		//        QQueryBase#createQCandidatesList
		internal bool TryAddConstraint(QCon a_constraint)
		{
			if (_field != null)
			{
				QField qf = a_constraint.GetField();
				if (qf != null)
				{
					if (_field.Name() != null && !_field.Name().Equals(qf.Name()))
					{
						return false;
					}
				}
			}
			if (i_classMetadata == null || a_constraint.IsNullConstraint())
			{
				AddConstraint(a_constraint);
				return true;
			}
			ClassMetadata yc = a_constraint.GetYapClass();
			if (yc != null)
			{
				yc = i_classMetadata.GetHigherOrCommonHierarchy(yc);
				if (yc != null)
				{
					i_classMetadata = yc;
					AddConstraint(a_constraint);
					return true;
				}
			}
			AddConstraint(a_constraint);
			return false;
		}