/*
* *************************************************************************************
* 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.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 CompositeAccessStrategyGE extends CompositeAccessStrategyRelOpBase implements CompositeAccessStrategy {
public CompositeAccessStrategyGE(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<Object, ?> index = (TreeMap<Object, ?>) parent;
Object comparable = super.evaluateLookup(theEvent, context);
if (comparable == null) {
return null;
}
comparable = EventBeanUtility.coerce(comparable, coercionType);
return CompositeIndexQueryRange.handle(theEvent, index.tailMap(comparable), null, result, next);
}
public Collection<EventBean> lookup(EventBean[] eventPerStream, Map parent, Collection<EventBean> result, CompositeIndexQuery next, ExprEvaluatorContext context) {
TreeMap index = (TreeMap) parent;
Object comparable = super.evaluatePerStream(eventPerStream, context);
if (comparable == null) {
return null;
}
comparable = EventBeanUtility.coerce(comparable, coercionType);
return CompositeIndexQueryRange.handle(eventPerStream, index.tailMap(comparable), null, result, next);
}
}