Ejemplo n.º 1
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            // find first indexNode
            var value = _value.Normalize(index.Options);
            var node  = indexer.Find(index, value, true, Query.Ascending);
            var str   = value.AsString;

            // navigate using next[0] do next node - if less or equals returns
            while (node != null)
            {
                var valueString = node.Key.AsString;

                // value will not be null because null occurs before string (bsontype sort order)
                if (valueString.StartsWith(str))
                {
                    if (!node.DataBlock.IsEmpty)
                    {
                        yield return(node);
                    }
                }
                else
                {
                    break; // if not more startswith, stop scanning
                }

                node = indexer.GetNode(node.Next[0]);
            }
        }
Ejemplo n.º 2
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            // find first indexNode
            var value = _value.Normalize(index.Options);
            var node  = indexer.Find(index, value, true, Query.Ascending);

            if (node == null)
            {
                yield break;
            }

            // move until next is last
            while (node != null)
            {
                var diff = node.Key.CompareTo(value);

                if (diff == 1 || (_equals && diff == 0))
                {
                    if (node.IsHeadTail(index))
                    {
                        yield break;
                    }

                    yield return(node);
                }

                node = indexer.GetNode(node.Next[0]);
            }
        }
Ejemplo n.º 3
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            var value = _value.Normalize(index.Options);
            var node  = indexer.Find(index, value, false, Query.Ascending);

            if (node == null)
            {
                yield break;
            }

            yield return(node);

            if (index.Options.Unique == false)
            {
                // navigate using next[0] do next node - if equals, returns
                while (!node.Next[0].IsEmpty && ((node = indexer.GetNode(node.Next[0])).Key.CompareTo(value) == 0))
                {
                    if (node.IsHeadTail(index))
                    {
                        yield break;
                    }

                    yield return(node);
                }
            }
        }
Ejemplo n.º 4
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            var start = _start.Normalize(index.Options);
            var end   = _end.Normalize(index.Options);

            // define order
            var order = start.CompareTo(end) <= 0 ? Query.Ascending : Query.Descending;

            // find first indexNode
            var node = indexer.Find(index, start, true, order);

            // navigate using next[0] do next node - if less or equals returns
            while (node != null)
            {
                var diff = node.Key.CompareTo(end);

                if (diff == 0 || diff != order)
                {
                    yield return(node);
                }
                else
                {
                    break;
                }

                node = indexer.GetNode(node.NextPrev(0, order));
            }
        }
Ejemplo n.º 5
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            var v = _value.Normalize(index.Options);

            return(indexer
                   .FindAll(index, Query.Ascending)
                   .Where(x => x.Key.IsString && x.Key.AsString.Contains(v)));
        }
Ejemplo n.º 6
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            var value = _value.Normalize(index.Options);

            foreach (var node in indexer.FindAll(index, Query.Ascending))
            {
                var diff = node.Key.CompareTo(value);

                if (diff == 1 || (!_equals && diff == 0))
                {
                    break;
                }

                if (node.IsHeadTail(index))
                {
                    yield break;
                }

                yield return(node);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Insert a new node index inside an collection index. Flip coin to know level
 /// </summary>
 public IndexNode AddNode(CollectionIndex index, BsonValue key)
 {
     // call AddNode normalizing value
     return(this.AddNode(index, key.Normalize(index.Options), this.FlipCoin()));
 }
Ejemplo n.º 8
0
        internal override IEnumerable<IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            var value = _value.Normalize(index.Options);

            return indexer.FindAll(index, Query.Ascending).Where(x => x.Key.CompareTo(value) != 0);
        }