Exemplo n.º 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));
        }
Exemplo n.º 2
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);
		}
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 4
0
		internal override bool Evaluate(IInternalCandidate candidate)
		{
			if (!candidate.FieldIsAvailable())
			{
				VisitOnNull(candidate.GetRoot());
			}
			return true;
		}
Exemplo n.º 5
0
 internal override bool Evaluate(IInternalCandidate candidate)
 {
     if (!candidate.FieldIsAvailable())
     {
         VisitOnNull(candidate.GetRoot());
     }
     return(true);
 }
Exemplo n.º 6
0
 private ITypeHandler4 TypeHandlerFor(IInternalCandidate candidate)
 {
     Db4objects.Db4o.Internal.ClassMetadata classMetadata = candidate.ClassMetadata();
     if (classMetadata != null)
     {
         return(classMetadata.TypeHandler());
     }
     return(null);
 }
Exemplo n.º 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);
 }
Exemplo n.º 8
0
 internal virtual IPreparedComparison PrepareComparison(IInternalCandidate candidate
                                                        )
 {
     if (_preparedComparison != null)
     {
         return(_preparedComparison);
     }
     return(candidate.PrepareComparison(Container(), i_object));
 }
Exemplo n.º 9
0
        public virtual void Visit(object a_tree)
        {
            IInternalCandidate candidate = (IInternalCandidate)a_tree;

            if (candidate.Include())
            {
                AddKeyCheckDuplicates(candidate.Id());
            }
        }
Exemplo n.º 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;
		}
Exemplo n.º 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);
        }
Exemplo n.º 12
0
 internal override bool Evaluate(IInternalCandidate candidate)
 {
     try
     {
         return(candidate.Evaluate(this, i_evaluator));
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemplo n.º 13
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;
		}
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
		}
Exemplo n.º 17
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;
		}
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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));
            }
Exemplo n.º 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());
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
		}
Exemplo n.º 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);
 }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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());
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 29
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);
				}
			}
		}
Exemplo n.º 30
0
		public virtual void Root(IInternalCandidate root)
		{
			_root = root;
		}
Exemplo n.º 31
0
        public virtual void Visit(object obj)
        {
            IInternalCandidate candidate = (IInternalCandidate)obj;

            Visit1(candidate.GetRoot(), this, Evaluate(candidate));
        }
Exemplo n.º 32
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());
			}
		}
Exemplo n.º 33
0
		internal virtual void Visit(IInternalCandidate root, bool res)
		{
			Visit1(root, this, i_evaluator.Not(res));
		}
Exemplo n.º 34
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();
			}
		}
Exemplo n.º 35
0
		internal override bool Evaluate(IInternalCandidate candidate)
		{
			try
			{
				return candidate.Evaluate(this, i_evaluator);
			}
			catch (Exception e)
			{
				return false;
			}
		}
Exemplo n.º 36
0
		internal virtual IPreparedComparison PrepareComparison(IInternalCandidate candidate
			)
		{
			if (_preparedComparison != null)
			{
				return _preparedComparison;
			}
			return candidate.PrepareComparison(Container(), i_object);
		}
Exemplo n.º 37
0
		public virtual void Add(IInternalCandidate candidate)
		{
			ToQCandidates();
			_candidates = ((QCandidateBase)Tree.Add(_candidates, (QCandidateBase)candidate));
		}
Exemplo n.º 38
0
 public virtual void Add(IInternalCandidate candidate)
 {
     ToQCandidates();
     _candidates = ((QCandidateBase)Tree.Add(_candidates, (QCandidateBase)candidate));
 }
Exemplo n.º 39
0
		internal override bool Evaluate(IInternalCandidate a_candidate)
		{
			return _value;
		}
Exemplo n.º 40
0
 /// <param name="candidate"></param>
 internal virtual bool Evaluate(IInternalCandidate candidate)
 {
     throw Exceptions4.VirtualException();
 }
Exemplo n.º 41
0
		public override Tree OnAttemptToAddDuplicate(Tree oldNode)
		{
			_size = 0;
			_root = (IInternalCandidate)oldNode;
			return oldNode;
		}
Exemplo n.º 42
0
		private void ForceActivation(IInternalCandidate candidate)
		{
			candidate.GetObject();
		}
Exemplo n.º 43
0
		internal override void DoNotInclude(IInternalCandidate root)
		{
			Constraint1().DoNotInclude(root);
			Constraint2().DoNotInclude(root);
		}
Exemplo n.º 44
0
 internal override void DoNotInclude(IInternalCandidate root)
 {
     Constraint1().DoNotInclude(root);
     Constraint2().DoNotInclude(root);
 }
Exemplo n.º 45
0
 protected virtual void AddDependant(IInternalCandidate a_candidate)
 {
     _dependants = new List4(_dependants, a_candidate);
 }
Exemplo n.º 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));
 }
Exemplo n.º 47
0
 public virtual void Root(IInternalCandidate root)
 {
     _root = root;
 }
Exemplo n.º 48
0
		/// <param name="candidate"></param>
		internal virtual bool Evaluate(IInternalCandidate candidate)
		{
			throw Exceptions4.VirtualException();
		}
Exemplo n.º 49
0
 private void ForceActivation(IInternalCandidate candidate)
 {
     candidate.GetObject();
 }
Exemplo n.º 50
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);
				}
			}
		}
Exemplo n.º 51
0
		protected virtual void AddDependant(IInternalCandidate a_candidate)
		{
			_dependants = new List4(_dependants, a_candidate);
		}
Exemplo n.º 52
0
		internal override bool Evaluate(QConObject a_constraint, IInternalCandidate a_candidate
			, object a_value)
		{
			return !i_evaluator.Evaluate(a_constraint, a_candidate, a_value);
		}
Exemplo n.º 53
0
 internal virtual void Visit(IInternalCandidate root, bool res)
 {
     Visit1(root, this, i_evaluator.Not(res));
 }