public abstract void ApplyLeave(EventBean[] eventsPerStream, object optionalGroupKeyPerRow, ExprEvaluatorContext exprEvaluatorContext);
public EventBean EvaluateGetEventBean(EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { return(null); }
public ICollection <EventBean> EvaluateGetROCollectionEvents(EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { return(null); }
public abstract ICollection <object> EvaluateGetCollScalar(EventBean[] eventsPerStream, bool isNewData, ICollection <EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext);
public ExprTimePeriodEvalDeltaResult DeltaMillisecondsAddWReference(long current, long reference, EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { lock (this) { // find the next-nearest reference higher then the current time, compute delta, return reference one lower if (reference > current) { while (reference > current) { reference = reference - DeltaMillisecondsSubtract(reference, eventsPerStream, isNewData, context); } } long next = reference; long last; do { last = next; next = next + DeltaMillisecondsAdd(last, eventsPerStream, isNewData, context); } while (next <= current); return(new ExprTimePeriodEvalDeltaResult(next - current, last)); } }
public object GetConstantValue(ExprEvaluatorContext context) { return(_isConstant ? _valueIfConstant : null); }
public Object[][] EvaluateTypableMulti(EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { ICollection <EventBean> matching = _strategy.EvaluateMatching(eventsPerStream, context); return(EvaluateTypableMulti(eventsPerStream, isNewData, matching, context)); }
public object Evaluate(DateTimeOffset d, EventBean[] eventsPerStream, bool newData, ExprEvaluatorContext exprEvaluatorContext) { return(Action(d)); }
public Object EvaluateLookup(EventBean theEvent, ExprEvaluatorContext context) { events[lookupStream] = theEvent; return(keyEval.Evaluate(new EvaluateParams(events, true, context))); }
public TableOnMergeView(SubordWMatchExprLookupStrategy lookupStrategy, TableStateInstance rootView, ExprEvaluatorContext exprEvaluatorContext, TableMetadata metadata, TableOnMergeViewFactory parent) : base(lookupStrategy, rootView, exprEvaluatorContext, metadata, parent.OnMergeHelper.IsRequiresWriteLock) { this.parent = parent; }
public Object Evaluate(long ts, EventBean[] eventsPerStream, bool newData, ExprEvaluatorContext exprEvaluatorContext) { return(Action(ts.TimeFromMillis(null))); }
public object EvaluateEnumMethod(EventBean[] eventsLambda, ICollection <object> target, bool isNewData, ExprEvaluatorContext context) { int count = 0; foreach (EventBean next in target) { eventsLambda[StreamNumLambda] = next; var pass = (bool?)InnerExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context)); if (!pass.GetValueOrDefault(false)) { continue; } count++; } return(count); }
public void Evaluate(DateTimeEx dateTime, EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { dateTime.Set( ApacheCommonsDateUtils.Modify( dateTime.DateTime, _fieldName.ToDateTimeFieldEnum(), _code, dateTime.TimeZone)); }
public abstract void ClearResults(ExprEvaluatorContext exprEvaluatorContext);
public UniformPair <ISet <MultiKey <EventBean> > > Join(EventBean[][] newDataPerStream, EventBean[][] oldDataPerStream, ExprEvaluatorContext exprEvaluatorContext) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QJoinCompositionHistorical(); } _oldResults.Clear(); _newResults.Clear(); // join old data for (var i = 0; i < oldDataPerStream.Length; i++) { if (oldDataPerStream[i] != null) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QJoinCompositionQueryStrategy(false, i, oldDataPerStream[i]); } _queryStrategies[i].Lookup(oldDataPerStream[i], _oldResults, exprEvaluatorContext); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AJoinCompositionQueryStrategy(); } } } if (_repositories != null) { // We add and remove data in one call to each index. // Most indexes will add first then remove as newdata and olddata may contain the same event. // Unique indexes may remove then add. for (var stream = 0; stream < newDataPerStream.Length; stream++) { for (var j = 0; j < _repositories[stream].Length; j++) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QJoinCompositionStepUpdIndex(stream, newDataPerStream[stream], oldDataPerStream[stream]); } _repositories[stream][j].AddRemove(newDataPerStream[stream], oldDataPerStream[stream]); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AJoinCompositionStepUpdIndex(); } } } } // join new data for (var i = 0; i < newDataPerStream.Length; i++) { if (newDataPerStream[i] != null) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QJoinCompositionQueryStrategy(true, i, newDataPerStream[i]); } _queryStrategies[i].Lookup(newDataPerStream[i], _newResults, exprEvaluatorContext); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AJoinCompositionQueryStrategy(); } } } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AJoinCompositionHistorical(_newResults, _oldResults); } return(new UniformPair <ISet <MultiKey <EventBean> > >(_newResults, _oldResults)); }
public ICollection <object> EvaluateGetROCollectionScalar(EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { var result = Evaluate(new EvaluateParams(eventsPerStream, isNewData, context)); if (result == null) { return(null); } if (result is ICollection <object> ) { return((ICollection <object>)result); } if (result is Array) { return(((Array)result).Cast <object>().ToList()); } throw new ArgumentException("invalid result type returned from evaluate; expected array"); }
private bool? EvaluateInternal( EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext exprEvaluatorContext) { if (_evaluators.Length == 1) { return false; } var isAll = _forge.ForgeRenderable.IsAll; RelationalOpEnumComputer computer = _forge.Computer; var valueLeft = _evaluators[0].Evaluate(eventsPerStream, isNewData, exprEvaluatorContext); var len = _evaluators.Length - 1; if (_forge.IsCollectionOrArray) { var hasNonNullRow = false; var hasRows = false; for (var i = 1; i <= len; i++) { var valueRight = _evaluators[i].Evaluate(eventsPerStream, isNewData, exprEvaluatorContext); if (valueRight == null) { continue; } if (valueRight is Array valueRightArray) { hasRows = true; var arrayLength = valueRightArray.Length; for (var index = 0; index < arrayLength; index++) { object item = valueRightArray.GetValue(index); if (item == null) { if (isAll) { return null; } continue; } hasNonNullRow = true; if (valueLeft != null) { if (isAll) { if (!computer.Compare(valueLeft, item)) { return false; } } else { if (computer.Compare(valueLeft, item)) { return true; } } } } } else if (valueRight is IDictionary<object, object>) { var coll = (IDictionary<object, object>) valueRight; hasRows = true; foreach (object item in coll.Keys) { if (!(item.IsNumber())) { if (isAll && item == null) { return null; } continue; } hasNonNullRow = true; if (valueLeft != null) { if (isAll) { if (!computer.Compare(valueLeft, item)) { return false; } } else { if (computer.Compare(valueLeft, item)) { return true; } } } } } else if (valueRight is ICollection<object>) { var coll = (ICollection<object>) valueRight; hasRows = true; foreach (object item in coll) { if (!(item.IsNumber())) { if (isAll && item == null) { return null; } continue; } hasNonNullRow = true; if (valueLeft != null) { if (isAll) { if (!computer.Compare(valueLeft, item)) { return false; } } else { if (computer.Compare(valueLeft, item)) { return true; } } } } } else if (!(valueRight.IsNumber())) { if (isAll) { return null; } } else { hasNonNullRow = true; if (isAll) { if (!computer.Compare(valueLeft, valueRight)) { return false; } } else { if (computer.Compare(valueLeft, valueRight)) { return true; } } } } if (isAll) { if (!hasRows) { return true; } if (!hasNonNullRow || valueLeft == null) { return null; } return true; } if (!hasRows) { return false; } if (!hasNonNullRow || valueLeft == null) { return null; } return false; } else { var hasNonNullRow = false; var hasRows = false; for (var i = 1; i <= len; i++) { var valueRight = _evaluators[i].Evaluate(eventsPerStream, isNewData, exprEvaluatorContext); hasRows = true; if (valueRight != null) { hasNonNullRow = true; } else { if (isAll) { return null; } } if (valueRight != null && valueLeft != null) { if (isAll) { if (!computer.Compare(valueLeft, valueRight)) { return false; } } else { if (computer.Compare(valueLeft, valueRight)) { return true; } } } } if (isAll) { if (!hasRows) { return true; } if (!hasNonNullRow || valueLeft == null) { return null; } return true; } if (!hasRows) { return false; } if (!hasNonNullRow || valueLeft == null) { return null; } return false; } }
public EventBean EvaluateGetEventBean(EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { return(AggregationResultFuture.GetEventBean(Column, eventsPerStream, isNewData, context)); }
private ICollection <EventBean> EvaluateMatching(EventBean[] eventsPerStream, ExprEvaluatorContext exprEvaluatorContext) { return(_strategy.EvaluateMatching(eventsPerStream, exprEvaluatorContext)); }
public ICollection <EventBean> EvaluateGetROCollectionEvents(EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { return(AggregationResultFuture.GetCollectionOfEvents(Column, eventsPerStream, isNewData, context)); }
/// <summary> /// Evaluate the lookup expression returning an evaluation result object. /// </summary> /// <param name="eventsPerStream">is the events for each stream in a join</param> /// <param name="isNewData">is true for new data, or false for old data</param> /// <param name="matchingEvents">is filtered results from the table of stored lookup events</param> /// <param name="exprEvaluatorContext">context for expression evalauation</param> /// <returns>evaluation result</returns> public abstract Object Evaluate(EventBean[] eventsPerStream, bool isNewData, ICollection <EventBean> matchingEvents, ExprEvaluatorContext exprEvaluatorContext);
public ICollection <object> EvaluateGetROCollectionScalar(EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { var result = AggregationResultFuture.GetValue(Column, context.AgentInstanceId, eventsPerStream, isNewData, context); if (result == null) { return(null); } return(result.Unwrap <object>()); }
public long DeltaMillisecondsSubtract(long currentTime, EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { lock (this) { _dateTime.SetUtcMillis(currentTime); AddSubtract(_parent, _dateTime, -1, eventsPerStream, isNewData, context); return(_dateTime.TimeInMillis - currentTime); } }
protected internal static TimerScheduleSpec Compute( ExprEvaluator date, ExprEvaluator repetitions, TimePeriodEval timePeriod, EventBean[] eventsPerStream, ExprEvaluatorContext exprEvaluatorContext, TimeZoneInfo timeZone, TimeAbacus timeAbacus) { DateTimeEx optionalDate = null; long? optionalRemainder = null; if (date != null) { object param = PatternExpressionUtil.EvaluateChecked( TimerScheduleObserverForge.NAME_OBSERVER, date, eventsPerStream, exprEvaluatorContext); if (param is string) { optionalDate = TimerScheduleISO8601Parser.ParseDate((string) param); } else if (TypeHelper.IsNumber(param)) { long msec = param.AsInt64(); optionalDate = DateTimeEx.GetInstance(timeZone); optionalRemainder = timeAbacus.DateTimeSet(msec, optionalDate); } else if (param is DateTimeEx dateTimeEx) { optionalDate = DateTimeEx.GetInstance(timeZone, dateTimeEx); } else if (param is DateTime dateTime) { optionalDate = DateTimeEx.GetInstance(timeZone, dateTime); } else if (param is DateTimeOffset dateTimeOffset) { optionalDate = DateTimeEx.GetInstance(timeZone, dateTimeOffset); } else if (param == null) { throw new EPException("Null date-time value returned from date evaluation"); } else { throw new EPException("Unrecognized date-time value " + param.GetType()); } } TimePeriod optionalTimePeriod = null; if (timePeriod != null) { try { optionalTimePeriod = timePeriod.TimePeriodEval(eventsPerStream, true, exprEvaluatorContext); } catch (EPException) { throw; } catch (Exception ex) { PatternExpressionUtil.HandleRuntimeEx(ex, NAME_OBSERVER); } } long? optionalRepeatCount = null; if (repetitions != null) { object param = PatternExpressionUtil.EvaluateChecked( NAME_OBSERVER, repetitions, eventsPerStream, exprEvaluatorContext); if (param != null) { optionalRepeatCount = (param).AsInt64(); } } if (optionalDate == null && optionalTimePeriod == null) { throw new EPException("Required date or time period are both null for " + NAME_OBSERVER); } return new TimerScheduleSpec(optionalDate, optionalRemainder, optionalRepeatCount, optionalTimePeriod); }
private void AddSubtract(ExprTimePeriodImpl parent, DateTimeEx dateTime, int factor, EventBean[] eventsPerStream, bool newData, ExprEvaluatorContext context) { var adders = parent.Adders; var evaluators = parent.Evaluators; var evaluateParams = new EvaluateParams(eventsPerStream, newData, context); for (int i = 0; i < adders.Length; i++) { var value = evaluators[i].Evaluate(evaluateParams).AsInt(); adders[i].Add(dateTime, factor * value); } }
public Object EvaluateEnumMethod(EventBean[] eventsLambda, ICollection <object> target, bool isNewData, ExprEvaluatorContext context) { var map = new Dictionary <object, object>(); var resultEvent = new ObjectArrayEventBean(new Object[1], _resultEventType); var values = (ICollection <Object>)target; foreach (Object next in values) { resultEvent.Properties[0] = next; eventsLambda[StreamNumLambda] = resultEvent; var key = InnerExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context)); var value = _secondExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context)); map.Put(key, value); } return(map); }
private CountMinSketchSpec ValidateSpecification(ExprEvaluatorContext exprEvaluatorContext, EngineImportService engineImportService) { // default specification var spec = new CountMinSketchSpec(new CountMinSketchSpecHashes(DEFAULT__EPS_OF_TOTAL_COUNT, DEFAULT__CONFIDENCE, DEFAULT__SEED), null, DEFAULT__AGENT); // no parameters if (ChildNodes.Length == 0) { return(spec); } // check expected parameter type: a json object if (ChildNodes.Length > 1 || !(ChildNodes[0] is ExprConstantNode)) { throw DeclaredWrongParameterExpr; } var constantNode = (ExprConstantNode)ChildNodes[0]; var value = constantNode.GetConstantValue(exprEvaluatorContext); if (!(value is IDictionary <string, object>)) { throw DeclaredWrongParameterExpr; } // define what to populate var descriptors = new PopulateFieldWValueDescriptor[] { new PopulateFieldWValueDescriptor(NAME__EPS_OF_TOTAL_COUNT, typeof(double), spec.HashesSpec.GetType(), vv => { if (vv != null) { spec.HashesSpec.EpsOfTotalCount = (double)vv; } }, true), new PopulateFieldWValueDescriptor(NAME__CONFIDENCE, typeof(double), spec.HashesSpec.GetType(), vv => { if (vv != null) { spec.HashesSpec.Confidence = (double)vv; } }, true), new PopulateFieldWValueDescriptor(NAME__SEED, typeof(int), spec.HashesSpec.GetType(), vv => { if (vv != null) { spec.HashesSpec.Seed = (int)vv; } }, true), new PopulateFieldWValueDescriptor(NAME__TOPK, typeof(int), spec.GetType(), vv => { if (vv != null) { spec.TopkSpec = (int)vv; } }, true), new PopulateFieldWValueDescriptor(NAME__AGENT, typeof(string), spec.GetType(), vv => { if (vv != null) { CountMinSketchAgent transform; try { var transformClass = engineImportService.ResolveType((string)vv, false); transform = TypeHelper.Instantiate <CountMinSketchAgent>(transformClass.FullName); } catch (Exception e) { throw new ExprValidationException("Failed to instantiate agent provider: " + e.Message, e); } spec.Agent = transform; } }, true), }; // populate from json, validates incorrect names, coerces types, instantiates transform PopulateUtil.PopulateSpecCheckParameters(descriptors, (IDictionary <String, object>)value, spec, engineImportService); return(spec); }
public override void Apply(EventBean matchingEvent, EventBean[] eventsPerStream, TableStateInstance tableStateInstance, TableOnMergeViewChangeHandler changeHandlerAdded, TableOnMergeViewChangeHandler changeHandlerRemoved, ExprEvaluatorContext exprEvaluatorContext) { tableStateInstance.DeleteEvent(matchingEvent); if (changeHandlerRemoved != null) { changeHandlerRemoved.Add(matchingEvent, eventsPerStream, false, exprEvaluatorContext); } }
public void ApplyEnter(EventBean[] eventsPerStream, ExprEvaluatorContext exprEvaluatorContext, AggregationState aggregationState) { aggregationState.ApplyEnter(eventsPerStream, exprEvaluatorContext); }
public abstract ICollection <object> GetGroupKeys(ExprEvaluatorContext exprEvaluatorContext);