示例#1
0
        void OptimizeQuery(Db4objects.Db4o.Query.IQuery q, object predicate, System.Reflection.MethodBase filterMethod)
        {
            if (_builder == null)
            {
                _builder = NQOptimizerFactory.CreateExpressionBuilder();
            }

            _builder.Optimize(q, predicate, filterMethod);
        }
示例#2
0
        public virtual System.Collections.Generic.IList <Extent> Execute <Extent>(Db4objects.Db4o.Query.IQuery query, System.Predicate <Extent> match,
                                                                                  Db4objects.Db4o.Query.IQueryComparator comparator)
        {
#if CF
            return(ExecuteUnoptimized <Extent>(QueryForExtent <Extent>(query, comparator), match));
#else
            // XXX: check GetDelegateList().Length
            // only 1 delegate must be allowed
            // although we could use it as a filter chain
            // (and)
            return(ExecuteImpl <Extent>(query, match, match.Target, match.Method, match, comparator));
#endif
        }
示例#3
0
        private System.Collections.Generic.IList <Extent> ExecuteImpl <Extent>(
            Db4objects.Db4o.Query.IQuery query,
            object originalPredicate,
            object matchTarget,
            System.Reflection.MethodBase matchMethod,
            System.Predicate <Extent> match,
            Db4objects.Db4o.Query.IQueryComparator comparator)
        {
            Db4objects.Db4o.Query.IQuery q = QueryForExtent <Extent>(query, comparator);
            try
            {
                if (OptimizeNativeQueries())
                {
                    OptimizeQuery(q, matchTarget, matchMethod);
                    OnQueryExecution(originalPredicate, QueryExecutionKind.DynamicallyOptimized);

                    return(WrapQueryResult <Extent>(q));
                }
            }
            catch (FileNotFoundException fnfe)
            {
                NativeQueryOptimizerNotLoaded(fnfe);
            }
            catch (TargetInvocationException tie)
            {
                NativeQueryOptimizerNotLoaded(tie);
            }
            catch (TypeLoadException tle)
            {
                NativeQueryOptimizerNotLoaded(tle);
            }
            catch (System.Exception e)
            {
                OnQueryOptimizationFailure(e);

                NativeQueryUnoptimized(e);
            }

            return(ExecuteUnoptimized(q, match));
        }
示例#4
0
        private Db4objects.Db4o.Query.IQuery ConfigureQuery(Db4objects.Db4o.Query.IQuery query, Db4objects.Db4o.Query.Predicate predicate)
        {
            IDb4oEnhancedFilter filter = predicate as IDb4oEnhancedFilter;

            if (null != filter)
            {
                filter.OptimizeQuery(query);
                OnQueryExecution(predicate, QueryExecutionKind.PreOptimized);
                return(query);
            }

            query.Constrain(predicate.ExtentType());

            try
            {
                if (OptimizeNativeQueries())
                {
                    OptimizeQuery(query, predicate, predicate.GetFilterMethod());
                    OnQueryExecution(predicate, QueryExecutionKind.DynamicallyOptimized);
                    return(query);
                }
            }
            catch (System.Exception e)
            {
                OnQueryOptimizationFailure(e);

                if (OptimizeNativeQueries())
                {
                    DiagnosticProcessor dp = Container()._handlers.DiagnosticProcessor();
                    if (dp.Enabled())
                    {
                        dp.NativeQueryUnoptimized(predicate, e);
                    }
                }
            }

            query.Constrain(new Db4objects.Db4o.Internal.Query.PredicateEvaluation(predicate));
            OnQueryExecution(predicate, QueryExecutionKind.Unoptimized);
            return(query);
        }
示例#5
0
 public virtual Db4objects.Db4o.IObjectSet Execute(Db4objects.Db4o.Query.IQuery query, Db4objects.Db4o.Query.Predicate predicate, Db4objects.Db4o.Query.IQueryComparator comparator)
 {
     Db4objects.Db4o.Query.IQuery q = ConfigureQuery(query, predicate);
     q.SortBy(comparator);
     return(q.Execute());
 }
示例#6
0
        private static System.Collections.Generic.IList <Extent> WrapQueryResult <Extent>(Db4objects.Db4o.Query.IQuery query)
        {
            IQueryResult queryResult = ((QQuery)query).GetQueryResult();

            return(new GenericObjectSetFacade <Extent>(queryResult));
        }
示例#7
0
 private Db4objects.Db4o.Query.IQuery QueryForExtent <Extent>(Db4objects.Db4o.Query.IQuery query, Db4objects.Db4o.Query.IQueryComparator comparator)
 {
     query.Constrain(typeof(Extent));
     query.SortBy(comparator);
     return(query);
 }