/// <summary>
 ///     Ctor.
 /// </summary>
 public ConfigurationCommonEventTypeMeta()
 {
     _classPropertyResolutionStyle = PropertyResolutionStyle.DEFAULT;
     _defaultAccessorStyle = AccessorStyle.NATIVE;
     _defaultEventRepresentation = EventUnderlyingTypeExtensions.GetDefault();
     _avroSettings = new AvroSettingsConfig();
 }
Esempio n. 2
0
 /// <summary>
 ///     Returns the class name of the default underlying type.
 /// </summary>
 /// <returns>default underlying type class name</returns>
 public static string GetUnderlyingClassName(this EventUnderlyingType underlyingType)
 {
     return underlyingType switch {
         EventUnderlyingType.OBJECTARRAY => typeof(object[]).FullName,
         EventUnderlyingType.MAP => typeof(IDictionary<string, object>).FullName,
         EventUnderlyingType.AVRO => AvroConstantsNoDep.GENERIC_RECORD_CLASSNAME,
         EventUnderlyingType.JSON => typeof(object).FullName,
         _ => throw new ArgumentException("invalid value", nameof(underlyingType))
     };
 }
Esempio n. 3
0
        /// <summary>
        ///     Returns the class name of the default underlying type.
        /// </summary>
        /// <returns>default underlying type class name</returns>
        public static string GetUnderlyingClassName(this EventUnderlyingType underlyingType)
        {
            switch (underlyingType) {
                case EventUnderlyingType.OBJECTARRAY:
                    return OA_TYPE_NAME;

                case EventUnderlyingType.MAP:
                    return MAP_TYPE_NAME;

                case EventUnderlyingType.AVRO:
                    return AVRO_TYPE_NAME;
            }

            throw new ArgumentException("invalid value", nameof(underlyingType));
        }
Esempio n. 4
0
        /// <summary>
        ///     Returns the class name of the default underlying type.
        /// </summary>
        /// <returns>default underlying type</returns>
        public static Type GetUnderlyingClass(this EventUnderlyingType underlyingType)
        {
            switch (underlyingType) {
                case EventUnderlyingType.OBJECTARRAY:
                    return typeof(object[]);
                case EventUnderlyingType.MAP:
                    return typeof(IDictionary<string, object>);
                case EventUnderlyingType.AVRO:
                    return null;
                case EventUnderlyingType.JSON:
                    return typeof(object);
            }

            throw new ArgumentException("invalid value", nameof(underlyingType));
        }
Esempio n. 5
0
        /// <summary>
        /// Returns the class name of the default underlying type.
        /// </summary>
        /// <returns>default underlying type class name</returns>
        public static string GetUnderlyingClassName(this EventUnderlyingType enumValue)
        {
            switch (enumValue)
            {
            case EventUnderlyingType.OBJECTARRAY:
                return(OA_TYPE_NAME);

            case EventUnderlyingType.MAP:
                return(MAP_TYPE_NAME);

            case EventUnderlyingType.AVRO:
                return(AVRO_TYPE_NAME);
            }

            throw new ArgumentException("illegal enum value");
        }
Esempio n. 6
0
        public static EventUnderlyingType GetRepresentation(
            Attribute[] annotations,
            ConfigurationInformation configs,
            AssignedType assignedType)
        {
            // assigned type has priority
            if (assignedType == AssignedType.OBJECTARRAY)
            {
                return(EventUnderlyingType.OBJECTARRAY);
            }
            else if (assignedType == AssignedType.MAP)
            {
                return(EventUnderlyingType.MAP);
            }
            else if (assignedType == AssignedType.AVRO)
            {
                return(EventUnderlyingType.AVRO);
            }
            if (assignedType == AssignedType.VARIANT ||
                assignedType != AssignedType.NONE)
            {
                throw new IllegalStateException("Not handled by event representation: " + assignedType);
            }

            // annotation has second priority
            var annotation = AnnotationUtil.FindAnnotation(annotations, typeof(EventRepresentationAttribute));

            if (annotation != null)
            {
                EventRepresentationAttribute eventRepresentation = (EventRepresentationAttribute)annotation;
                if (eventRepresentation.Value == EventUnderlyingType.AVRO)
                {
                    return(EventUnderlyingType.AVRO);
                }
                else if (eventRepresentation.Value == EventUnderlyingType.OBJECTARRAY)
                {
                    return(EventUnderlyingType.OBJECTARRAY);
                }
                else if (eventRepresentation.Value == EventUnderlyingType.MAP)
                {
                    return(EventUnderlyingType.MAP);
                }
                else
                {
                    throw new IllegalStateException("Unrecognized enum " + eventRepresentation.Value);
                }
            }

            // use engine-wide default
            EventUnderlyingType configured = configs.EngineDefaults.EventMeta.DefaultEventRepresentation;

            if (configured == EventUnderlyingType.OBJECTARRAY)
            {
                return(EventUnderlyingType.OBJECTARRAY);
            }
            else if (configured == EventUnderlyingType.MAP)
            {
                return(EventUnderlyingType.MAP);
            }
            else if (configured == EventUnderlyingType.AVRO)
            {
                return(EventUnderlyingType.AVRO);
            }
            return(EventUnderlyingType.MAP);
        }
