/**************************************************************************************
* 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.expression;
import com.espertech.esper.client.EventType;
import com.espertech.esper.event.EventAdapterService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.espertech.esper.epl.spec.StatementSpecRaw;
import com.espertech.esper.client.EventBean;
import java.util.Collection;
import java.util.Map;
/**
* Represents an exists-subselect in an expression tree.
*/
public class ExprSubselectExistsNode extends ExprSubselectNode
{
private static final Log log = LogFactory.getLog(ExprSubselectExistsNode.class);
private static final long serialVersionUID = 7082390247880356269L;
/**
* Ctor.
* @param statementSpec is the lookup statement spec from the parser, unvalidated
*/
public ExprSubselectExistsNode(StatementSpecRaw statementSpec)
{
super(statementSpec);
}
public Class getType()
{
return Boolean.class;
}
public Map<String, Object> getEventType() {
return null;
}
public void validateSubquery(ExprValidationContext validationContext) throws ExprValidationException
{
}
public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext)
{
if (matchingEvents == null)
{
return false;
}
if (matchingEvents.size() == 0)
{
return false;
}
if (filterExpr == null)
{
return true;
}
// Evaluate filter
EventBean[] events = new EventBean[eventsPerStream.length + 1];
System.arraycopy(eventsPerStream, 0, events, 1, eventsPerStream.length);
for (EventBean subselectEvent : matchingEvents)
{
// Prepare filter expression event list
events[0] = subselectEvent;
Boolean pass = (Boolean) filterExpr.evaluate(events, true, exprEvaluatorContext);
if ((pass != null) && (pass))
{
return true;
}
}
return false;
}
public Collection<EventBean> evaluateGetCollEvents(EventBean[] eventsPerStream, boolean isNewData, Collection<EventBean> matchingEvents, ExprEvaluatorContext context) {
return null;
}
public EventType getEventTypeCollection(EventAdapterService eventAdapterService) {
return null;
}
public Class getComponentTypeCollection() throws ExprValidationException {
return null;
}
public Collection evaluateGetCollScalar(EventBean[] eventsPerStream, boolean isNewData, Collection<EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext) {
return null;
}
public boolean isAllowMultiColumnSelect() {
return false;
}
public EventType getEventTypeSingle(EventAdapterService eventAdapterService, String statementId) throws ExprValidationException {
return null;
}
public EventBean evaluateGetEventBean(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) {
return null;
}
}