예제 #1
0
        public void SendEvent(Object theEvent)
        {
            EventBean eventBean = _eventAdapterService.AdapterForTypedAvro(theEvent, _eventType);

            if ((ThreadingOption.IsThreadingEnabled) && (_threadingService.IsInboundThreading))
            {
                _threadingService.SubmitInbound(new InboundUnitSendWrapped(eventBean, _runtimeEventSender).Run);
            }
            else
            {
                _runtimeEventSender.ProcessWrappedEvent(eventBean);
            }
        }
예제 #2
0
 /// <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, (BeanEventType)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 if (eventType is AvroSchemaEventType)
     {
         return(eventAdapterService.AdapterForTypedAvro(theEvent, eventType));
     }
     else
     {
         return(null);
     }
 }
예제 #3
0
 public EventBean Copy(EventBean theEvent)
 {
     var original = (GenericRecord) theEvent.Underlying;
     var copy = new GenericRecord(_avroEventType.SchemaAvro.AsRecordSchema());
     var fields = _avroEventType.SchemaAvro.GetFields();
     foreach (Field field in fields)
     {
         if (field.Schema.Tag == Schema.Type.Array)
         {
             var originalColl = original.Get(field).UnwrapEnumerable<object>(true);
             if (originalColl != null)
             {
                 copy.Put(field, new List<object>(originalColl));
             }
         }
         else if (field.Schema.Tag == Schema.Type.Map)
         {
             var originalMap = original.Get(field).UnwrapStringDictionary();
             if (originalMap != null)
             {
                 copy.Put(field, new Dictionary<string, object>(originalMap));
             }
         }
         else
         {
             object originalValue;
             if (original.TryGetValue(field.Name, out originalValue))
             {
                 copy.Add(field.Name, originalValue);
             }
         }
     }
     return _eventAdapterService.AdapterForTypedAvro(copy, _avroEventType);
 }
예제 #4
0
            public EventBean Process(EventBean[] eventsPerStream, bool isNewData, bool isSynthesize, ExprEvaluatorContext exprEvaluatorContext)
            {
                var evaluateParams = new EvaluateParams(eventsPerStream, isNewData, exprEvaluatorContext);
                var source         = ((AvroGenericDataBackedEventBean)eventsPerStream[_underlyingStreamNumber]).Properties;
                var target         = new GenericRecord(_resultSchema.AsRecordSchema());

                foreach (var item in _items)
                {
                    Object value;

                    if (item.OptionalFromField != null)
                    {
                        value = source.Get(item.OptionalFromField);
                    }
                    else
                    {
                        value = item.Evaluator.Evaluate(evaluateParams);
                        if (item.OptionalWidener != null)
                        {
                            value = item.OptionalWidener.Invoke(value);
                        }
                    }

                    target.Put(item.ToField, value);
                }

                return(_eventAdapterService.AdapterForTypedAvro(target, _resultType));
            }
예제 #5
0
 public EventBean Process(
     EventBean[] eventsPerStream,
     bool isNewData,
     bool isSynthesize,
     ExprEvaluatorContext exprEvaluatorContext)
 {
     return _eventAdapterService.AdapterForTypedAvro(eventsPerStream[0].Underlying, _resultEventType);
 }
 public Object GetFragment(EventBean eventBean)
 {
     if (_fragmentEventType == null)
     {
         return null;
     }
     Object value = Get(eventBean);
     if (value == null)
     {
         return null;
     }
     return _eventAdapterService.AdapterForTypedAvro(value, _fragmentEventType);
 }
