Package com.espertech.esper.epl.core.eval

Source Code of com.espertech.esper.epl.core.eval.EvalSelectWildcardSSWrapper

/*
* *************************************************************************************
*  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.core.eval;

import com.espertech.esper.client.EventBean;
import com.espertech.esper.client.EventType;
import com.espertech.esper.epl.core.SelectExprProcessor;
import com.espertech.esper.epl.expression.ExprEvaluatorContext;
import com.espertech.esper.event.DecoratingEventBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.HashMap;
import java.util.Map;

public class EvalSelectWildcardSSWrapper extends EvalBase implements SelectExprProcessor {

    private static final Log log = LogFactory.getLog(EvalSelectWildcardSSWrapper.class);

    public EvalSelectWildcardSSWrapper(SelectExprContext selectExprContext, EventType resultEventType) {
        super(selectExprContext, resultEventType);
    }

    public EventBean processSpecific(Map<String, Object> props, EventBean[] eventsPerStream, boolean isNewData, boolean isSynthesize, ExprEvaluatorContext exprEvaluatorContext)
    {
        // In case of a wildcard and single stream that is itself a
        // wrapper bean, we also need to add the map properties
        DecoratingEventBean wrapper = (DecoratingEventBean)eventsPerStream[0];
        if(wrapper != null)
        {
            Map<String, Object> map = wrapper.getDecoratingProperties();
            if ((super.getExprNodes().length == 0) && (!map.isEmpty()))
            {
                props = new HashMap<String, Object>(map);
            }
            else
            {
                props.putAll(map);
            }
        }

        EventBean event = eventsPerStream[0];

        // Using a wrapper bean since we cannot use the same event type else same-type filters match.
        // Wrapping it even when not adding properties is very inexpensive.
        return super.getEventAdapterService().adapterForTypedWrapper(event, props, super.getResultEventType());
    }
}
TOP

Related Classes of com.espertech.esper.epl.core.eval.EvalSelectWildcardSSWrapper

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.