/*
* *************************************************************************************
* 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.exec.composite;
import com.espertech.esper.client.EventBean;
import com.espertech.esper.client.EventPropertyGetter;
import com.espertech.esper.epl.expression.ExprEvaluator;
import com.espertech.esper.epl.expression.ExprEvaluatorContext;
import com.espertech.esper.event.EventBeanUtility;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class CompositeAccessStrategyLT extends CompositeAccessStrategyRelOpBase implements CompositeAccessStrategy {
public CompositeAccessStrategyLT(boolean isNWOnTrigger, int lookupStream, int numStreams, ExprEvaluator key, Class coercionType) {
super(isNWOnTrigger, lookupStream, numStreams, key, coercionType);
}
public Set<EventBean> lookup(EventBean theEvent, Map parent, Set<EventBean> result, CompositeIndexQuery next, ExprEvaluatorContext context) {
TreeMap index = (TreeMap) parent;
Object comparable = super.evaluateLookup(theEvent, context);
if (comparable == null) {
return null;
}
comparable = EventBeanUtility.coerce(comparable, coercionType);
return CompositeIndexQueryRange.handle(theEvent, index.headMap(comparable), null, result, next);
}
public Collection<EventBean> lookup(EventBean[] eventsPerStream, Map parent, Collection<EventBean> result, CompositeIndexQuery next, ExprEvaluatorContext context) {
TreeMap index = (TreeMap) parent;
Object comparable = super.evaluatePerStream(eventsPerStream, context);
if (comparable == null) {
return null;
}
comparable = EventBeanUtility.coerce(comparable, coercionType);
return CompositeIndexQueryRange.handle(eventsPerStream, index.headMap(comparable), null, result, next);
}
}