Esempio n. 7
0
        public static SelectExprProcessor Create(
            ICollection <int> assignedTypeNumberStack,
            int statementId,
            string statementName,
            string[] streamNames,
            EventType[] streamTypes,
            EventAdapterService eventAdapterService,
            InsertIntoDesc insertIntoDesc,
            SelectExprEventTypeRegistry selectExprEventTypeRegistry,
            EngineImportService engineImportService,
            Attribute[] annotations,
            ConfigurationInformation configuration,
            TableService tableService,
            string engineURI)

        {
            if ((streamNames.Length < 2) || (streamTypes.Length < 2) || (streamNames.Length != streamTypes.Length))
            {
                throw new ArgumentException(
                          "Stream names and types parameter length is invalid, expected use of this class is for join statements");
            }

            // Create EventType of result join events
            var  selectProperties   = new LinkedHashMap <string, Object>();
            var  streamTypesWTables = new EventType[streamTypes.Length];
            bool hasTables          = false;

            for (int i = 0; i < streamTypes.Length; i++)
            {
                streamTypesWTables[i] = streamTypes[i];
                string tableName = TableServiceUtil.GetTableNameFromEventType(streamTypesWTables[i]);
                if (tableName != null)
                {
                    hasTables             = true;
                    streamTypesWTables[i] = tableService.GetTableMetadata(tableName).PublicEventType;
                }
                selectProperties.Put(streamNames[i], streamTypesWTables[i]);
            }

            // If we have a name for this type, add it
            EventUnderlyingType representation = EventRepresentationUtil.GetRepresentation(
                annotations, configuration, AssignedType.NONE);
            EventType resultEventType;

            SelectExprProcessor processor = null;

            if (insertIntoDesc != null)
            {
                EventType existingType = eventAdapterService.GetEventTypeByName(insertIntoDesc.EventTypeName);
                if (existingType != null)
                {
                    processor = SelectExprInsertEventBeanFactory.GetInsertUnderlyingJoinWildcard(
                        eventAdapterService, existingType, streamNames, streamTypesWTables, engineImportService,
                        statementName, engineURI);
                }
            }

            if (processor == null)
            {
                if (insertIntoDesc != null)
                {
                    try
                    {
                        if (representation == EventUnderlyingType.MAP)
                        {
                            resultEventType = eventAdapterService.AddNestableMapType(
                                insertIntoDesc.EventTypeName, selectProperties, null, false, false, false, false, true);
                        }
                        else if (representation == EventUnderlyingType.OBJECTARRAY)
                        {
                            resultEventType = eventAdapterService.AddNestableObjectArrayType(
                                insertIntoDesc.EventTypeName, selectProperties, null, false, false, false, false, true,
                                false, null);
                        }
                        else if (representation == EventUnderlyingType.AVRO)
                        {
                            resultEventType = eventAdapterService.AddAvroType(
                                insertIntoDesc.EventTypeName, selectProperties, false, false, false, false, true,
                                annotations, null, statementName, engineURI);
                        }
                        else
                        {
                            throw new IllegalStateException("Unrecognized code " + representation);
                        }
                        selectExprEventTypeRegistry.Add(resultEventType);
                    }
                    catch (EventAdapterException ex)
                    {
                        throw new ExprValidationException(ex.Message, ex);
                    }
                }
                else
                {
                    if (representation == EventUnderlyingType.MAP)
                    {
                        resultEventType =
                            eventAdapterService.CreateAnonymousMapType(
                                statementId + "_join_" + CollectionUtil.ToString(assignedTypeNumberStack, "_"),
                                selectProperties, true);
                    }
                    else if (representation == EventUnderlyingType.OBJECTARRAY)
                    {
                        resultEventType =
                            eventAdapterService.CreateAnonymousObjectArrayType(
                                statementId + "_join_" + CollectionUtil.ToString(assignedTypeNumberStack, "_"),
                                selectProperties);
                    }
                    else if (representation == EventUnderlyingType.AVRO)
                    {
                        resultEventType =
                            eventAdapterService.CreateAnonymousAvroType(
                                statementId + "_join_" + CollectionUtil.ToString(assignedTypeNumberStack, "_"),
                                selectProperties, annotations, statementName, engineURI);
                    }
                    else
                    {
                        throw new IllegalStateException("Unrecognized enum " + representation);
                    }
                }
                if (resultEventType is ObjectArrayEventType)
                {
                    processor = new SelectExprJoinWildcardProcessorObjectArray(
                        streamNames, resultEventType, eventAdapterService);
                }
                else if (resultEventType is MapEventType)
                {
                    processor = new SelectExprJoinWildcardProcessorMap(
                        streamNames, resultEventType, eventAdapterService);
                }
                else if (resultEventType is AvroSchemaEventType)
                {
                    processor = eventAdapterService.EventAdapterAvroHandler.GetOutputFactory().MakeJoinWildcard(
                        streamNames, resultEventType, eventAdapterService);
                }
            }

            if (!hasTables)
            {
                return(processor);
            }
            return(new SelectExprJoinWildcardProcessorTableRows(streamTypes, processor, tableService));
        }
 public AnnotationEventRepresentation(EventUnderlyingType value)
 {
     base.Value = value;
 }