コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: IndexedPath.cs プロジェクト: Galigator/db4o
		private static FieldMetadata GetYapField(QCon con)
		{
			QField field = con.GetField();
			if (null == field)
			{
				return null;
			}
			return field.GetFieldMetadata();
		}
コード例 #5
0
ファイル: QCandidates.cs プロジェクト: bvangrinsven/db4o-net
		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;
		}
コード例 #6
0
ファイル: QCandidates.cs プロジェクト: bvangrinsven/db4o-net
		// 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;
		}
コード例 #7
0
 internal virtual bool CreateChild(QCandidates a_candidates)
 {
     if (!_include)
     {
         return(false);
     }
     if (_fieldMetadata != null)
     {
         ITypeHandler4 handler = _fieldMetadata.GetHandler();
         if (handler != null)
         {
             QueryingReadContext queryingReadContext = new QueryingReadContext(Transaction(),
                                                                               MarshallerFamily().HandlerVersion(), _bytes, _key);
             ITypeHandler4 arrayElementHandler = Handlers4.ArrayElementHandler(handler, queryingReadContext
                                                                               );
             if (arrayElementHandler != null)
             {
                 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 b
                 // kept fairly easy. TODO: Optimize!
                 IEnumerator i = a_candidates.IterateConstraints();
                 while (i.MoveNext())
                 {
                     QCon   qcon = (QCon)i.Current;
                     QField qf   = qcon.GetField();
                     if (qf == null || qf.Name().Equals(_fieldMetadata.GetName()))
                     {
                         QCon tempParent = qcon.Parent();
                         qcon.SetParent(null);
                         QCandidates candidates = new QCandidates(a_candidates.i_trans, null, qf);
                         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();
                         bool[] innerRes = new bool[] { isNot };
                         candidates.Traverse(new _IVisitor4_160(innerRes, isNot, pending));
                         // Collect all pending subresults.
                         // We need to change
                         // the
                         // constraint here, so
                         // our
                         // pending collector
                         // uses
                         // the right
                         // comparator.
                         // We only keep one
                         // pending result
                         // for
                         // all array
                         // elements.
                         // and memorize,
                         // whether we had a
                         // true or a false
                         // result.
                         // or both.
                         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_229(this));
                         }
                         if (!innerRes[0])
                         {
                             // 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);
             }
             // We may get simple types here too, if the YapField was null
             // in the higher level simple evaluation. Evaluate these
             // immediately.
             if (Handlers4.IsQueryLeaf(handler))
             {
                 a_candidates.i_currentConstraint.Visit(this);
                 return(true);
             }
         }
     }
     if (_fieldMetadata == null)
     {
         return(false);
     }
     if (_fieldMetadata is NullFieldMetadata)
     {
         return(false);
     }
     _classMetadata.SeekToField(Transaction(), _bytes, _fieldMetadata);
     Db4objects.Db4o.Internal.Query.Processor.QCandidate candidate = ReadSubCandidate(
         a_candidates);
     if (candidate == null)
     {
         return(false);
     }
     // fast early check for ClassMetadata
     if (a_candidates.i_classMetadata != null && a_candidates.i_classMetadata.IsStronglyTyped
             ())
     {
         ITypeHandler4 handler = _fieldMetadata.GetHandler();
         if (Handlers4.IsUntyped(handler))
         {
             handler = TypeHandlerFor(candidate);
         }
         if (handler == null)
         {
             return(false);
         }
     }
     AddDependant(a_candidates.Add(candidate));
     return(true);
 }