Ejemplo n.º 1
0
 private void CollectIndexedNodes(IEnumerator qcons)
 {
     while (qcons.MoveNext())
     {
         QCon qcon = (QCon)qcons.Current;
         if (IsCached(qcon))
         {
             continue;
         }
         if (IsLeaf(qcon))
         {
             if (qcon.CanLoadByIndex() && qcon.CanBeIndexLeaf())
             {
                 QConObject conObject = (QConObject)qcon;
                 if (conObject.HasJoins())
                 {
                     CollectJoinedNode(conObject);
                 }
                 else
                 {
                     CollectStandaloneNode(conObject);
                 }
             }
         }
         else
         {
             if (!qcon.HasJoins())
             {
                 CollectIndexedNodes(qcon.IterateChildren());
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void PrintQConObject(QConObject obj)
 {
     _builder.AppendFormat("({0} {1} {2})",
                           obj.GetField().Name(),
                           EvaluatorToString(obj.Evaluator()),
                           ValueToString(obj.GetObject()));
 }
Ejemplo n.º 3
0
        private Collection4 CollectTopLevelJoins(QConObject constraintWithJoins)
        {
            Collection4 joins = new Collection4();

            CollectTopLevelJoins(joins, constraintWithJoins);
            return(joins);
        }
Ejemplo n.º 4
0
 internal override bool Evaluate(QConObject a_constraint, QCandidate a_candidate,
                                 object a_value)
 {
     if (i_objectID == 0)
     {
         i_objectID = a_constraint.GetObjectID();
     }
     return(a_candidate._key == i_objectID);
 }
Ejemplo n.º 5
0
 internal override bool Evaluate(QConObject a_constraint, QCandidate a_candidate,
     object a_value)
 {
     if (i_objectID == 0)
     {
         i_objectID = a_constraint.GetObjectID();
     }
     return a_candidate._key == i_objectID;
 }
Ejemplo n.º 6
0
 public IndexedNodeBase(QConObject qcon)
 {
     if (null == qcon)
     {
         throw new ArgumentNullException();
     }
     if (null == qcon.GetField())
     {
         throw new ArgumentException();
     }
     _constraint = qcon;
 }
Ejemplo n.º 7
0
        private void CollectStandaloneNode(QConObject conObject)
        {
            IndexedLeaf existing = FindLeafOnSameField(conObject);

            if (existing != null)
            {
                CollectImplicitAnd(conObject, existing, new IndexedLeaf(conObject));
            }
            else
            {
                _nodes.Add(new IndexedLeaf(conObject));
            }
        }
Ejemplo n.º 8
0
 internal override bool Evaluate(QConObject constraint, QCandidate candidate, object
     obj)
 {
     if (obj == null)
     {
         return false;
     }
     var preparedComparison = constraint.PrepareComparison(candidate);
     if (preparedComparison is PreparedArrayContainsComparison)
     {
         return ((PreparedArrayContainsComparison) preparedComparison).IsGreaterThan(obj);
     }
     return preparedComparison.CompareTo(obj) > 0;
 }
Ejemplo n.º 9
0
 protected virtual void Visit(QConObject obj)
 {
     if (obj.HasJoins())
     {
         var constraints = obj.IterateJoins();
         while (constraints.MoveNext())
         {
             var constraint = (IConstraint)constraints.Current;
             Visit(constraint);
         }
         return;
     }
     PrintQConObject(obj);
 }
Ejemplo n.º 10
0
        private void CollectJoinedNode(QConObject constraintWithJoins)
        {
            Collection4 joins = CollectTopLevelJoins(constraintWithJoins);

            if (!CanJoinsBeSearchedByIndex(joins))
            {
                return;
            }
            if (1 == joins.Size())
            {
                _nodes.Add(NodeForConstraint((QCon)joins.SingleElement()));
                return;
            }
            CollectImplicitlyAndingJoins(joins, constraintWithJoins);
        }
Ejemplo n.º 11
0
        private void CollectImplicitlyAndingJoins(Collection4 joins, QConObject constraintWithJoins
                                                  )
        {
            IEnumerator i = joins.GetEnumerator();

            i.MoveNext();
            IIndexedNodeWithRange last = NodeForConstraint((QCon)i.Current);

            while (i.MoveNext())
            {
                IIndexedNodeWithRange node = NodeForConstraint((QCon)i.Current);
                last = new AndIndexedLeaf(constraintWithJoins, node, last);
                _nodes.Add(last);
            }
        }
Ejemplo n.º 12
0
        internal override bool Evaluate(QConObject constraint, QCandidate candidate, object
                                        obj)
        {
            if (obj == null)
            {
                return(false);
            }
            var preparedComparison = constraint.PrepareComparison(candidate);

            if (preparedComparison is PreparedArrayContainsComparison)
            {
                return(((PreparedArrayContainsComparison)preparedComparison).IsSmallerThan(obj));
            }
            return(preparedComparison.CompareTo(obj) < 0);
        }
Ejemplo n.º 13
0
        private IndexedLeaf FindLeafOnSameField(QConObject conObject)
        {
            IEnumerator i = _nodes.GetEnumerator();

            while (i.MoveNext())
            {
                if (i.Current is IndexedLeaf)
                {
                    IndexedLeaf leaf = (IndexedLeaf)i.Current;
                    if (conObject.OnSameFieldAs(leaf.Constraint()))
                    {
                        return(leaf);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 14
0
 internal override bool Evaluate(QConObject constraint, QCandidate candidate, object
     obj)
 {
     if (obj != null)
     {
         if (obj is ByteArrayBuffer)
         {
             obj = candidate.ReadString((ByteArrayBuffer) obj);
         }
         var candidateStringValue = obj.ToString();
         var stringConstraint = constraint.GetObject().ToString();
         if (!caseSensitive)
         {
             candidateStringValue = candidateStringValue.ToLower();
             stringConstraint = stringConstraint.ToLower();
         }
         return CompareStrings(candidateStringValue, stringConstraint);
     }
     return constraint.GetObject() == null;
 }
Ejemplo n.º 15
0
 internal override bool Evaluate(QConObject constraint, QCandidate candidate, object
                                 obj)
 {
     if (obj != null)
     {
         if (obj is ByteArrayBuffer)
         {
             obj = candidate.ReadString((ByteArrayBuffer)obj);
         }
         var candidateStringValue = obj.ToString();
         var stringConstraint     = constraint.GetObject().ToString();
         if (!caseSensitive)
         {
             candidateStringValue = candidateStringValue.ToLower();
             stringConstraint     = stringConstraint.ToLower();
         }
         return(CompareStrings(candidateStringValue, stringConstraint));
     }
     return(constraint.GetObject() == null);
 }
Ejemplo n.º 16
0
        internal virtual void CollectConstraints(Transaction trans, QConObject a_parent,
                                                 object a_template, IVisitor4 a_visitor)
        {
            object obj = GetOn(trans, a_template);

            if (obj != null)
            {
                Collection4 objs = Platform4.FlattenCollection(trans.Container(), obj);
                IEnumerator j    = objs.GetEnumerator();
                while (j.MoveNext())
                {
                    obj = j.Current;
                    if (obj != null)
                    {
                        if (_isPrimitive && !_isArray)
                        {
                            object nullValue = _reflectField.GetFieldType().NullValue();
                            if (obj.Equals(nullValue))
                            {
                                return;
                            }
                        }
                        if (Platform4.IgnoreAsConstraint(obj))
                        {
                            return;
                        }
                        if (!a_parent.HasObjectInParentPath(obj))
                        {
                            QConObject constraint = new QConObject(trans, a_parent, QField(trans), obj);
                            constraint.ByExample();
                            a_visitor.Visit(constraint);
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
 public IndexedPath(QConObject parent, IIndexedNode next) : base(parent)
 {
     _next = next;
 }
Ejemplo n.º 18
0
 public IndexedLeaf(QConObject qcon) : base(qcon)
 {
     _range = Search();
 }
Ejemplo n.º 19
0
 internal override bool Evaluate(QConObject a_constraint, QCandidate a_candidate,
                                 object a_value)
 {
     return(!i_evaluator.Evaluate(a_constraint, a_candidate, a_value));
 }
 internal override void CollectConstraints(Transaction a_trans, QConObject a_parent
                                           , object a_template, IVisitor4 a_visitor)
 {
 }
Ejemplo n.º 21
0
 internal override bool Evaluate(QConObject a_constraint, QCandidate a_candidate,
     object a_value)
 {
     return !i_evaluator.Evaluate(a_constraint, a_candidate, a_value);
 }