Ejemplo n.º 1
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            var node = indexer.Find(index, _value, false, 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);
                }
            }
        }
Ejemplo n.º 2
0
 public CollectionService(PageService pager, IndexService indexer, DataService data, TransactionService trans, Logger log)
 {
     _pager   = pager;
     _indexer = indexer;
     _data    = data;
     _trans   = trans;
     _log     = log;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create instances for all engine services
 /// </summary>
 private void InitializeServices()
 {
     _cache       = new CacheService(_disk, _log);
     _locker      = new LockService(_disk, _cache, _timeout, _log);
     _pager       = new PageService(_disk, _crypto, _cache, _log);
     _indexer     = new IndexService(_pager, _log);
     _data        = new DataService(_pager, _log);
     _trans       = new TransactionService(_disk, _crypto, _pager, _locker, _cache, _cacheSize, _log);
     _collections = new CollectionService(_pager, _indexer, _data, _trans, _log);
 }
Ejemplo n.º 4
0
 internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
 {
     foreach (var value in _values.Distinct())
     {
         foreach (var node in EQ(Field, value).ExecuteIndex(indexer, index))
         {
             yield return(node);
         }
     }
 }
Ejemplo n.º 5
0
        internal override IEnumerable <IndexNode> Run(CollectionPage col, IndexService indexer)
        {
            var left  = _left.Run(col, indexer);
            var right = _right.Run(col, indexer);

            // if any query (left/right) is FullScan, this query is full scan too
            UseIndex  = _left.UseIndex && _right.UseIndex;
            UseFilter = _left.UseFilter || _right.UseFilter;

            return(left.Union(right, new IndexNodeComparer()));
        }
Ejemplo n.º 6
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            // define order
            var order = _start.CompareTo(_end) <= 0 ? Ascending : 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));
            }
        }
Ejemplo n.º 7
0
        internal override IEnumerable <IndexNode> Run(CollectionPage col, IndexService indexer)
        {
            // run base query
            var result = _query.Run(col, indexer);

            UseIndex  = _query.UseIndex;
            UseFilter = _query.UseFilter;

            if (_query.UseIndex)
            {
                // if is by index, resolve here
                var all = new QueryAll("_id", _order).Run(col, indexer);

                return(all.Except(result, new IndexNodeComparer()));
            }
            else
            {
                // if is by document, must return all nodes to be ExecuteDocument after
                return(result);
            }
        }
Ejemplo n.º 8
0
        internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
        {
            foreach (var node in indexer.FindAll(index, Ascending))
            {
                // 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))
                    {
                        break;
                    }

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

                    yield return(node);
                }
            }
        }
Ejemplo n.º 9
0
 internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
 {
     return(indexer
            .FindAll(index, Ascending)
            .Where(x => x.Key.CompareTo(_value) != 0));
 }
Ejemplo n.º 10
0
 internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Abstract method that must be implement for index seek/scan - Returns IndexNodes that match with index
 /// </summary>
 internal abstract IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index);
Ejemplo n.º 12
0
 internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
 {
     yield break;
 }
Ejemplo n.º 13
0
 internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
 {
     return(indexer
            .FindAll(index, _order)
            .Where(i => _func(i.Key)));
 }
Ejemplo n.º 14
0
 internal override IEnumerable <IndexNode> ExecuteIndex(IndexService indexer, CollectionIndex index)
 {
     return(indexer
            .FindAll(index, Ascending)
            .Where(x => x.Key.IsString && x.Key.AsString.Contains(_value)));
 }