예제 #1
0
        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));
        }
예제 #2
0
파일: QConClass.cs 프로젝트: superyfwy/db4o
		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);
		}
예제 #3
0
        internal virtual void EvaluatePending(IInternalCandidate root, QPending pending,
                                              int secondResult)
        {
            bool res = i_evaluator.Not(i_and ? ((pending._result + secondResult) > 0) : (pending
                                                                                         ._result + 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;
                    root.Evaluate(new QPending(qcj, this, res));
                }
            }
            else
            {
                if (!res)
                {
                    Constraint1().DoNotInclude(root);
                    Constraint2().DoNotInclude(root);
                }
            }
        }
예제 #4
0
파일: QConPath.cs 프로젝트: Galigator/db4o
		internal override bool Evaluate(IInternalCandidate candidate)
		{
			if (!candidate.FieldIsAvailable())
			{
				VisitOnNull(candidate.GetRoot());
			}
			return true;
		}
예제 #5
0
 internal override bool Evaluate(IInternalCandidate candidate)
 {
     if (!candidate.FieldIsAvailable())
     {
         VisitOnNull(candidate.GetRoot());
     }
     return(true);
 }
예제 #6
0
 private ITypeHandler4 TypeHandlerFor(IInternalCandidate candidate)
 {
     Db4objects.Db4o.Internal.ClassMetadata classMetadata = candidate.ClassMetadata();
     if (classMetadata != null)
     {
         return(classMetadata.TypeHandler());
     }
     return(null);
 }
예제 #7
0
 internal override bool Evaluate(QConObject a_constraint, IInternalCandidate a_candidate
                                 , object a_value)
 {
     if (i_objectID == 0)
     {
         i_objectID = a_constraint.GetObjectID();
     }
     return(a_candidate.Id() == i_objectID);
 }
예제 #8
0
 internal virtual IPreparedComparison PrepareComparison(IInternalCandidate candidate
                                                        )
 {
     if (_preparedComparison != null)
     {
         return(_preparedComparison);
     }
     return(candidate.PrepareComparison(Container(), i_object));
 }
예제 #9
0
        public virtual void Visit(object a_tree)
        {
            IInternalCandidate candidate = (IInternalCandidate)a_tree;

            if (candidate.Include())
            {
                AddKeyCheckDuplicates(candidate.Id());
            }
        }
예제 #10
0
		internal override bool Evaluate(QConObject a_constraint, IInternalCandidate a_candidate
			, object a_value)
		{
			if (i_objectID == 0)
			{
				i_objectID = a_constraint.GetObjectID();
			}
			return a_candidate.Id() == i_objectID;
		}
예제 #11
0
        public virtual bool CreateChild(QField field, QCandidates candidates)
        {
            if (!_include)
            {
                return(false);
            }
            UseField(field);
            if (_fieldMetadata == null || _fieldMetadata is NullFieldMetadata)
            {
                return(false);
            }
            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)
                {
                    return(CreateChildForDescendable(candidates, handler, queryingReadContext, arrayElementHandler
                                                     ));
                }
                // 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))
                {
                    candidates._currentConstraint.Visit(this);
                    return(true);
                }
            }
            _classMetadata.SeekToField(Transaction(), _bytes, _fieldMetadata);
            IInternalCandidate candidate = ReadSubCandidate(candidates);

            if (candidate == null)
            {
                return(false);
            }
            // fast early check for ClassMetadata
            if (candidates._classMetadata != null && candidates._classMetadata.IsStronglyTyped
                    ())
            {
                if (Handlers4.IsUntyped(handler))
                {
                    handler = TypeHandlerFor(candidate);
                }
                if (handler == null)
                {
                    return(false);
                }
            }
            AddDependant(candidates.Add(candidate));
            return(true);
        }
예제 #12
0
 internal override bool Evaluate(IInternalCandidate candidate)
 {
     try
     {
         return(candidate.Evaluate(this, i_evaluator));
     }
     catch (Exception e)
     {
         return(false);
     }
 }
예제 #13
0
파일: QEMulti.cs 프로젝트: superyfwy/db4o
		internal override bool Evaluate(QConObject a_constraint, IInternalCandidate a_candidate
			, object a_value)
		{
			IEnumerator i = i_evaluators.GetEnumerator();
			while (i.MoveNext())
			{
				if (((QE)i.Current).Evaluate(a_constraint, a_candidate, a_value))
				{
					return true;
				}
			}
			return false;
		}
