Package com.espertech.esper.epl.join.plan

Source Code of com.espertech.esper.epl.join.plan.InKeywordTableLookupPlanSingleIdx

/**************************************************************************************
* 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.epl.join.plan;

import com.espertech.esper.client.EventType;
import com.espertech.esper.epl.expression.ExprEvaluator;
import com.espertech.esper.epl.expression.ExprNode;
import com.espertech.esper.epl.expression.ExprNodeUtility;
import com.espertech.esper.epl.join.exec.base.InKeywordSingleTableLookupStrategyExpr;
import com.espertech.esper.epl.join.exec.base.JoinExecTableLookupStrategy;
import com.espertech.esper.epl.join.table.EventTable;
import com.espertech.esper.epl.join.table.PropertyIndexedEventTableSingle;
import com.espertech.esper.epl.lookup.LookupStrategyDesc;
import com.espertech.esper.epl.lookup.LookupStrategyType;

import java.util.Collections;

/**
* Plan to perform an indexed table lookup.
*/
public class InKeywordTableLookupPlanSingleIdx extends TableLookupPlan
{
    private ExprNode[] expressions;

    /**
     * Ctor.
     * @param lookupStream - stream that generates event to look up for
     * @param indexedStream - stream to index table lookup
     * @param indexNum - index number for the table containing the full unindexed contents
     */
    public InKeywordTableLookupPlanSingleIdx(int lookupStream, int indexedStream, String indexNum, ExprNode[] expressions)
    {
        super(lookupStream, indexedStream, new String[] {indexNum});
        this.expressions = expressions;
    }

    public ExprNode[] getExpressions() {
        return expressions;
    }

    public TableLookupKeyDesc getKeyDescriptor() {
        return new TableLookupKeyDesc(Collections.<QueryGraphValueEntryHashKeyed>emptyList(), Collections.<QueryGraphValueEntryRange>emptyList());
    }

    public JoinExecTableLookupStrategy makeStrategyInternal(EventTable[] eventTable, EventType[] eventTypes)
    {
        PropertyIndexedEventTableSingle single = (PropertyIndexedEventTableSingle) eventTable[0];
        ExprEvaluator[] evaluators = new ExprEvaluator[expressions.length];
        for (int i = 0; i < expressions.length; i++) {
            evaluators[i] = expressions[i].getExprEvaluator();
        }
        return new InKeywordSingleTableLookupStrategyExpr(evaluators,
                super.getLookupStream(), single, new LookupStrategyDesc(LookupStrategyType.INKEYWORDSINGLEIDX, ExprNodeUtility.toExpressionStringsMinPrecedence(expressions)));
    }

    public String toString()
    {
        return this.getClass().getSimpleName() + " " +
                super.toString() +
               " keyProperties=" + ExprNodeUtility.toExpressionStringMinPrecedence(expressions);
    }
}
TOP

Related Classes of com.espertech.esper.epl.join.plan.InKeywordTableLookupPlanSingleIdx

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.