public static void QueryPlanLogOnExpr(
            bool queryPlanLogging,
            ILog queryPlanLog,
            SubordinateWMatchExprQueryPlanForge strategy,
            Attribute[] annotations,
            ImportService importService)
        {
            QueryPlanIndexHook hook = QueryPlanIndexHookUtil.GetHook(annotations, importService);
            if (queryPlanLogging && (queryPlanLog.IsInfoEnabled || hook != null)) {
                var prefix = "On-Expr ";
                queryPlanLog.Info(prefix + "strategy " + strategy.Strategy.ToQueryPlan());
                if (strategy.Indexes == null) {
                    queryPlanLog.Info(prefix + "full table scan");
                }
                else {
                    for (var i = 0; i < strategy.Indexes.Length; i++) {
                        string indexName = strategy.Indexes[i].IndexName;
                        var indexText = indexName != null ? "index " + indexName + " " : "(implicit) (" + i + ")";
                        queryPlanLog.Info(prefix + indexText);
                    }
                }

                if (hook != null) {
                    var pairs = GetPairs(strategy.Indexes);
                    SubordTableLookupStrategyFactoryForge inner = strategy.Strategy.OptionalInnerStrategy;
                    hook.InfraOnExpr(
                        new QueryPlanIndexDescOnExpr(
                            pairs,
                            strategy.Strategy.GetType().GetSimpleName(),
                            inner == null ? null : inner.GetType().GetSimpleName()));
                }
            }
        }
示例#2
0
 public SubordinateWMatchExprQueryPlanResult(
     SubordinateWMatchExprQueryPlanForge forge,
     IList<StmtClassForgeableFactory> additionalForgeables)
 {
     Forge = forge;
     AdditionalForgeables = additionalForgeables;
 }
示例#3
0
        public static SubordinateWMatchExprQueryPlanResult PlanOnExpression(
            ExprNode joinExpr,
            EventType filterEventType,
            IndexHint optionalIndexHint,
            bool isIndexShare,
            int subqueryNumber,
            ExcludePlanHint excludePlanHint,
            bool isVirtualDataWindow,
            EventTableIndexMetadata indexMetadata,
            EventType eventTypeIndexed,
            ISet<string> optionalUniqueKeyProps,
            bool onlyUseExistingIndexes,
            StatementRawInfo statementRawInfo,
            StatementCompileTimeServices compileTimeServices)
        {
            var allStreamsZeroIndexed = new EventType[] {eventTypeIndexed, filterEventType};
            var outerStreams = new EventType[] {filterEventType};
            var joinedPropPlan = QueryPlanIndexBuilder.GetJoinProps(
                joinExpr,
                1,
                allStreamsZeroIndexed,
                excludePlanHint);

            // No join expression means all
            if (joinExpr == null && !isVirtualDataWindow) {
                var forgeX = new SubordinateWMatchExprQueryPlanForge(new SubordWMatchExprLookupStrategyAllUnfilteredForge(), null);
                return new SubordinateWMatchExprQueryPlanResult(forgeX, EmptyList<StmtClassForgeableFactory>.Instance);
            }

            var queryPlan = PlanSubquery(
                outerStreams,
                joinedPropPlan,
                true,
                false,
                optionalIndexHint,
                isIndexShare,
                subqueryNumber,
                isVirtualDataWindow,
                indexMetadata,
                optionalUniqueKeyProps,
                onlyUseExistingIndexes,
                eventTypeIndexed,
                statementRawInfo,
                compileTimeServices);

            if (queryPlan == null) {
                var forgeX = new SubordinateWMatchExprQueryPlanForge(new SubordWMatchExprLookupStrategyAllFilteredForge(joinExpr), null);
                return new SubordinateWMatchExprQueryPlanResult(forgeX, EmptyList<StmtClassForgeableFactory>.Instance);
            }

            var queryPlanDesc = queryPlan.Forge;
            SubordinateWMatchExprQueryPlanForge forge;
            if (joinExpr == null) {   // it can be null when using virtual data window
                forge = new SubordinateWMatchExprQueryPlanForge(
                    new SubordWMatchExprLookupStrategyIndexedUnfilteredForge(queryPlanDesc.LookupStrategyFactory), queryPlanDesc.IndexDescs);
            } else {
                var filteredForge =
                    new SubordWMatchExprLookupStrategyIndexedFilteredForge(joinExpr.Forge, queryPlanDesc.LookupStrategyFactory);
                forge = new SubordinateWMatchExprQueryPlanForge(filteredForge, queryPlanDesc.IndexDescs);
            }

            return new SubordinateWMatchExprQueryPlanResult(forge, queryPlan.AdditionalForgeables);
        }