コード例 #1
0
ファイル: QueryGreater.cs プロジェクト: rejemy/UltraLiteDB
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            // find first indexNode
            var node = indexer.Find(index, _value, true, Query.Ascending);

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

            // move until next is last
            while (node != null)
            {
                // compares only with are same type
                if (node.Key.Type == _value.Type || (node.Key.IsNumber && _value.IsNumber))
                {
                    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]);
            }
        }
コード例 #2
0
ファイル: QueryStartsWith.cs プロジェクト: rejemy/UltraLiteDB
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            // find first indexNode
            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 no more starts with, stop scanning
                }

                node = indexer.GetNode(node.Next[0]);
            }
        }
コード例 #3
0
ファイル: QueryEquals.cs プロジェクト: rejemy/UltraLiteDB
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            var node = indexer.Find(index, _value, false, Query.Ascending);

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

            yield return(node);

            if (index.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);
                }
            }
        }
コード例 #4
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            // define order
            var order = _start.CompareTo(_end) <= 0 ? Query.Ascending : Query.Descending;

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

            // returns (or not) equals start value
            while (node != null)
            {
                var diff = node.Key.CompareTo(_start);

                // if current value are not equals start, go out this loop
                if (diff != 0)
                {
                    break;
                }

                if (_startEquals)
                {
                    yield return(node);
                }

                node = indexer.GetNode(node.NextPrev(0, order));
            }

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

                if (_endEquals && diff == 0)
                {
                    yield return(node);
                }
                else if (diff == -order)
                {
                    yield return(node);
                }
                else
                {
                    break;
                }

                node = indexer.GetNode(node.NextPrev(0, order));
            }
        }