/// <summary> /// NOTE: Code-generation-invoked method, method name and parameter order matters /// </summary> /// <param name="value">value</param> /// <param name="fragmentEventType">fragment type</param> /// <param name="eventAdapterService">event adapter service</param> /// <returns>fragment</returns> public static object HandleBNCreateFragmentMap( object value, EventType fragmentEventType, EventAdapterService eventAdapterService) { if (value == null) { return(null); } if (value is Map valueAsMap) { return(eventAdapterService.AdapterForTypedMap(valueAsMap, fragmentEventType)); } if (value.GetType().IsGenericStringDictionary()) { var valueAsStringMap = value.AsStringDictionary(); return(eventAdapterService.AdapterForTypedMap(valueAsStringMap, fragmentEventType)); } if (value is EventBean) { return(value); } return(null); }
public object Get(EventBean theEvent) { if (!(theEvent is DecoratingEventBean)) throw new PropertyAccessException("Mismatched property getter to EventBean type"); var wrapperEvent = (DecoratingEventBean) theEvent; var map = wrapperEvent.DecoratingProperties; return _mapGetter.Get(_eventAdapterService.AdapterForTypedMap(map, _underlyingMapType)); }
public Object Evaluate(EvaluateParams evaluateParams) { var values = (IDictionary<string, Object>) _innerEvaluator.Evaluate(evaluateParams); if (values == null) { return _eventAdapterService.AdapterForTypedMap(Collections.EmptyDataMap, _mapType); } return _eventAdapterService.AdapterForTypedMap(values, _mapType); }
public static EventBean[] TypeCast(IList <EventBean> events, EventType targetType, EventAdapterService eventAdapterService) { var convertedArray = new EventBean[events.Count]; var count = 0; foreach (EventBean theEvent in events) { EventBean converted; if (theEvent is DecoratingEventBean) { var wrapper = (DecoratingEventBean)theEvent; if (targetType is MapEventType) { IDictionary <String, Object> props = new Dictionary <String, Object>(); props.PutAll(wrapper.DecoratingProperties); foreach (EventPropertyDescriptor propDesc in wrapper.UnderlyingEvent.EventType.PropertyDescriptors) { props.Put(propDesc.PropertyName, wrapper.UnderlyingEvent.Get(propDesc.PropertyName)); } converted = eventAdapterService.AdapterForTypedMap(props, targetType); } else { converted = eventAdapterService.AdapterForTypedWrapper(wrapper.UnderlyingEvent, wrapper.DecoratingProperties, targetType); } } else if ((theEvent.EventType is MapEventType) && (targetType is MapEventType)) { var mapEvent = (MappedEventBean)theEvent; converted = eventAdapterService.AdapterForTypedMap(mapEvent.Properties, targetType); } else if ((theEvent.EventType is MapEventType) && (targetType is WrapperEventType)) { converted = eventAdapterService.AdapterForTypedWrapper(theEvent, Collections.EmptyDataMap, targetType); } else if ((theEvent.EventType is BeanEventType) && (targetType is BeanEventType)) { converted = eventAdapterService.AdapterForTypedObject(theEvent.Underlying, targetType); } else if (theEvent.EventType is ObjectArrayEventType && targetType is ObjectArrayEventType) { Object[] convertedObjectArray = ObjectArrayEventType.ConvertEvent(theEvent, (ObjectArrayEventType)targetType); converted = eventAdapterService.AdapterForTypedObjectArray(convertedObjectArray, targetType); } else { throw new EPException("Unknown event type " + theEvent.EventType); } convertedArray[count] = converted; count++; } return(convertedArray); }
public void Update(Object newValue, Object oldValue) { if (_statementResultService.IsMakeNatural || _statementResultService.IsMakeSynthetic) { IDictionary <String, Object> valuesOld = new Dictionary <String, Object>(); valuesOld.Put(_variableName, oldValue); EventBean eventOld = _eventAdapterService.AdapterForTypedMap(valuesOld, _eventType); IDictionary <String, Object> valuesNew = new Dictionary <String, Object>(); valuesNew.Put(_variableName, newValue); EventBean eventNew = _eventAdapterService.AdapterForTypedMap(valuesNew, _eventType); UpdateChildren(new[] { eventNew }, new[] { eventOld }); } }
public static EventBean DoPopulateMap(BaseStatisticsBean baseStatisticsBean, EventAdapterService eventAdapterService, EventType eventType, StatViewAdditionalProps additionalProps, Object[] decoration) { IDictionary <String, Object> result = new Dictionary <String, Object>(); result.Put(ViewFieldEnum.REGRESSION__SLOPE.GetName(), baseStatisticsBean.Slope); result.Put(ViewFieldEnum.REGRESSION__YINTERCEPT.GetName(), baseStatisticsBean.YIntercept); result.Put(ViewFieldEnum.REGRESSION__XAVERAGE.GetName(), baseStatisticsBean.XAverage); result.Put(ViewFieldEnum.REGRESSION__XSTANDARDDEVIATIONPOP.GetName(), baseStatisticsBean.XStandardDeviationPop); result.Put(ViewFieldEnum.REGRESSION__XSTANDARDDEVIATIONSAMPLE.GetName(), baseStatisticsBean.XStandardDeviationSample); result.Put(ViewFieldEnum.REGRESSION__XSUM.GetName(), baseStatisticsBean.XSum); result.Put(ViewFieldEnum.REGRESSION__XVARIANCE.GetName(), baseStatisticsBean.XVariance); result.Put(ViewFieldEnum.REGRESSION__YAVERAGE.GetName(), baseStatisticsBean.YAverage); result.Put(ViewFieldEnum.REGRESSION__YSTANDARDDEVIATIONPOP.GetName(), baseStatisticsBean.YStandardDeviationPop); result.Put(ViewFieldEnum.REGRESSION__YSTANDARDDEVIATIONSAMPLE.GetName(), baseStatisticsBean.YStandardDeviationSample); result.Put(ViewFieldEnum.REGRESSION__YSUM.GetName(), baseStatisticsBean.YSum); result.Put(ViewFieldEnum.REGRESSION__YVARIANCE.GetName(), baseStatisticsBean.YVariance); result.Put(ViewFieldEnum.REGRESSION__DATAPOINTS.GetName(), baseStatisticsBean.DataPoints); result.Put(ViewFieldEnum.REGRESSION__N.GetName(), baseStatisticsBean.N); result.Put(ViewFieldEnum.REGRESSION__SUMX.GetName(), baseStatisticsBean.SumX); result.Put(ViewFieldEnum.REGRESSION__SUMXSQ.GetName(), baseStatisticsBean.SumXSq); result.Put(ViewFieldEnum.REGRESSION__SUMXY.GetName(), baseStatisticsBean.SumXY); result.Put(ViewFieldEnum.REGRESSION__SUMY.GetName(), baseStatisticsBean.SumY); result.Put(ViewFieldEnum.REGRESSION__SUMYSQ.GetName(), baseStatisticsBean.SumYSq); if (additionalProps != null) { additionalProps.AddProperties(result, decoration); } return(eventAdapterService.AdapterForTypedMap(result, eventType)); }
public static Object HandleNestedValueArrayWithMapFragment(Object value, int index, MapEventPropertyGetter getter, EventAdapterService eventAdapterService, EventType fragmentType) { var asArray = value as Array; if (asArray == null) { return(null); } if (asArray.Length <= index) { return(null); } var valueMap = asArray.GetValue(index); if (!(valueMap is DataMap)) { if (valueMap is EventBean) { return(getter.GetFragment((EventBean)valueMap)); } return(null); } // If the map does not contain the key, this is allowed and represented as null var eventBean = eventAdapterService.AdapterForTypedMap((IDictionary <String, Object>)valueMap, fragmentType); return(getter.GetFragment(eventBean)); }
/// <summary>Return an adapter for the given type of event using the pre-validated object. </summary> /// <param name="theEvent">value object</param> /// <param name="eventType">type of event</param> /// <param name="eventAdapterService">service for instances</param> /// <returns>event adapter</returns> public static EventBean AdapterForType(Object theEvent, EventType eventType, EventAdapterService eventAdapterService) { if (theEvent == null) { return(null); } if (eventType is BeanEventType) { return(eventAdapterService.AdapterForTypedObject(theEvent, eventType)); } else if (eventType is MapEventType) { return(eventAdapterService.AdapterForTypedMap((IDictionary <string, object>)theEvent, eventType)); } else if (eventType is ObjectArrayEventType) { return(eventAdapterService.AdapterForTypedObjectArray((Object[])theEvent, eventType)); } else if (eventType is BaseConfigurableEventType) { return(eventAdapterService.AdapterForTypedDOM((XmlNode)theEvent, eventType)); } else { return(null); } }
public EventBean Copy(EventBean theEvent) { var mapped = (MappedEventBean)theEvent; var props = mapped.Properties; var shallowCopy = new Dictionary <String, Object>(props); foreach (var name in _mapPropertiesToCopy) { var innerMap = (IDictionary <String, Object>)props.Get(name); if (innerMap != null) { var copy = new Dictionary <String, Object>(innerMap); shallowCopy.Put(name, copy); } } foreach (var name in _arrayPropertiesToCopy) { var array = props.Get(name) as Array; if (array != null && (array.Length != 0)) { var copied = Array.CreateInstance(array.GetType().GetElementType(), array.Length); Array.Copy(array, 0, copied, 0, array.Length); shallowCopy.Put(name, copied); } } return(_eventAdapterService.AdapterForTypedMap(shallowCopy, _mapEventType)); }
public override object GetFilterValue(MatchedEventMap matchedEvents, AgentInstanceContext agentInstanceContext) { EventBean[] events = null; if ((_taggedEventTypes != null && !_taggedEventTypes.IsEmpty()) || (_arrayEventTypes != null && !_arrayEventTypes.IsEmpty())) { var size = 0; size += (_taggedEventTypes != null) ? _taggedEventTypes.Count : 0; size += (_arrayEventTypes != null) ? _arrayEventTypes.Count : 0; events = new EventBean[size + 1]; var count = 1; if (_taggedEventTypes != null) { foreach (var tag in _taggedEventTypes.Keys) { events[count] = matchedEvents.GetMatchingEventByTag(tag); count++; } } if (_arrayEventTypes != null) { foreach (var entry in _arrayEventTypes) { var compositeEventType = entry.Value.First; events[count] = _eventAdapterService.AdapterForTypedMap(matchedEvents.MatchingEventsAsMap, compositeEventType); count++; } } } return(_filterBooleanExpressionFactory.Make(this, events, agentInstanceContext, agentInstanceContext.StatementContext, agentInstanceContext.AgentInstanceId)); }
public override EventBean ProcessFirstCol(Object result) { var wrappedEvent = EventAdapterService.AdapterForTypedMap((IDictionary <string, object>)result, ResultEventType); return(_vaeProcessor.GetValueAddEventBean( EventAdapterService.AdapterForTypedWrapper(wrappedEvent, new Dictionary <string, object>(), _vaeInnerEventType))); }
public EventBean Copy(EventBean theEvent) { var mapped = (MappedEventBean)theEvent; IDictionary <string, object> props = mapped.Properties; return(_eventAdapterService.AdapterForTypedMap(new Dictionary <String, Object>(props), _mapEventType)); }
/// <summary> /// NOTE: Code-generation-invoked method, method name and parameter order matters /// </summary> /// <param name="value">value</param> /// <param name="fragmentEventType">fragment type</param> /// <param name="eventAdapterService">svc</param> /// <returns>fragment</returns> public static object GetBNFragmentArray( object value, EventType fragmentEventType, EventAdapterService eventAdapterService) { if (value is object[] subEvents) { var countNullInner = 0; foreach (var subEvent in subEvents) { if (subEvent != null) { countNullInner++; } } var outEvents = new EventBean[countNullInner]; var countInner = 0; foreach (var item in subEvents) { if (item != null) { outEvents[countInner++] = GetBNFragmentNonPono(item, fragmentEventType, eventAdapterService); } } return(outEvents); } if (!(value is Map[])) { return(null); } var mapTypedSubEvents = (Map[])value; var countNull = 0; foreach (var map in mapTypedSubEvents) { if (map != null) { countNull++; } } var mapEvents = new EventBean[countNull]; var count = 0; foreach (var map in mapTypedSubEvents) { if (map != null) { mapEvents[count++] = eventAdapterService.AdapterForTypedMap(map, fragmentEventType); } } return(mapEvents); }
public void SendEvent(Object theEvent) { if (!(theEvent is DataMap)) { throw new EPException("Unexpected event object of type " + theEvent.GetType().FullName + ", expected " + typeof(DataMap).FullName); } var map = (DataMap)theEvent; EventBean mapEvent = _eventAdapterService.AdapterForTypedMap(map, _mapEventType); if ((ThreadingOption.IsThreadingEnabledValue) && (_threadingService.IsInboundThreading)) { _threadingService.SubmitInbound(() => _runtimeEventSender.ProcessWrappedEvent(mapEvent)); } else { _runtimeEventSender.ProcessWrappedEvent(mapEvent); } }
public override EventBean Process(EventBean[] eventsPerStream, bool isNewData, bool isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { var evaluateParams = new EvaluateParams(eventsPerStream, isNewData, exprEvaluatorContext); var result = ExprEvaluator.Evaluate(evaluateParams); if (result == null) { return(null); } return(EventAdapterService.AdapterForTypedMap((IDictionary <string, object>)result, EventType)); }
public static EventBean GetFragmentNonPono(EventAdapterService eventAdapterService, Object fragmentUnderlying, EventType fragmentEventType) { if (fragmentUnderlying == null) { return(null); } if (fragmentEventType is MapEventType) { return(eventAdapterService.AdapterForTypedMap((IDictionary <String, Object>)fragmentUnderlying, fragmentEventType)); } return(eventAdapterService.AdapterForTypedObjectArray(fragmentUnderlying.UnwrapIntoArray <object>(true), fragmentEventType)); }
public override object HandleNestedValueFragment(object value) { if (!(value is Map)) { if (value is EventBean) return _mapGetter.GetFragment((EventBean) value); return null; } // If the map does not contain the key, this is allowed and represented as null var eventBean = EventAdapterService.AdapterForTypedMap((IDictionary<string, object>) value, FragmentType); return _mapGetter.GetFragment(eventBean); }
protected override EventBean GetEventBean(Object value) { try { var valueDataMap = value.UnwrapDictionary(); return(EventAdapterService.AdapterForTypedMap(valueDataMap, EventType)); } catch (ArgumentException) { Log.Warn("Expected map-type for value, but received type '" + value.GetType() + "'"); throw new EPException("Expected map-type for value, but received type '" + value.GetType() + "'"); } }
public static Object GetFragmentArray(EventAdapterService eventAdapterService, Object value, EventType fragmentEventType) { var mapTypedSubEvents = value as DataMap[]; if (mapTypedSubEvents != null) { var countNull = 0; foreach (var map in mapTypedSubEvents) { if (map != null) { countNull++; } } var mapEvents = new EventBean[countNull]; var count = 0; foreach (var map in mapTypedSubEvents) { if (map != null) { mapEvents[count++] = eventAdapterService.AdapterForTypedMap(map, fragmentEventType); } } return(mapEvents); } var subEvents = value as Object[]; if (subEvents != null) { var subCountNull = subEvents.Count(subEvent => subEvent != null); var outEvents = new EventBean[subCountNull]; var outCount = 0; foreach (var item in subEvents) { if (item != null) { outEvents[outCount++] = BaseNestableEventUtil.GetFragmentNonPono(eventAdapterService, item, fragmentEventType); } } return(outEvents); } return(null); }
public static Object HandleCreateFragmentMap(Object value, EventType fragmentEventType, EventAdapterService eventAdapterService) { if (!(value is DataMap)) { if (value is EventBean) { return(value); } return(null); } var subEvent = (DataMap)value; return(eventAdapterService.AdapterForTypedMap(subEvent, fragmentEventType)); }
public override Object HandleNestedValueFragment(Object value) { if (!(value is Map)) { if (value is EventBean) { return _mapGetter.GetFragment((EventBean)value); } return null; } // If the map does not contain the key, this is allowed and represented as null EventBean eventBean = EventAdapterService.AdapterForTypedMap((Map) value, FragmentType); return _mapGetter.GetFragment(eventBean); }
/// <summary>Populate bean. </summary> /// <param name="baseStatisticsBean">results</param> /// <param name="eventAdapterService">event wrapping</param> /// <param name="eventType">type to produce</param> /// <param name="additionalProps">addition properties</param> /// <param name="decoration">decoration values</param> /// <returns>bean</returns> public static EventBean DoPopulateMap(BaseStatisticsBean baseStatisticsBean, EventAdapterService eventAdapterService, EventType eventType, StatViewAdditionalProps additionalProps, Object[] decoration) { IDictionary <String, Object> result = new Dictionary <String, Object>(); result.Put(ViewFieldEnum.CORRELATION__CORRELATION.GetName(), baseStatisticsBean.Correlation); if (additionalProps != null) { additionalProps.AddProperties(result, decoration); } return(eventAdapterService.AdapterForTypedMap(result, eventType)); }
public EventBean Process(EventBean[] eventsPerStream, bool isNewData, bool isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { IDictionary <String, Object> tuple = new Dictionary <String, Object>(); for (int i = 0; i < _streamNames.Length; i++) { if (_streamNames[i] == null) { throw new IllegalStateException("Event name for stream " + i + " is null"); } tuple.Put(_streamNames[i], eventsPerStream[i]); } return(_eventAdapterService.AdapterForTypedMap(tuple, _resultEventType)); }
/// <summary> /// NOTE: Code-generation-invoked method, method name and parameter order matters /// </summary> /// <param name="fragmentUnderlying">fragment</param> /// <param name="fragmentEventType">type</param> /// <param name="eventAdapterService">svc</param> /// <returns>bean</returns> public static EventBean GetBNFragmentNonPono( object fragmentUnderlying, EventType fragmentEventType, EventAdapterService eventAdapterService) { if (fragmentUnderlying == null) { return(null); } if (fragmentEventType is MapEventType) { return(eventAdapterService.AdapterForTypedMap((IDictionary <string, object>)fragmentUnderlying, fragmentEventType)); } return(eventAdapterService.AdapterForTypedObjectArray((object[])fragmentUnderlying, fragmentEventType)); }
public static object HandleBNNestedValueArrayWithMapFragment(object value, int index, MapEventPropertyGetter getter, EventAdapterService eventAdapterService, EventType fragmentType) { var valueMap = GetBNArrayValueAtIndex(value, index); if (valueMap is Map valueMapAsMap) { // If the map does not contain the key, this is allowed and represented as null var eventBean = eventAdapterService.AdapterForTypedMap(valueMapAsMap, fragmentType); return(getter.GetFragment(eventBean)); } if (value is EventBean bean) { return(getter.GetFragment(bean)); } return(null); }
public static EventBean PopulateMap(BaseStatisticsBean baseStatisticsBean, EventAdapterService eventAdapterService, EventType eventType, StatViewAdditionalProps additionalProps, Object[] lastNewValues) { var result = new Dictionary <string, object>(); result.Put(ViewFieldEnum.UNIVARIATE_STATISTICS__DATAPOINTS.GetName(), baseStatisticsBean.N); result.Put(ViewFieldEnum.UNIVARIATE_STATISTICS__TOTAL.GetName(), baseStatisticsBean.XSum); result.Put(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEV.GetName(), baseStatisticsBean.XStandardDeviationSample); result.Put(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEVPA.GetName(), baseStatisticsBean.XStandardDeviationPop); result.Put(ViewFieldEnum.UNIVARIATE_STATISTICS__VARIANCE.GetName(), baseStatisticsBean.XVariance); result.Put(ViewFieldEnum.UNIVARIATE_STATISTICS__AVERAGE.GetName(), baseStatisticsBean.XAverage); if (additionalProps != null) { additionalProps.AddProperties(result, lastNewValues); } return(eventAdapterService.AdapterForTypedMap(result, eventType)); }
public EventBean Make(Object[] properties) { var values = (IDictionary <string, object>)MakeUnderlying(properties); return(_eventAdapterService.AdapterForTypedMap(values, _mapEventType)); }
protected override EventBean GetEventBean(object value) { var valueDataMap = value.UnwrapStringDictionary(); return(EventAdapterService.AdapterForTypedMap(valueDataMap, EventType)); }
public EventBean Process(EventBean[] eventsPerStream, bool isNewData, bool isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { var theEvent = (MappedEventBean)eventsPerStream[0]; return(_eventAdapterService.AdapterForTypedMap(theEvent.Properties, _resultEventType)); }
public override EventBean ProcessSpecific(IDictionary <String, Object> props, EventBean[] eventsPerStream, bool isNewData, bool isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { return(_vaeProcessor.GetValueAddEventBean(EventAdapterService.AdapterForTypedMap(props, _vaeInnerEventType))); }