public long ComputeMilliseconds(MatchedEventMap beginState, PatternAgentInstanceContext context) { if (_parameter is ExprTimePeriod) { ExprTimePeriod timePeriod = (ExprTimePeriod)_parameter; return(timePeriod.NonconstEvaluator().DeltaMillisecondsUseEngineTime( _convertor.Convert(beginState), context.AgentInstanceContext)); } else { var result = _parameter.ExprEvaluator.Evaluate(new EvaluateParams(_convertor.Convert(beginState), true, context.AgentInstanceContext)); if (result == null) { throw new EPException("Null value returned for guard expression"); } if (result.IsFloatingPointNumber()) { return((long)Math.Round(1000d * result.AsDouble())); } else { return(1000 * result.AsLong()); } } }
public override OutputProcessViewBase MakeView( ResultSetProcessor resultSetProcessor, AgentInstanceContext agentInstanceContext) { bool isAfterConditionSatisfied = true; long?afterConditionTime = null; if (AfterConditionNumberOfEvents != null) { isAfterConditionSatisfied = false; } else if (AfterTimePeriod != null) { isAfterConditionSatisfied = false; long delta = AfterTimePeriod.NonconstEvaluator().DeltaUseEngineTime(null, agentInstanceContext); afterConditionTime = agentInstanceContext.StatementContext.TimeProvider.Time + delta; } if (base.PostProcessFactory == null) { return(new OutputProcessViewDirectDistinctOrAfter( ResultSetProcessorHelperFactory, agentInstanceContext, resultSetProcessor, afterConditionTime, AfterConditionNumberOfEvents, isAfterConditionSatisfied, this)); } OutputStrategyPostProcess postProcess = PostProcessFactory.Make(agentInstanceContext); return(new OutputProcessViewDirectDistinctOrAfterPostProcess( ResultSetProcessorHelperFactory, agentInstanceContext, resultSetProcessor, afterConditionTime, AfterConditionNumberOfEvents, isAfterConditionSatisfied, this, postProcess)); }
public bool UpdateOutputCondition(int newEventsCount, int oldEventsCount) { // If we pull the interval from a variable, then we may need to reschedule long msecIntervalSize = _timePeriod.NonconstEvaluator().DeltaMillisecondsUseEngineTime(null, _context); long current = _context.TimeProvider.Time; if (_lastUpdate == null || current - _lastUpdate >= msecIntervalSize) { _lastUpdate = current; return(true); } return(false); }
public long ComputeMilliseconds(MatchedEventMap beginState, PatternAgentInstanceContext context) { if (MillisecondsExpr is ExprTimePeriod) { ExprTimePeriod timePeriod = (ExprTimePeriod)MillisecondsExpr; return(timePeriod.NonconstEvaluator() .DeltaMillisecondsUseEngineTime(Convertor.Convert(beginState), context.AgentInstanceContext)); } else { Object millisecondVal = PatternExpressionUtil.Evaluate( "Timer-within guard", beginState, MillisecondsExpr, Convertor, context.AgentInstanceContext); if (millisecondVal == null) { throw new EPException("Timer-within guard expression returned a null-value"); } return((long)Math.Round(1000d * millisecondVal.AsDouble())); } }
/// <summary> /// Constructor. /// </summary> /// <param name="timePeriod">is the number of minutes or seconds to batch events for, may include variables</param> /// <param name="isStartConditionOnCreation">if set to <c>true</c> [is start condition on creation].</param> public OutputConditionTimeFactory(ExprTimePeriod timePeriod, bool isStartConditionOnCreation) { _timePeriod = timePeriod; _timePeriodDeltaComputation = timePeriod.NonconstEvaluator(); _isStartConditionOnCreation = isStartConditionOnCreation; }