Package com.espertech.esper.core.context.subselect

Source Code of com.espertech.esper.core.context.subselect.SubSelectStrategyFactoryNamedWinIndexShare

/**************************************************************************************
* Copyright (C) 2008 EsperTech, Inc. All rights reserved.                            *
* http://esper.codehaus.org                                                          *
* http://www.espertech.com                                                           *
* ---------------------------------------------------------------------------------- *
* The software in this package is published under the terms of the GPL license       *
* a copy of which has been included with this distribution in the license.txt file.  *
**************************************************************************************/
package com.espertech.esper.core.context.subselect;

import com.espertech.esper.client.EventType;
import com.espertech.esper.core.context.util.AgentInstanceContext;
import com.espertech.esper.core.service.EPServicesContext;
import com.espertech.esper.epl.agg.service.AggregationService;
import com.espertech.esper.epl.agg.service.AggregationServiceFactoryDesc;
import com.espertech.esper.epl.expression.*;
import com.espertech.esper.epl.join.hint.IndexHint;
import com.espertech.esper.epl.lookup.SubordPropPlan;
import com.espertech.esper.epl.lookup.SubordTableLookupStrategy;
import com.espertech.esper.epl.named.NamedWindowProcessor;
import com.espertech.esper.epl.named.NamedWindowProcessorInstance;
import com.espertech.esper.epl.named.NamedWindowSubqueryStopCallback;
import com.espertech.esper.epl.subquery.*;
import com.espertech.esper.util.StopCallback;
import com.espertech.esper.view.Viewable;

import java.util.Collections;
import java.util.List;

/**
* Entry holding lookup resource references for use by {@link SubSelectActivationCollection}.
*/
public class SubSelectStrategyFactoryNamedWinIndexShare implements SubSelectStrategyFactory
{
    private final int subqueryNum;
    private final EventType[] outerEventTypesSelect;
    private final NamedWindowProcessor processor;
    private final boolean fullTableScan;
    private final IndexHint optionalIndexHint;
    private final SubordPropPlan joinedPropPlan;
    private final ExprEvaluator filterExprEval;
    private final AggregationServiceFactoryDesc aggregationServiceFactory;
    private final ExprEvaluator[] groupByKeys;

    public SubSelectStrategyFactoryNamedWinIndexShare(int subqueryNum, EventType[] outerEventTypesSelect, NamedWindowProcessor processor, boolean fullTableScan, IndexHint optionalIndexHint, SubordPropPlan joinedPropPlan, ExprEvaluator filterExprEval, AggregationServiceFactoryDesc aggregationServiceFactory, ExprEvaluator[] groupByKeys) {
        this.subqueryNum = subqueryNum;
        this.outerEventTypesSelect = outerEventTypesSelect;
        this.processor = processor;
        this.fullTableScan = fullTableScan;
        this.optionalIndexHint = optionalIndexHint;
        this.joinedPropPlan = joinedPropPlan;
        this.filterExprEval = filterExprEval;
        this.aggregationServiceFactory = aggregationServiceFactory;
        this.groupByKeys = groupByKeys;
    }

    public SubSelectStrategyRealization instantiate(EPServicesContext services,
                                                    Viewable viewableRoot,
                                                    AgentInstanceContext agentInstanceContext,
                                                    List<StopCallback> stopCallbackList) {

        SubselectAggregationPreprocessorBase subselectAggregationPreprocessor = null;

        AggregationService aggregationService = null;
        if (aggregationServiceFactory != null) {
            aggregationService = aggregationServiceFactory.getAggregationServiceFactory().makeService(agentInstanceContext, agentInstanceContext.getStatementContext().getMethodResolutionService());
            if (groupByKeys == null) {
                if (filterExprEval == null) {
                    subselectAggregationPreprocessor = new SubselectAggregationPreprocessorUnfilteredUngrouped(aggregationService, filterExprEval, null);
                }
                else {
                    subselectAggregationPreprocessor = new SubselectAggregationPreprocessorFilteredUngrouped(aggregationService, filterExprEval, null);
                }
            }
            else {
                if (filterExprEval == null) {
                    subselectAggregationPreprocessor = new SubselectAggregationPreprocessorUnfilteredGrouped(aggregationService, filterExprEval, groupByKeys);
                }
                else {
                    subselectAggregationPreprocessor = new SubselectAggregationPreprocessorFilteredGrouped(aggregationService, filterExprEval, groupByKeys);
                }
            }
        }

        NamedWindowProcessorInstance processorInstanceSubq = processor.getProcessorInstance(agentInstanceContext);
        SubordTableLookupStrategy namedWindowSubqueryLookup = processorInstanceSubq.getRootViewInstance()
                .getAddSubqueryLookupStrategy(agentInstanceContext, outerEventTypesSelect, joinedPropPlan, fullTableScan, subqueryNum, optionalIndexHint);
        stopCallbackList.add(new NamedWindowSubqueryStopCallback(processorInstanceSubq, namedWindowSubqueryLookup));

        return new SubSelectStrategyRealization(namedWindowSubqueryLookup, subselectAggregationPreprocessor, aggregationService, Collections.<ExprPriorNode, ExprPriorEvalStrategy>emptyMap(), Collections.<ExprPreviousNode, ExprPreviousEvalStrategy>emptyMap(), null, null);
    }
}
TOP

Related Classes of com.espertech.esper.core.context.subselect.SubSelectStrategyFactoryNamedWinIndexShare

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.