예제 #14
0
 public IInternalCandidate Add(IInternalCandidate candidate)
 {
     _result.Add(candidate);
     if (((QCandidateBase)candidate)._size == 0)
     {
         // This means that the candidate was already present
         // and QCandidate does not allow duplicates.
         // In this case QCandidate#isDuplicateOf will have
         // placed the existing QCandidate in the i_root
         // variable of the new candidate. We return it here:
         return(candidate.GetRoot());
     }
     return(candidate);
 }
예제 #15
0
        internal override bool Evaluate(QConObject a_constraint, IInternalCandidate a_candidate
                                        , object a_value)
        {
            IEnumerator i = i_evaluators.GetEnumerator();

            while (i.MoveNext())
            {
                if (((QE)i.Current).Evaluate(a_constraint, a_candidate, a_value))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #16
0
		public IInternalCandidate Add(IInternalCandidate candidate)
		{
			_result.Add(candidate);
			if (((QCandidateBase)candidate)._size == 0)
			{
				// This means that the candidate was already present
				// and QCandidate does not allow duplicates.
				// In this case QCandidate#isDuplicateOf will have
				// placed the existing QCandidate in the i_root
				// variable of the new candidate. We return it here: 
				return candidate.GetRoot();
			}
			return candidate;
		}
예제 #17
0
파일: QESmaller.cs 프로젝트: superyfwy/db4o
		internal override bool Evaluate(QConObject constraint, IInternalCandidate candidate
			, object obj)
		{
			if (obj == null)
			{
				return false;
			}
			IPreparedComparison preparedComparison = constraint.PrepareComparison(candidate);
			if (preparedComparison is PreparedArrayContainsComparison)
			{
				return ((PreparedArrayContainsComparison)preparedComparison).IsGreaterThan(obj);
			}
			return preparedComparison.CompareTo(obj) > 0;
		}
예제 #18
0
        internal virtual bool Evaluate(QConObject constraint, IInternalCandidate candidate
                                       , object obj)
        {
            IPreparedComparison prepareComparison = constraint.PrepareComparison(candidate);

            if (obj == null)
            {
                return(prepareComparison is Null);
            }
            if (prepareComparison is PreparedArrayContainsComparison)
            {
                return(((PreparedArrayContainsComparison)prepareComparison).IsEqual(obj));
            }
            return(prepareComparison.CompareTo(obj) == 0);
        }
예제 #19
0
        internal override bool Evaluate(QConObject constraint, IInternalCandidate candidate
                                        , object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            IPreparedComparison preparedComparison = constraint.PrepareComparison(candidate);

            if (preparedComparison is PreparedArrayContainsComparison)
            {
                return(((PreparedArrayContainsComparison)preparedComparison).IsGreaterThan(obj));
            }
            return(preparedComparison.CompareTo(obj) > 0);
        }
예제 #20
0
 internal virtual void DoNotInclude(IInternalCandidate root)
 {
     if (DTrace.enabled)
     {
         DTrace.Donotinclude.Log(Id());
     }
     if (i_parent != null)
     {
         i_parent.Visit1(root, this, false);
     }
     else
     {
         root.DoNotInclude();
     }
 }
예제 #21
0
            public void Visit(object obj)
            {
                IInternalCandidate cand = (IInternalCandidate)obj;

                if (cand.Include())
                {
                    _innerRes.value = !_isNot;
                }
                // Collect all pending subresults.
                if (cand.PendingJoins() == null)
                {
                    return;
                }
                cand.PendingJoins().Traverse(new _IVisitor4_529(this));
            }
예제 #22
0
        internal void VisitOnNull(IInternalCandidate a_root)
        {
            // TODO: It may be more efficient to rule out
            // all possible keepOnNull issues when starting
            // evaluation.
            IEnumerator i = IterateChildren();

            while (i.MoveNext())
            {
                ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).VisitOnNull(a_root);
            }
            if (VisitSelfOnNull())
            {
                Visit(a_root, IsNullConstraint());
            }
        }
예제 #23
0
        public override void Visit(object obj)
        {
            IInternalCandidate qc = (IInternalCandidate)obj;
            bool res       = true;
            bool processed = false;

            if (_checkClassMetadataOnly)
            {
                ClassMetadata yc = qc.ClassMetadata();
                if (yc != null)
                {
                    res       = i_evaluator.Not(_classMetadata.GetHigherHierarchy(yc) == _classMetadata);
                    processed = true;
                }
            }
            if (!processed)
            {
                res = Evaluate(qc);
            }
            Visit1(qc.GetRoot(), this, res);
        }
예제 #24
0
		internal override bool Evaluate(QConObject constraint, IInternalCandidate candidate
			, object obj)
		{
			if (obj != null)
			{
				if (obj is ByteArrayBuffer)
				{
					obj = StringHandler.ReadString(candidate.Transaction().Context(), (ByteArrayBuffer
						)obj);
				}
				string candidateStringValue = obj.ToString();
				string stringConstraint = constraint.GetObject().ToString();
				if (!caseSensitive)
				{
					candidateStringValue = candidateStringValue.ToLower();
					stringConstraint = stringConstraint.ToLower();
				}
				return CompareStrings(candidateStringValue, stringConstraint);
			}
			return constraint.GetObject() == null;
		}
예제 #25
0
 internal override bool Evaluate(QConObject constraint, IInternalCandidate candidate
                                 , object obj)
 {
     if (obj != null)
     {
         if (obj is ByteArrayBuffer)
         {
             obj = StringHandler.ReadString(candidate.Transaction().Context(), (ByteArrayBuffer
                                                                                )obj);
         }
         string candidateStringValue = obj.ToString();
         string stringConstraint     = constraint.GetObject().ToString();
         if (!caseSensitive)
         {
             candidateStringValue = candidateStringValue.ToLower();
             stringConstraint     = stringConstraint.ToLower();
         }
         return(CompareStrings(candidateStringValue, stringConstraint));
     }
     return(constraint.GetObject() == null);
 }
예제 #26
0
 internal virtual void Visit1(IInternalCandidate 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);
         }
     }
 }
