com.espertech.esper.pattern.EvalEveryDistinctStateNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esper Show documentation
Show all versions of esper Show documentation
Complex event processing and event series analysis component
/*
***************************************************************************************
* Copyright (C) 2006 EsperTech, Inc. All rights reserved. *
* http://www.espertech.com/esper *
* 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.pattern;
import com.espertech.esper.client.EventBean;
import com.espertech.esper.metrics.instrumentation.InstrumentationHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
/**
* Contains the state collected by an "every" operator. The state includes handles to any sub-listeners
* started by the operator.
*/
public class EvalEveryDistinctStateNode extends EvalStateNode implements Evaluator {
protected final EvalEveryDistinctNode everyDistinctNode;
protected final Map> spawnedNodes;
protected MatchedEventMap beginState;
/**
* Constructor.
*
* @param parentNode is the parent evaluator to call to indicate truth value
* @param everyDistinctNode is the factory node associated to the state
*/
public EvalEveryDistinctStateNode(Evaluator parentNode,
EvalEveryDistinctNode everyDistinctNode) {
super(parentNode);
this.everyDistinctNode = everyDistinctNode;
this.spawnedNodes = new LinkedHashMap>();
}
public void removeMatch(Set matchEvent) {
if (PatternConsumptionUtil.containsEvent(matchEvent, beginState)) {
quit();
this.getParentEvaluator().evaluateFalse(this, true);
} else {
PatternConsumptionUtil.childNodeRemoveMatches(matchEvent, spawnedNodes.keySet());
}
}
@Override
public EvalNode getFactoryNode() {
return everyDistinctNode;
}
public final void start(MatchedEventMap beginState) {
if (InstrumentationHelper.ENABLED) {
InstrumentationHelper.get().qPatternEveryDistinctStart(everyDistinctNode, beginState);
}
this.beginState = beginState.shallowCopy();
EvalStateNode childState = everyDistinctNode.getChildNode().newState(this, null, 0L);
spawnedNodes.put(childState, new HashSet
© 2015 - 2025 Weber Informatics LLC | Privacy Policy