public EventBean AdapterForAvro( object avroGenericDataDotRecord, string eventTypeName) { var eventType = FindType(eventTypeName); return typedEventFactory.AdapterForTypedAvro(avroGenericDataDotRecord, eventType); }
/// <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, EventBeanTypedEventFactory eventAdapterService, EventType fragmentType) { if (fragmentType == null) { return null; } if (value is GenericRecord) { return eventAdapterService.AdapterForTypedAvro(value, fragmentType); } if (value is ICollection<object> valueAsCollection) { var events = new EventBean[valueAsCollection.Count]; var index = 0; foreach (var item in valueAsCollection) { events[index++] = eventAdapterService.AdapterForTypedAvro(item, fragmentType); } return events; } return null; }
public void SendEvent(object theEvent) { var eventBean = eventBeanTypedEventFactory.AdapterForTypedAvro(theEvent, eventType); if (threadingService.IsInboundThreading) { threadingService.SubmitInbound(eventBean, runtimeEventSender); } else { runtimeEventSender.ProcessWrappedEvent(eventBean); } }
public EventBean Process( EventBean[] eventsPerStream, bool isNewData, bool isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { AvroGenericDataBackedEventBean theEvent = (AvroGenericDataBackedEventBean) eventsPerStream[_underlyingStreamNumber]; GenericRecord source = theEvent.Properties; GenericRecord target = new GenericRecord(_resultSchema.AsRecordSchema()); foreach (var item in _items) { object value; if (item.OptionalFromIndex != null) { value = source.Get(item.OptionalFromIndex); } else { value = item.EvaluatorAssigned.Evaluate(eventsPerStream, isNewData, exprEvaluatorContext); if (item.OptionalWidener != null) { value = item.OptionalWidener.Widen(value); } } target.Put(item.ToIndex, value); } return _eventAdapterService.AdapterForTypedAvro(target, ResultEventType); }
public EventBean Copy(EventBean theEvent) { var original = (GenericRecord) theEvent.Underlying; var copy = new GenericRecord(_avroEventType.SchemaAvro.AsRecordSchema()); var fields = _avroEventType.SchemaAvro.GetFields(); foreach (var field in fields) { if (field.Schema.Tag == Schema.Type.Array) { var originalValue = original.Get(field); if (originalValue == null) { } else if (originalValue is Array originalArray) { var copyArray = Array.CreateInstance( originalArray.GetType().GetElementType(), originalArray.Length); Array.Copy(originalArray, 0, copyArray, 0, copyArray.Length); copy.Put(field, copyArray); } else if (originalValue.GetType().IsGenericCollection()) { var elementType = originalValue.GetType().GetCollectionItemType(); var copyList = Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType)); throw new NotImplementedException(); } } else if (field.Schema.Tag == Schema.Type.Map) { var originalMap = (IDictionary<string, object>) original.Get(field); if (originalMap != null) { copy.Put(field, new Dictionary<string, object>(originalMap)); } } else { copy.Put(field, original.Get(field)); } } return _eventAdapterService.AdapterForTypedAvro(copy, _avroEventType); }
public object GetAvroFragment(GenericRecord record) { if (_fragmentEventType == null) { return null; } var value = GetAvroFieldValue(record); if (value == null) { return null; } return _eventAdapterService.AdapterForTypedAvro(value, _fragmentEventType); }
public object GetFragment(EventBean eventBean) { if (_fragmentEventType == null) { return null; } var value = Get(eventBean); if (value == null) { return null; } return _eventAdapterService.AdapterForTypedAvro(value, _fragmentEventType); }
/// <summary> /// NOTE: Code-generation-invoked method, method name and parameter order matters /// </summary> /// <param name="eventsPerStream">events</param> /// <param name="schema">schema</param> /// <param name="eventAdapterService">event svc</param> /// <param name="resultEventType">result event type</param> /// <returns>bean</returns> public static EventBean ProcessSelectExprJoinWildcardAvro( EventBean[] eventsPerStream, Schema schema, EventBeanTypedEventFactory eventAdapterService, EventType resultEventType) { var fields = schema.AsRecordSchema().Fields; var @event = new GenericRecord(schema.AsRecordSchema()); for (var i = 0; i < eventsPerStream.Length; i++) { var streamEvent = eventsPerStream[i]; if (streamEvent != null) { var record = (GenericRecord) streamEvent.Underlying; @event.Put(fields[i], record); } } return eventAdapterService.AdapterForTypedAvro(@event, resultEventType); }
public EventBean Wrap(object underlying) { return _eventAdapterService.AdapterForTypedAvro(underlying, _type); }
public EventBean Make(object[] properties) { var record = MakeUnderlying(properties); return _eventAdapterService.AdapterForTypedAvro(record, _eventType); }