Пример #1
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            if (typename == "*")
                throw new ParserException("Incorrect query format. \'*\' is not supported.");

            if (queryContext.IndexManager == null)
                throw new TypeIndexNotDefined("Index is not defined for '" + typename.ToString() + "'");

            queryContext.TypeName = typename;

            if (queryContext.Index == null) //try to get virtual index
            {
                //in case of DisableException is true, exception will not be thrown, and return new attribute index.
                if (QueryIndexManager.DisableException)
                {
                    queryContext.Index = new AttributeIndex(null, queryContext.Cache.Context.CacheRoot.Name, null);
                    return;
                }

                throw new TypeIndexNotDefined("Index is not defined for '" + typename.ToString() + "'");
            }
            else
            {
                
                //populate the tree for normal queries...
                if (nextPredicate == null && queryContext.PopulateTree)
                {
                    queryContext.Tree.Populate(queryContext.Index.GetEnumerator(typename));
                }
                else
                {
                    nextPredicate.Execute(queryContext, null);
                }
            }
        }
Пример #2
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            if (typename == "*")
            {
                throw new ParserException("Incorrect query format. \'*\' is not supported.");
            }

            if (queryContext.IndexManager == null)
            {
                throw new TypeIndexNotDefined("Index is not defined for '" + typename.ToString() + "'");
            }

            queryContext.TypeName = typename;

            if (queryContext.Index == null) //try to get virtual index
            {
                //we are not allowing queries
                //with out attribute-level indexes right now.

                //in case of DisableException is true, exception will not be thrown, and return new attribute index.
                if (QueryIndexManager.DisableException)
                {
                    queryContext.Index = new AttributeIndex(null, queryContext.Cache.Context.CacheRoot.Name, null);
                    return;
                }

                throw new TypeIndexNotDefined("Index is not defined for '" + typename.ToString() + "'");
            }
            else
            {
                //populate the tree for normal queries...
                if (nextPredicate == null && queryContext.PopulateTree)
                {
                    queryContext.InternalQueryResult = new ListQueryResult();
                    queryContext.InternalQueryResult.Populate(queryContext.Index.GetEnumerator(typename));
                }
                else
                {
                    if (nextPredicate is LogicalAndPredicate)
                    {
                        queryContext.InternalQueryResult = new HashedQueryResult();
                    }
                    else
                    {
                        queryContext.InternalQueryResult = new ListQueryResult();
                    }
                    nextPredicate.Execute(queryContext, null);
                }
            }
        }
Пример #3
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            for (int i = 0; i < members.Count; i++)
            {
                Predicate predicate         = (Predicate)members[i];
                bool      isOfTypePredicate = predicate is IsOfTypePredicate;

                if (isOfTypePredicate)
                {
                    predicate.Execute(queryContext, (Predicate)members[++i]);
                }
                else
                {
                    CollectionOperation mergeType = (Inverse == true || (queryContext.InternalQueryResult.Count == 0 & i == 0)) ? CollectionOperation.Union : CollectionOperation.Intersection;
                    predicate.ExecuteInternal(queryContext, mergeType);
                }
            }
        }
Пример #4
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            bool sortAscending       = true;
            bool normalizePredicates = true;

            if (Inverse)
            {
                sortAscending = false;
            }

            SortedList list = new SortedList(new QueryResultComparer(sortAscending));

            for (int i = 0; i < members.Count; i++)
            {
                Predicate predicate         = (Predicate)members[i];
                bool      isOfTypePredicate = predicate is IsOfTypePredicate;

                if (isOfTypePredicate)
                {
                    predicate.Execute(queryContext, (Predicate)members[++i]);
                    normalizePredicates = false;
                }
                else
                {
                    predicate.ExecuteInternal(queryContext, ref list);
                }
            }

            if (normalizePredicates)
            {
                if (Inverse)
                {
                    queryContext.Tree.RightList = GetUnion(list);
                }
                else
                {
                    queryContext.Tree.RightList = GetIntersection(list);
                }
            }
        }
Пример #5
0
        internal override void Execute(QueryContext queryContext, Predicate nextPredicate)
        {
            for (int i = 0; i < members.Count; i++)
            {
                if (queryContext.CancellationToken != null && queryContext.CancellationToken.IsCancellationRequested)
                {
                    throw new OperationCanceledException(ExceptionsResource.OperationFailed);
                }

                Predicate predicate         = (Predicate)members[i];
                bool      isOfTypePredicate = predicate is IsOfTypePredicate;

                if (isOfTypePredicate)
                {
                    predicate.Execute(queryContext, (Predicate)members[++i]);
                }
                else
                {
                    CollectionOperation mergeType = (Inverse == true || (queryContext.InternalQueryResult.Count == 0 & i == 0)) ? CollectionOperation.Union : CollectionOperation.Intersection;
                    predicate.ExecuteInternal(queryContext, mergeType);
                }
            }
        }
Пример #6
0
        /// <summary>
        ///         /// returns the keylist fullfilling the specified criteria.
        /// </summary>
        /// <param name="queryString">a string describing the search criteria.</param>
        /// <returns>a list of keys.</returns>
        internal override QueryContext SearchInternal(Predicate pred, IDictionary values)
        {
            QueryContext queryContext = new QueryContext(this);
            queryContext.AttributeValues = values;
            queryContext.CacheContext = _context.CacheRoot.Name;

            try
            {
                pred.Execute(queryContext, null);
                return queryContext;
            }
            catch (Exception)
            {
                throw;
            }
        }