Exemplo 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());
             }
         }
     }
 }
Exemplo n.º 2
0
 private void CollectImplicitAnd(QCon constraint, IIndexedNodeWithRange x, IIndexedNodeWithRange
                                 y)
 {
     _nodes.Remove(x);
     _nodes.Remove(y);
     _nodes.Add(new AndIndexedLeaf(constraint, x, y));
 }
Exemplo n.º 3
0
 private IIndexedNodeWithRange NewNodeForConstraint(QCon con)
 {
     if (con is QConJoin)
     {
         return(NewNodeForConstraint((QConJoin)con));
     }
     return(new IndexedLeaf((QConObject)con));
 }
Exemplo n.º 4
0
 public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint)
 {
     if (!CanFollowParent(constraint))
     {
         return(null);
     }
     return(new Db4objects.Db4o.Internal.Fieldindex.IndexedPath((QConObject)constraint
                                                                .Parent(), next));
 }
Exemplo n.º 5
0
 public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint)
 {
     if (!CanFollowParent(constraint))
     {
         return(null);
     }
     return(new IndexedPath((QConObject)constraint
                            .Parent(), next));
 }
Exemplo n.º 6
0
        private static FieldMetadata GetYapField(QCon con)
        {
            QField field = con.GetField();

            if (null == field)
            {
                return(null);
            }
            return(field.GetFieldMetadata());
        }
Exemplo n.º 7
0
 public JoinedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IBTreeRange range
                   )
 {
     if (null == constraint || null == leaf1 || null == range)
     {
         throw new ArgumentNullException();
     }
     _constraint = constraint;
     _leaf1      = leaf1;
     _range      = range;
 }
Exemplo n.º 8
0
        private IIndexedNodeWithRange NodeForConstraint(QCon con)
        {
            IIndexedNodeWithRange node = (IIndexedNodeWithRange)_nodeCache.Get(con);

            if (null != node || _nodeCache.ContainsKey(con))
            {
                return(node);
            }
            node = NewNodeForConstraint(con);
            _nodeCache.Put(con, node);
            return(node);
        }
Exemplo n.º 9
0
 private void CollectLeavesFromJoinConstraint(Collection4 leaves, QCon constraint)
 {
     if (constraint is QConJoin)
     {
         CollectLeavesFromJoin(leaves, (QConJoin)constraint);
     }
     else
     {
         if (!leaves.ContainsByIdentity(constraint))
         {
             leaves.Add(constraint);
         }
     }
 }
Exemplo n.º 10
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));
        }
Exemplo n.º 11
0
        private bool AllCanBeSearchedByIndex(Collection4 leaves)
        {
            IEnumerator i = leaves.GetEnumerator();

            while (i.MoveNext())
            {
                QCon leaf = ((QCon)i.Current);
                if (!leaf.CanLoadByIndex())
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 12
0
        private void VisitJoinBranch(QCon branch)
        {
            if (branch is QConJoin)
            {
                Visit(branch as QConJoin);
                return;
            }

            if (branch is QConObject)
            {
                PrintQConObject(branch as QConObject);
                return;
            }

            throw new NotSupportedException();
        }
Exemplo n.º 13
0
        private bool AllHaveSamePath(Collection4 leaves)
        {
            IEnumerator i = leaves.GetEnumerator();

            i.MoveNext();
            QCon first = (QCon)i.Current;

            while (i.MoveNext())
            {
                if (!HaveSamePath(first, (QCon)i.Current))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 14
0
 private bool HaveSamePath(QCon x, QCon y)
 {
     if (x == y)
     {
         return(true);
     }
     if (!x.OnSameFieldAs(y))
     {
         return(false);
     }
     if (!x.HasParent())
     {
         return(!y.HasParent());
     }
     return(HaveSamePath(x.Parent(), y.Parent()));
 }
Exemplo n.º 15
0
        private bool HasJoins(QCon con)
        {
            if (con.HasJoins())
            {
                return(true);
            }
            IEnumerator childIter = con.IterateChildren();

            while (childIter.MoveNext())
            {
                if (HasJoins((QCon)childIter.Current))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 16
0
        private static bool CanFollowParent(QCon con)
        {
            QCon          parent      = con.Parent();
            FieldMetadata parentField = GetYapField(parent);

            if (null == parentField)
            {
                return(false);
            }
            FieldMetadata conField = GetYapField(con);

            if (null == conField)
            {
                return(false);
            }
            return(parentField.HasIndex() && parentField.FieldType().IsAssignableFrom(conField
                                                                                      .ContainingClass()));
        }
Exemplo n.º 17
0
        private void CollectTopLevelJoins(Collection4 joins, QCon constraintWithJoins)
        {
            IEnumerator i = constraintWithJoins.IterateJoins();

            while (i.MoveNext())
            {
                QConJoin join = (QConJoin)i.Current;
                if (!join.HasJoins())
                {
                    if (!joins.ContainsByIdentity(join))
                    {
                        joins.Add(join);
                    }
                }
                else
                {
                    CollectTopLevelJoins(joins, join);
                }
            }
        }
Exemplo n.º 18
0
 public OrIndexedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IIndexedNodeWithRange
                      leaf2) : base(constraint, leaf1, leaf1.GetRange().Union(leaf2.GetRange()))
 {
 }
Exemplo n.º 19
0
 private bool IsCached(QCon qcon)
 {
     return(null != _nodeCache.Get(qcon));
 }
Exemplo n.º 20
0
 public AndIndexedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IIndexedNodeWithRange
                       leaf2) : base(constraint, leaf1, leaf1.GetRange().Intersect(leaf2.GetRange()))
 {
 }
Exemplo n.º 21
0
 private void VisitAllChildrenOf(QCon path)
 {
     VisitAll(Iterators.Iterable(path.IterateChildren()).Cast <IConstraint>());
 }
Exemplo n.º 22
0
 private bool IsLeaf(QCon qcon)
 {
     return(!qcon.HasChildren());
 }
Exemplo n.º 23
0
        public virtual bool IsResolved()
        {
            QCon parent = Constraint().Parent();

            return(null == parent || !parent.HasParent());
        }