Example #1
0
        private TreeInt ToTreeInt(IIndexedNode result)
        {
            ByRef treeInts = ByRef.NewInstance();

            result.Traverse(new _IIntVisitor_65(treeInts));
            return((TreeInt)treeInts.value);
        }
        public virtual IIndexedNode SelectBestIndex()
        {
            IEnumerator  i    = CollectIndexedNodes();
            IIndexedNode best = null;

            while (i.MoveNext())
            {
                IIndexedNode indexedNode = (IIndexedNode)i.Current;
                IIndexedNode resolved    = ResolveFully(indexedNode);
                if (resolved == null)
                {
                    continue;
                }
                if (best == null)
                {
                    best = indexedNode;
                    continue;
                }
                if (indexedNode.ResultSize() < best.ResultSize())
                {
                    best = indexedNode;
                }
            }
            return(best);
        }
Example #3
0
		public static void Traverse(IIndexedNode node, IIntVisitor visitor)
		{
			IEnumerator i = node.GetEnumerator();
			while (i.MoveNext())
			{
				IFieldIndexKey composite = (IFieldIndexKey)i.Current;
				visitor.Visit(composite.ParentID());
			}
		}
Example #4
0
 public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint)
 {
     if (!CanFollowParent(constraint))
     {
         return null;
     }
     return new IndexedPath((QConObject) constraint
         .Parent(), next);
 }
Example #5
0
 public static IIndexedNode NewParentPath(IIndexedNode next, QCon constraint)
 {
     if (!CanFollowParent(constraint))
     {
         return(null);
     }
     return(new IndexedPath((QConObject)constraint
                            .Parent(), next));
 }
Example #6
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));
 }
Example #7
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);
		}
Example #8
0
        public static void Traverse(IIndexedNode node, IIntVisitor visitor)
        {
            IEnumerator i = node.GetEnumerator();

            while (i.MoveNext())
            {
                IFieldIndexKey composite = (IFieldIndexKey)i.Current;
                visitor.Visit(composite.ParentID());
            }
        }
Example #9
0
		public static TreeInt AddToTree(TreeInt tree, IIndexedNode node)
		{
			IEnumerator i = node.GetEnumerator();
			while (i.MoveNext())
			{
				IFieldIndexKey composite = (IFieldIndexKey)i.Current;
				tree = (TreeInt)((TreeInt)Tree.Add(tree, new TreeInt(composite.ParentID())));
			}
			return tree;
		}
Example #10
0
        public static TreeInt AddToTree(TreeInt tree, IIndexedNode node)
        {
            var i = node.GetEnumerator();

            while (i.MoveNext())
            {
                var composite = (IFieldIndexKey)i.Current;
                tree = (TreeInt)Tree.Add(tree, new TreeInt(composite.ParentID()));
            }
            return(tree);
        }
 private IIndexedNode ResolveFully(IIndexedNode indexedNode)
 {
     if (null == indexedNode)
     {
         return(null);
     }
     if (indexedNode.IsResolved())
     {
         return(indexedNode);
     }
     return(ResolveFully(indexedNode.Resolve()));
 }
 private IIndexedNode ResolveFully(IIndexedNode bestIndex)
 {
     if (null == bestIndex)
     {
         return(null);
     }
     if (bestIndex.IsResolved())
     {
         return(bestIndex);
     }
     return(ResolveFully(bestIndex.Resolve()));
 }