예제 #7
0
 /// <summary>
 /// NOTE: Code-generation-invoked method, method name and parameter order matters
 /// </summary>
 /// <param name="value">value</param>
 /// <param name="eventAdapterService">svc</param>
 /// <param name="fragmentType">type</param>
 /// <returns>fragment</returns>
 public static Object GetFragmentAvro(Object value, EventAdapterService eventAdapterService, EventType fragmentType)
 {
     if (fragmentType == null)
     {
         return(null);
     }
     if (value is GenericRecord)
     {
         return(eventAdapterService.AdapterForTypedAvro(value, fragmentType));
     }
     if (value is ICollection <object> coll)
     {
         var events = new EventBean[coll.Count];
         int index  = 0;
         foreach (Object item in coll)
         {
             events[index++] = eventAdapterService.AdapterForTypedAvro(item, fragmentType);
         }
         return(events);
     }
     return(null);
 }
            public override EventBean Process(
                EventBean[] eventsPerStream,
                bool isNewData,
                bool isSynthesize,
                ExprEvaluatorContext exprEvaluatorContext)
            {
                var result = ExprEvaluator.Evaluate(new EvaluateParams(eventsPerStream, isNewData, exprEvaluatorContext));

                if (result == null)
                {
                    return(null);
                }
                return(EventAdapterService.AdapterForTypedAvro(result, EventType));
            }
예제 #9
0
 private Object GetFragmentInternal(Object value)
 {
     if (_fragmentType == null)
     {
         return null;
     }
     if (value is GenericRecord)
     {
         return _eventAdapterService.AdapterForTypedAvro(value, _fragmentType);
     }
     if (value is ICollection<object>)
     {
         var coll = (ICollection<object>) value;
         var events = new EventBean[coll.Count];
         int index = 0;
         foreach (Object item in coll)
         {
             events[index++] = _eventAdapterService.AdapterForTypedAvro(item, _fragmentType);
         }
         return events;
     }
     return null;
 }
예제 #10
0
        public object GetAvroFragment(GenericRecord record)
        {
            if (_fragmentEventType == null)
            {
                return(null);
            }
            var value = GetAvroFieldValue(record);

            if (value == null)
            {
                return(null);
            }
            return(_eventAdapterService.AdapterForTypedAvro(value, _fragmentEventType));
        }
예제 #11
0
 public EventBean Process(
     EventBean[] eventsPerStream,
     bool isNewData,
     bool isSynthesize,
     ExprEvaluatorContext exprEvaluatorContext)
 {
     var fields = _schema.Fields;
     var @event = new GenericRecord(_schema);
     for (int i = 0; i < eventsPerStream.Length; i++)
     {
         EventBean streamEvent = eventsPerStream[i];
         if (streamEvent != null)
         {
             var record = (GenericRecord) streamEvent.Underlying;
             @event.Put(fields[i], record);
         }
     }
     return _eventAdapterService.AdapterForTypedAvro(@event, _resultEventType);
 }
예제 #12
0
        public static EventBean[] TypeCast(
            IList <EventBean> events,
            EventType targetType,
            EventAdapterService eventAdapterService)
        {
            var convertedArray = new EventBean[events.Count];
            var count          = 0;

            foreach (var theEvent in events)
            {
                EventBean converted;
                if (theEvent is DecoratingEventBean)
                {
                    var wrapper = (DecoratingEventBean)theEvent;
                    if (targetType is MapEventType)
                    {
                        var props = new Dictionary <string, Object>();
                        props.PutAll(wrapper.DecoratingProperties);
                        foreach (var 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)
                {
                    var convertedObjectArray = ObjectArrayEventType.ConvertEvent(
                        theEvent, (ObjectArrayEventType)targetType);
                    converted = eventAdapterService.AdapterForTypedObjectArray(convertedObjectArray, targetType);
                }
                else if (theEvent.EventType is AvroSchemaEventType && targetType is AvroSchemaEventType)
                {
                    Object convertedGenericRecord = eventAdapterService.EventAdapterAvroHandler.ConvertEvent(
                        theEvent, (AvroSchemaEventType)targetType);
                    converted = eventAdapterService.AdapterForTypedAvro(convertedGenericRecord, targetType);
                }
                else
                {
                    throw new EPException("Unknown event type " + theEvent.EventType);
                }
                convertedArray[count] = converted;
                count++;
            }
            return(convertedArray);
        }
예제 #13
0
 public EventBean Make(Object[] properties)
 {
     Object record = MakeUnderlying(properties);
     return _eventAdapterService.AdapterForTypedAvro(record, _eventType);
 }
예제 #14
0
 public EventBean Wrap(Object underlying)
 {
     return(_eventAdapterService.AdapterForTypedAvro(underlying, _type));
 }