示例#1
0
        internal virtual void EvaluatePending(QCandidate a_root, QPending a_pending, int
                                              a_secondResult)
        {
            bool res = i_evaluator.Not(i_and ? ((a_pending._result + a_secondResult) > 0) : (
                                           a_pending._result + a_secondResult) > QPending.False);

            if (HasJoins())
            {
                IEnumerator i = IterateJoins();
                while (i.MoveNext())
                {
                    Db4objects.Db4o.Internal.Query.Processor.QConJoin qcj = (Db4objects.Db4o.Internal.Query.Processor.QConJoin
                                                                             )i.Current;
                    a_root.Evaluate(new QPending(qcj, this, res));
                }
            }
            else
            {
                if (!res)
                {
                    Constraint1().DoNotInclude(a_root);
                    Constraint2().DoNotInclude(a_root);
                }
            }
        }
示例#2
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;
 }
示例#3
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;
 }
示例#4
0
文件: QCon.cs 项目: Galigator/db4o
		internal virtual void AddJoin(QConJoin a_join)
		{
			if (i_joins == null)
			{
				i_joins = new Collection4();
			}
			i_joins.Add(a_join);
		}
示例#5
0
 internal virtual void AddJoin(QConJoin a_join)
 {
     if (i_joins == null)
     {
         i_joins = new Collection4();
     }
     i_joins.Add(a_join);
 }
示例#6
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);
            }
示例#7
0
        private Collection4 CollectJoinsToBeRemoved()
        {
            Collection4 toBeRemoved = new Collection4();
            IEnumerator joinIter    = IterateJoins();

            while (joinIter.MoveNext())
            {
                QConJoin join = (QConJoin)joinIter.Current;
                if (join.RemoveForParent(this))
                {
                    toBeRemoved.Add(join);
                }
            }
            return(toBeRemoved);
        }
示例#8
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);
            }
        }
示例#9
0
        internal virtual IConstraint Join1(QCon
                                           a_with, bool a_and)
        {
            if (a_with is QConstraints)
            {
                var j           = 0;
                var joinHooks   = new Collection4();
                var constraints = ((QConstraints)a_with).ToArray();
                for (j = 0; j < constraints.Length; j++)
                {
                    joinHooks.Ensure(((QCon)constraints[j]).
                                     JoinHook());
                }
                var joins = new IConstraint[joinHooks.Size()];
                j = 0;
                var i = joinHooks.GetEnumerator();
                while (i.MoveNext())
                {
                    joins[j++] = Join((IConstraint)i.Current, a_and);
                }
                return(new QConstraints(i_trans, joins));
            }
            var myHook    = JoinHook();
            var otherHook = a_with.JoinHook();

            if (myHook == otherHook)
            {
                // You might like to check out, what happens, if you
                // remove this line. It seems to open a bug in an
                // StOr testcase.
                return(myHook);
            }
            var cj = new QConJoin(i_trans, myHook, otherHook, a_and);

            myHook.AddJoin(cj);
            otherHook.AddJoin(cj);
            return(cj);
        }
示例#10
0
文件: QCon.cs 项目: Galigator/db4o
		internal virtual IConstraint Join1(Db4objects.Db4o.Internal.Query.Processor.QCon 
			a_with, bool a_and)
		{
			if (a_with is QConstraints)
			{
				int j = 0;
				Collection4 joinHooks = new Collection4();
				IConstraint[] constraints = ((QConstraints)a_with).ToArray();
				for (j = 0; j < constraints.Length; j++)
				{
					joinHooks.Ensure(((Db4objects.Db4o.Internal.Query.Processor.QCon)constraints[j]).
						JoinHook());
				}
				IConstraint[] joins = new IConstraint[joinHooks.Size()];
				j = 0;
				IEnumerator i = joinHooks.GetEnumerator();
				while (i.MoveNext())
				{
					joins[j++] = Join((IConstraint)i.Current, a_and);
				}
				return new QConstraints(i_trans, joins);
			}
			Db4objects.Db4o.Internal.Query.Processor.QCon myHook = JoinHook();
			Db4objects.Db4o.Internal.Query.Processor.QCon otherHook = a_with.JoinHook();
			if (myHook == otherHook)
			{
				// You might like to check out, what happens, if you
				// remove this line. It seems to open a bug in an
				// StOr testcase.
				return myHook;
			}
			QConJoin cj = new QConJoin(i_trans, myHook, otherHook, a_and);
			myHook.AddJoin(cj);
			otherHook.AddJoin(cj);
			return cj;
		}
示例#11
0
		private QCon FindLeafForJoin(QConJoin join)
		{
			if (join.Constraint1() is QConObject)
			{
				return join.Constraint1();
			}
			QCon con = join.Constraint2();
			if (con is QConObject)
			{
				return con;
			}
			return FindLeafForJoin((QConJoin)con);
		}
示例#12
0
		private IIndexedNodeWithRange NewNodeForConstraint(QConJoin join)
		{
			IIndexedNodeWithRange c1 = NodeForConstraint(join.Constraint1());
			IIndexedNodeWithRange c2 = NodeForConstraint(join.Constraint2());
			if (join.IsOr())
			{
				return new OrIndexedLeaf(FindLeafForJoin(join), c1, c2);
			}
			return new AndIndexedLeaf(join.Constraint1(), c1, c2);
		}
示例#13
0
		private void CollectLeavesFromJoin(Collection4 leaves, QConJoin join)
		{
			CollectLeavesFromJoinConstraint(leaves, join.Constraint1());
			CollectLeavesFromJoinConstraint(leaves, join.Constraint2());
		}
示例#14
0
 internal virtual void RemoveJoin(QConJoin a_join)
 {
     i_joins.Remove(a_join);
     CheckLastJoinRemoved();
 }
示例#15
0
		internal virtual void RemoveJoin(QConJoin a_join)
		{
			i_joins.Remove(a_join);
			CheckLastJoinRemoved();
		}