Example #13
0
		private IIndexedNode ResolveFully(IIndexedNode indexedNode)
		{
			if (null == indexedNode)
			{
				return null;
			}
			if (indexedNode.IsResolved())
			{
				return indexedNode;
			}
			return ResolveFully(indexedNode.Resolve());
		}
		private IIndexedNode ResolveFully(IIndexedNode bestIndex)
		{
			if (null == bestIndex)
			{
				return null;
			}
			if (bestIndex.IsResolved())
			{
				return bestIndex;
			}
			return ResolveFully(bestIndex.Resolve());
		}
        public virtual FieldIndexProcessorResult Run()
        {
            IIndexedNode bestIndex = SelectBestIndex();

            if (null == bestIndex)
            {
                return(FieldIndexProcessorResult.NoIndexFound);
            }
            IIndexedNode resolved = ResolveFully(bestIndex);

            if (!bestIndex.IsEmpty())
            {
                bestIndex.MarkAsBestIndex(_candidates);
                return(new FieldIndexProcessorResult(resolved));
            }
            return(FieldIndexProcessorResult.FoundIndexButNoMatch);
        }
Example #16
0
        public virtual void TestDoubleDescendingOnIndexedNodes()
        {
            IQuery query = CreateComplexItemQuery();

            query.Descend("child").Descend("foo").Constrain(3);
            query.Descend("bar").Constrain(2);
            IIndexedNode index = SelectBestIndex(query);

            AssertComplexItemIndex("foo", index);
            Assert.IsFalse(index.IsResolved());
            IIndexedNode result = index.Resolve();

            Assert.IsNotNull(result);
            AssertComplexItemIndex("child", result);
            Assert.IsTrue(result.IsResolved());
            Assert.IsNull(result.Resolve());
            AssertComplexItems(new int[] { 4 }, result.ToTreeInt());
        }
        public virtual IIndexedNode SelectBestIndex()
        {
            IEnumerator i = CollectIndexedNodes();

            if (!i.MoveNext())
            {
                return(null);
            }
            IIndexedNode best = (IIndexedNode)i.Current;

            while (i.MoveNext())
            {
                IIndexedNode leaf = (IIndexedNode)i.Current;
                if (leaf.ResultSize() < best.ResultSize())
                {
                    best = leaf;
                }
            }
            return(best);
        }
        public virtual FieldIndexProcessorResult Run()
        {
            IIndexedNode bestIndex = SelectBestIndex();

            if (null == bestIndex)
            {
                return(FieldIndexProcessorResult.NoIndexFound);
            }
            if (bestIndex.ResultSize() > 0)
            {
                IIndexedNode resolved = ResolveFully(bestIndex);
                if (null == resolved)
                {
                    return(FieldIndexProcessorResult.NoIndexFound);
                }
                resolved.MarkAsBestIndex();
                return(new FieldIndexProcessorResult(resolved));
            }
            return(FieldIndexProcessorResult.FoundIndexButNoMatch);
        }
Example #19
0
 public IndexedPath(QConObject parent, IIndexedNode next) : base(parent)
 {
     _next = next;
 }
Example #20
0
        private void AssertBestIndex(string expectedFieldIndex, IQuery query)
        {
            IIndexedNode node = SelectBestIndex(query);

            AssertComplexItemIndex(expectedFieldIndex, node);
        }
		public FieldIndexProcessorResult(IIndexedNode indexedNode)
		{
			_indexedNode = indexedNode;
		}
Example #22
0
 protected virtual void AssertComplexItemIndex(string expectedFieldIndex, IIndexedNode
                                               node)
 {
     Assert.AreSame(ComplexItemIndex(expectedFieldIndex), node.GetIndex());
 }
Example #23
0
 public FieldIndexProcessorResult(IIndexedNode indexedNode)
 {
     _indexedNode = indexedNode;
 }
 protected virtual void AssertComplexItemIndex(string expectedFieldIndex, IIndexedNode
     node)
 {
     Assert.AreSame(ComplexItemIndex(expectedFieldIndex), node.GetIndex());
 }
Example #25
0
		public IndexedPath(QConObject parent, IIndexedNode next) : base(parent)
		{
			_next = next;
		}
Example #26
0
		private TreeInt ToTreeInt(IIndexedNode result)
		{
			ByRef treeInts = ByRef.NewInstance();
			result.Traverse(new _IIntVisitor_65(treeInts));
			return ((TreeInt)treeInts.value);
		}