Esempio n. 1
0
        public TerminalPredicate GetExecutionPredicate(IQueryStore queryStore)
        {
            if (_predicates.Count == 1)
            {
                return(_predicates[0].GetExecutionPredicate(queryStore));
            }

            bool        optimized   = true;
            ORPredicate orPredicate = new ORPredicate();

            foreach (var predicate in _predicates)
            {
                TerminalPredicate execPred = predicate.GetExecutionPredicate(queryStore);

                if (execPred is StorePredicate)
                {
                    optimized = false;
                    break;
                }
                orPredicate.AddChildPredicate(execPred);
            }

            if (!optimized)
            {
                return(new StorePredicate(OrTreePredicate, queryStore));
            }

            return(orPredicate);
        }
Esempio n. 2
0
        //Marked for refactoring
        private IPredicate GetSelectAllPredicate(QueryCriteria criteria, IEnumerable <long> rowsEnumerator)
        {
            if (criteria.GetAllFields || criteria.Projections.Length == 0)
            {
                return(new FullPredicate(rowsEnumerator));
            }

            if (criteria.ProjectionCount > 1)
            {
                IPredicate predicate = new ORPredicate();
                for (int i = 0; i < criteria.ProjectionCount; i++)
                {
                    List <IIndex> list = _indexManager.GetIndexes(criteria[i].ToString());

                    if (list == null)
                    {
                        return(new StorePredicate(new TrueCondition(), criteria.Store));
                    }

                    predicate.AddChildPredicate(new AllPredicate(list[0]));
                }
                return(predicate);
            }

            var indexlist = _indexManager.GetIndexes(criteria[0].ToString());

            if (indexlist == null)
            {
                return(new FullPredicate(rowsEnumerator));
            }

            return(new AllPredicate(indexlist[0]));
        }
Esempio n. 3
0
        public override IEnumerable <KeyValuePair <AttributeValue, long> > Enumerate(QueryCriteria value)
        {
            var orPredicate = new ORPredicate();

            foreach (var attributeValue in _anyValues)
            {
                orPredicate.AddChildPredicate(new RangePredicate(Source,
                                                                 new SingleAttributeValue(new ArrayElement(attributeValue, 0)), IsInverse,
                                                                 new SingleAttributeValue(new ArrayElement(attributeValue, int.MaxValue))
                                                                 , IsInverse, IsInverse));
            }

            return(orPredicate.Enumerate(value));
        }