예제 #27
0
        public override void Visit(object obj)
        {
            IInternalCandidate candidate = (IInternalCandidate)obj;

            // force activation outside the try block
            // so any activation errors bubble up
            ForceActivation(candidate);
            try
            {
                Platform4.EvaluationEvaluate(i_evaluation, candidate);
            }
            catch (Exception)
            {
                candidate.Include(false);
            }
            // TODO: implement Exception callback for the user coder
            // at least for test cases
            if (!candidate.Include())
            {
                DoNotInclude(candidate.GetRoot());
            }
        }
예제 #28
0
        private IInternalCandidate ReadSubCandidate(QCandidates candidateCollection)
        {
            Read();
            if (_bytes == null || _fieldMetadata == null)
            {
                return(null);
            }
            int offset = CurrentOffSet();
            QueryingReadContext context = NewQueryingReadContext();
            ITypeHandler4       handler = HandlerRegistry.CorrectHandlerVersion(context, _fieldMetadata
                                                                                .GetHandler());
            IInternalCandidate subCandidate = candidateCollection.ReadSubCandidate(context, handler
                                                                                   );

            Seek(offset);
            if (subCandidate != null)
            {
                subCandidate.Root(GetRoot());
                return(subCandidate);
            }
            return(null);
        }
예제 #29
0
파일: QConJoin.cs 프로젝트: superyfwy/db4o
		internal virtual void EvaluatePending(IInternalCandidate root, QPending pending, 
			int secondResult)
		{
			bool res = i_evaluator.Not(i_and ? ((pending._result + secondResult) > 0) : (pending
				._result + 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;
					root.Evaluate(new QPending(qcj, this, res));
				}
			}
			else
			{
				if (!res)
				{
					Constraint1().DoNotInclude(root);
					Constraint2().DoNotInclude(root);
				}
			}
		}
예제 #30
0
		public virtual void Root(IInternalCandidate root)
		{
			_root = root;
		}
예제 #31
0
        public virtual void Visit(object obj)
        {
            IInternalCandidate candidate = (IInternalCandidate)obj;

            Visit1(candidate.GetRoot(), this, Evaluate(candidate));
        }
