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()); } } } }
private void CollectImplicitAnd(QCon constraint, IIndexedNodeWithRange x, IIndexedNodeWithRange y) { _nodes.Remove(x); _nodes.Remove(y); _nodes.Add(new AndIndexedLeaf(constraint, x, y)); }
private IIndexedNodeWithRange NewNodeForConstraint(QCon con) { if (con is QConJoin) { return(NewNodeForConstraint((QConJoin)con)); } return(new IndexedLeaf((QConObject)con)); }
public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint) { if (!CanFollowParent(constraint)) { return(null); } return(new Db4objects.Db4o.Internal.Fieldindex.IndexedPath((QConObject)constraint .Parent(), next)); }
public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint) { if (!CanFollowParent(constraint)) { return(null); } return(new IndexedPath((QConObject)constraint .Parent(), next)); }
private static FieldMetadata GetYapField(QCon con) { QField field = con.GetField(); if (null == field) { return(null); } return(field.GetFieldMetadata()); }
public JoinedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IBTreeRange range ) { if (null == constraint || null == leaf1 || null == range) { throw new ArgumentNullException(); } _constraint = constraint; _leaf1 = leaf1; _range = range; }
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); }
private void CollectLeavesFromJoinConstraint(Collection4 leaves, QCon constraint) { if (constraint is QConJoin) { CollectLeavesFromJoin(leaves, (QConJoin)constraint); } else { if (!leaves.ContainsByIdentity(constraint)) { leaves.Add(constraint); } } }
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)); }
private bool AllCanBeSearchedByIndex(Collection4 leaves) { IEnumerator i = leaves.GetEnumerator(); while (i.MoveNext()) { QCon leaf = ((QCon)i.Current); if (!leaf.CanLoadByIndex()) { return(false); } } return(true); }
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(); }
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); }
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())); }
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); }
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())); }
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); } } }
public OrIndexedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IIndexedNodeWithRange leaf2) : base(constraint, leaf1, leaf1.GetRange().Union(leaf2.GetRange())) { }
private bool IsCached(QCon qcon) { return(null != _nodeCache.Get(qcon)); }
public AndIndexedLeaf(QCon constraint, IIndexedNodeWithRange leaf1, IIndexedNodeWithRange leaf2) : base(constraint, leaf1, leaf1.GetRange().Intersect(leaf2.GetRange())) { }
private void VisitAllChildrenOf(QCon path) { VisitAll(Iterators.Iterable(path.IterateChildren()).Cast <IConstraint>()); }
private bool IsLeaf(QCon qcon) { return(!qcon.HasChildren()); }
public virtual bool IsResolved() { QCon parent = Constraint().Parent(); return(null == parent || !parent.HasParent()); }