예제 #32
0
파일: QCon.cs 프로젝트: Galigator/db4o
		internal void VisitOnNull(IInternalCandidate a_root)
		{
			// TODO: It may be more efficient to rule out 
			// all possible keepOnNull issues when starting
			// evaluation.
			IEnumerator i = IterateChildren();
			while (i.MoveNext())
			{
				((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).VisitOnNull(a_root);
			}
			if (VisitSelfOnNull())
			{
				Visit(a_root, IsNullConstraint());
			}
		}
예제 #33
0
파일: QCon.cs 프로젝트: Galigator/db4o
		internal virtual void Visit(IInternalCandidate root, bool res)
		{
			Visit1(root, this, i_evaluator.Not(res));
		}
예제 #34
0
파일: QCon.cs 프로젝트: Galigator/db4o
		internal virtual void DoNotInclude(IInternalCandidate root)
		{
			if (DTrace.enabled)
			{
				DTrace.Donotinclude.Log(Id());
			}
			if (i_parent != null)
			{
				i_parent.Visit1(root, this, false);
			}
			else
			{
				root.DoNotInclude();
			}
		}
예제 #35
0
		internal override bool Evaluate(IInternalCandidate candidate)
		{
			try
			{
				return candidate.Evaluate(this, i_evaluator);
			}
			catch (Exception e)
			{
				return false;
			}
		}
예제 #36
0
		internal virtual IPreparedComparison PrepareComparison(IInternalCandidate candidate
			)
		{
			if (_preparedComparison != null)
			{
				return _preparedComparison;
			}
			return candidate.PrepareComparison(Container(), i_object);
		}
예제 #37
0
		public virtual void Add(IInternalCandidate candidate)
		{
			ToQCandidates();
			_candidates = ((QCandidateBase)Tree.Add(_candidates, (QCandidateBase)candidate));
		}
예제 #38
0
 public virtual void Add(IInternalCandidate candidate)
 {
     ToQCandidates();
     _candidates = ((QCandidateBase)Tree.Add(_candidates, (QCandidateBase)candidate));
 }
예제 #39
0
		internal override bool Evaluate(IInternalCandidate a_candidate)
		{
			return _value;
		}
예제 #40
0
 /// <param name="candidate"></param>
 internal virtual bool Evaluate(IInternalCandidate candidate)
 {
     throw Exceptions4.VirtualException();
 }
예제 #41
0
		public override Tree OnAttemptToAddDuplicate(Tree oldNode)
		{
			_size = 0;
			_root = (IInternalCandidate)oldNode;
			return oldNode;
		}
예제 #42
0
		private void ForceActivation(IInternalCandidate candidate)
		{
			candidate.GetObject();
		}
예제 #43
0
파일: QConJoin.cs 프로젝트: superyfwy/db4o
		internal override void DoNotInclude(IInternalCandidate root)
		{
			Constraint1().DoNotInclude(root);
			Constraint2().DoNotInclude(root);
		}
예제 #44
0
 internal override void DoNotInclude(IInternalCandidate root)
 {
     Constraint1().DoNotInclude(root);
     Constraint2().DoNotInclude(root);
 }
예제 #45
0
 protected virtual void AddDependant(IInternalCandidate a_candidate)
 {
     _dependants = new List4(_dependants, a_candidate);
 }
예제 #46
0
 internal override bool Evaluate(QConObject a_constraint, IInternalCandidate a_candidate
                                 , object a_value)
 {
     return(!i_evaluator.Evaluate(a_constraint, a_candidate, a_value));
 }
예제 #47
0
 public virtual void Root(IInternalCandidate root)
 {
     _root = root;
 }
예제 #48
0
파일: QCon.cs 프로젝트: Galigator/db4o
		/// <param name="candidate"></param>
		internal virtual bool Evaluate(IInternalCandidate candidate)
		{
			throw Exceptions4.VirtualException();
		}
예제 #49
0
 private void ForceActivation(IInternalCandidate candidate)
 {
     candidate.GetObject();
 }
예제 #50
0
파일: QCon.cs 프로젝트: Galigator/db4o
		internal virtual void Visit1(IInternalCandidate 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);
				}
			}
		}
예제 #51
0
		protected virtual void AddDependant(IInternalCandidate a_candidate)
		{
			_dependants = new List4(_dependants, a_candidate);
		}
예제 #52
0
파일: QENot.cs 프로젝트: superyfwy/db4o
		internal override bool Evaluate(QConObject a_constraint, IInternalCandidate a_candidate
			, object a_value)
		{
			return !i_evaluator.Evaluate(a_constraint, a_candidate, a_value);
		}
예제 #53
0
 internal virtual void Visit(IInternalCandidate root, bool res)
 {
     Visit1(root, this, i_evaluator.Not(res));
 }