public EventPropertyGetter GetGetterProperty(String name, BeanEventType nativeFragmentType, EventAdapterService eventAdapterService) { return(new MapEntryPropertyGetter(name, nativeFragmentType, eventAdapterService)); }
public EventPropertyGetter GetGetterProperty(String name, BeanEventType nativeFragmentType, EventAdapterService eventAdapterService) { int index = GetAssertIndex(name); return(new ObjectArrayEntryPropertyGetter(index, nativeFragmentType, eventAdapterService)); }
/// <summary> /// Ctor. /// </summary> /// <param name="propertyName">property to get</param> /// <param name="eventAdapterService">factory for event beans and event types</param> /// <param name="eventType">type of the entry returned</param> public MapEntryPropertyGetter(String propertyName, BeanEventType eventType, EventAdapterService eventAdapterService) { _propertyName = propertyName; _eventAdapterService = eventAdapterService; _eventType = eventType; }
/// <summary> /// Returns value getter for the property of an event of the given event type. /// </summary> /// <param name="eventType">is the type of event to make a getter for</param> /// <param name="eventAdapterService">factory for event beans and event types</param> /// <returns> /// fast property value getter for property /// </returns> public abstract EventPropertyGetter GetGetter(BeanEventType eventType, EventAdapterService eventAdapterService);
public override Type GetPropertyType(BeanEventType eventType, EventAdapterService eventAdapterService) { return(typeof(Object)); }
/// <summary> /// Returns the property type. /// </summary> /// <param name="eventType">is the event type representing the object</param> /// <param name="eventAdapterService">for event adapters</param> /// <returns> /// property type class /// </returns> public abstract Type GetPropertyType(BeanEventType eventType, EventAdapterService eventAdapterService);
public override GenericPropertyDesc GetPropertyTypeGeneric( BeanEventType beanEventType, BeanEventTypeFactory beanEventTypeFactory) { return GenericPropertyDesc.ObjectGeneric; }
public ExprDotStaticMethodWrapArrayEvents(EventAdapterService eventAdapterService, BeanEventType type) { _eventAdapterService = eventAdapterService; _type = type; }
/// <summary> /// Creates an event type from the query meta data. /// </summary> /// <param name="streamNum"></param> /// <param name="queryMetaData">The query meta data.</param> /// <param name="services"></param> /// <param name="databaseStreamSpec">The database stream spec.</param> /// <param name="columnTypeConversionHook">The column type conversion hook.</param> /// <param name="outputRowConversionHook">The output row conversion hook.</param> /// <param name="base"></param> private static EventType CreateEventType( int streamNum, QueryMetaData queryMetaData, StatementCompileTimeServices services, DBStatementStreamSpec databaseStreamSpec, SQLColumnTypeConversion columnTypeConversionHook, SQLOutputRowConversion outputRowConversionHook, StatementBaseInfo @base) { var eventTypeFields = CreateEventTypeFields( databaseStreamSpec, columnTypeConversionHook, queryMetaData); var eventTypeName = services.EventTypeNameGeneratorStatement.GetAnonymousDBHistorical(streamNum); EventType eventType; Func<EventTypeApplicationType, EventTypeMetadata> metadata = appType => new EventTypeMetadata( eventTypeName, @base.ModuleName, EventTypeTypeClass.DBDERIVED, appType, NameAccessModifier.TRANSIENT, EventTypeBusModifier.NONBUS, false, EventTypeIdPair.Unassigned()); if (outputRowConversionHook == null) { eventType = BaseNestableEventUtil.MakeMapTypeCompileTime( metadata.Invoke(EventTypeApplicationType.MAP), eventTypeFields, null, null, null, null, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); } else { var carrierClass = outputRowConversionHook.GetOutputRowType( new SQLOutputRowTypeContext( databaseStreamSpec.DatabaseName, databaseStreamSpec.SqlWithSubsParams, eventTypeFields)); if (carrierClass == null) { throw new ExprValidationException("Output row conversion hook returned no type"); } var stem = services.BeanEventTypeStemService.GetCreateStem(carrierClass, null); eventType = new BeanEventType( services.Container, stem, metadata.Invoke(EventTypeApplicationType.CLASS), services.BeanEventTypeFactoryPrivate, null, null, null, null); } return eventType; }
public override Type GetPropertyType( BeanEventType eventType, BeanEventTypeFactory beanEventTypeFactory) { return typeof(object); }
public abstract EventPropertyGetterSPI GetGetter( BeanEventType eventType, EventBeanTypedEventFactory eventBeanTypedEventFactory, BeanEventTypeFactory beanEventTypeFactory);
public abstract GenericPropertyDesc GetPropertyTypeGeneric( BeanEventType eventType, BeanEventTypeFactory beanEventTypeFactory);
public abstract Type GetPropertyType( BeanEventType eventType, BeanEventTypeFactory beanEventTypeFactory);
public void AssignedType(String name, BeanEventType eventType) { // no op required }
public Type GetPropertyTypeMap(Map optionalMapPropTypes, EventAdapterService eventAdapterService) { Map currentDictionary = optionalMapPropTypes; int count = 0; for (var it = Properties.EnumerateWithLookahead(); it.HasNext();) { count++; var property = it.Next(); var propertyBase = (PropertyBase)property; var propertyName = propertyBase.PropertyNameAtomic; Object nestedType = null; if (currentDictionary != null) { nestedType = currentDictionary.Get(propertyName); } if (nestedType == null) { if (property is DynamicProperty) { return(typeof(Object)); } else { return(null); } } if (!it.HasNext()) { if (nestedType is Type) { return(((Type)nestedType).GetBoxedType()); } if (nestedType is Map) { return(typeof(Map)); } } if (ReferenceEquals(nestedType, typeof(Map))) { return(typeof(Object)); } if (nestedType is Type) { Type pocoType = (Type)nestedType; if (!pocoType.IsArray) { BeanEventType beanType = eventAdapterService.BeanEventTypeFactory.CreateBeanType(pocoType.Name, pocoType, false, false, false); String remainingProps = ToPropertyEPL(Properties, count); return(beanType.GetPropertyType(remainingProps).GetBoxedType()); } else if (property is IndexedProperty) { Type componentType = pocoType.GetElementType(); BeanEventType beanType = eventAdapterService.BeanEventTypeFactory.CreateBeanType(componentType.Name, componentType, false, false, false); String remainingProps = ToPropertyEPL(Properties, count); return(beanType.GetPropertyType(remainingProps).GetBoxedType()); } } if (nestedType is String) // property type is the name of a map event type { String nestedName = nestedType.ToString(); bool isArray = EventTypeUtility.IsPropertyArray(nestedName); if (isArray) { nestedName = EventTypeUtility.GetPropertyRemoveArray(nestedName); } EventType innerType = eventAdapterService.GetEventTypeByName(nestedName); if (innerType == null) { return(null); } String remainingProps = ToPropertyEPL(Properties, count); return(innerType.GetPropertyType(remainingProps).GetBoxedType()); } else if (nestedType is EventType) // property type is the name of a map event type { var innerType = (EventType)nestedType; var remainingProps = ToPropertyEPL(Properties, count); return(innerType.GetPropertyType(remainingProps).GetBoxedType()); } else { if (!(nestedType is Map)) { String message = "Nestable map type configuration encountered an unexpected value type of '" + nestedType.GetType() + " for property '" + propertyName + "', expected Class, typeof(Map) or IDictionary<String, Object> as value type"; throw new PropertyAccessException(message); } } currentDictionary = (Map)nestedType; } throw new IllegalStateException("Unexpected end of nested property"); }
public override EventPropertyGetterSPI GetGetter(BeanEventType eventType, EventAdapterService eventAdapterService) { return(new DynamicMappedPropertyGetter(PropertyNameAtomic, _key, eventAdapterService)); }
public MapEventPropertyGetter GetGetterMap(Map optionalMapPropTypes, EventAdapterService eventAdapterService) { var getters = new List <EventPropertyGetter>(); var currentDictionary = optionalMapPropTypes; int count = 0; for (var it = Properties.EnumerateWithLookahead(); it.HasNext();) { count++; Property property = it.Next(); // manufacture a getter for getting the item out of the map EventPropertyGetter getter = property.GetGetterMap(currentDictionary, eventAdapterService); if (getter == null) { return(null); } getters.Add(getter); var @base = (PropertyBase)property; var propertyName = @base.PropertyNameAtomic; // For the next property if there is one, check how to property type is defined if (!it.HasNext()) { continue; } if (currentDictionary != null) { // check the type that this property will return Object propertyReturnType = currentDictionary.Get(propertyName); if (propertyReturnType == null) { currentDictionary = null; } if (propertyReturnType != null) { if (propertyReturnType is Map) { currentDictionary = (Map)propertyReturnType; } else if (ReferenceEquals(propertyReturnType, typeof(Map))) { currentDictionary = null; } else if (propertyReturnType is String) { String nestedName = propertyReturnType.ToString(); bool isArray = EventTypeUtility.IsPropertyArray(nestedName); if (isArray) { nestedName = EventTypeUtility.GetPropertyRemoveArray(nestedName); } EventType innerType = eventAdapterService.GetEventTypeByName(nestedName); if (innerType == null) { return(null); } String remainingProps = ToPropertyEPL(Properties, count); EventPropertyGetter getterInner = innerType.GetGetter(remainingProps); if (getterInner == null) { return(null); } getters.Add(getterInner); break; // the single getter handles the rest } else if (propertyReturnType is EventType) { var innerType = (EventType)propertyReturnType; var remainingProps = ToPropertyEPL(Properties, count); var getterInner = innerType.GetGetter(remainingProps); if (getterInner == null) { return(null); } getters.Add(getterInner); break; // the single getter handles the rest } else { // treat the return type of the map property as an object var returnType = (Type)propertyReturnType; if (!returnType.IsArray) { BeanEventType beanType = eventAdapterService.BeanEventTypeFactory.CreateBeanType(returnType.Name, returnType, false, false, false); String remainingProps = ToPropertyEPL(Properties, count); EventPropertyGetter getterInner = beanType.GetGetter(remainingProps); if (getterInner == null) { return(null); } getters.Add(getterInner); break; // the single getter handles the rest } else { Type componentType = returnType.GetElementType(); BeanEventType beanType = eventAdapterService.BeanEventTypeFactory.CreateBeanType( componentType.Name, componentType, false, false, false); String remainingProps = ToPropertyEPL(Properties, count); EventPropertyGetter getterInner = beanType.GetGetter(remainingProps); if (getterInner == null) { return(null); } getters.Add(getterInner); break; // the single pono getter handles the rest } } } } } var hasNonmapGetters = false; for (int i = 0; i < getters.Count; i++) { if (!(getters[i] is MapEventPropertyGetter)) { hasNonmapGetters = true; } } if (!hasNonmapGetters) { return(new MapNestedPropertyGetterMapOnly(getters, eventAdapterService)); } else { return(new MapNestedPropertyGetterMixedType(getters, eventAdapterService)); } }
public override EventPropertyGetter GetGetter(BeanEventType eventType, EventAdapterService eventAdapterService) { return(new DynamicIndexedPropertyGetter(PropertyNameAtomic, _index, eventAdapterService)); }
// The create window command: // create window windowName[.window_view_list] as [select properties from] type // // This section expected s single FilterStreamSpecCompiled representing the selected type. // It creates a new event type representing the window type and a sets the type selected on the filter stream spec. protected internal static CreateWindowCompileResult HandleCreateWindow( StatementBaseInfo @base, StatementCompileTimeServices services) { var createWindowDesc = @base.StatementSpec.Raw.CreateWindowDesc; var columns = createWindowDesc.Columns; var typeName = createWindowDesc.WindowName; EventType targetType; // determine that the window name is not already in use as an event type name var existingType = services.EventTypeCompileTimeResolver.GetTypeByName(typeName); if (existingType != null && existingType.Metadata.TypeClass != EventTypeTypeClass.NAMED_WINDOW) { throw new ExprValidationException( "Error starting statement: An event type or schema by name '" + typeName + "' already exists"); } // Determine select-from var optionalSelectFrom = GetOptionalSelectFrom(createWindowDesc, services); // Create Map or Wrapper event type from the select clause of the window. // If no columns selected, simply create a wrapper type // Build a list of properties var newSelectClauseSpecRaw = new SelectClauseSpecRaw(); LinkedHashMap<string, object> properties; var hasProperties = false; if (columns != null && !columns.IsEmpty()) { properties = EventTypeUtility.BuildType( columns, null, services.ImportServiceCompileTime, services.EventTypeCompileTimeResolver); hasProperties = true; } else { if (optionalSelectFrom == null) { throw new IllegalStateException("Missing from-type information for create-window"); } // Validate the select expressions which consists of properties only var select = CompileLimitedSelect(optionalSelectFrom, @base, services); properties = new LinkedHashMap<string, object>(); foreach (var selectElement in select) { if (selectElement.FragmentType != null) { properties.Put(selectElement.AssignedName, selectElement.FragmentType); } else { properties.Put(selectElement.AssignedName, selectElement.SelectExpressionType); } // Add any properties to the new select clause for use by consumers to the statement itself newSelectClauseSpecRaw.Add( new SelectClauseExprRawSpec(new ExprIdentNodeImpl(selectElement.AssignedName), null, false)); hasProperties = true; } } // Create Map or Wrapper event type from the select clause of the window. // If no columns selected, simply create a wrapper type var isOnlyWildcard = @base.StatementSpec.Raw.SelectClauseSpec.IsOnlyWildcard; var isWildcard = @base.StatementSpec.Raw.SelectClauseSpec.IsUsingWildcard; var namedWindowVisibility = services.ModuleVisibilityRules.GetAccessModifierNamedWindow(@base, typeName); var additionalForgeables = new List<StmtClassForgeableFactory>(); try { if (isWildcard && !isOnlyWildcard) { var metadata = new EventTypeMetadata( typeName, @base.ModuleName, EventTypeTypeClass.NAMED_WINDOW, EventTypeApplicationType.WRAPPER, namedWindowVisibility, EventTypeBusModifier.NONBUS, false, EventTypeIdPair.Unassigned()); targetType = WrapperEventTypeUtil.MakeWrapper( metadata, optionalSelectFrom.EventType, properties, null, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); } else { // Some columns selected, use the types of the columns Func<EventTypeApplicationType, EventTypeMetadata> metadata = type => new EventTypeMetadata( typeName, @base.ModuleName, EventTypeTypeClass.NAMED_WINDOW, type, namedWindowVisibility, EventTypeBusModifier.NONBUS, false, EventTypeIdPair.Unassigned()); if (hasProperties && !isOnlyWildcard) { var compiledProperties = EventTypeUtility.CompileMapTypeProperties( properties, services.EventTypeCompileTimeResolver); var representation = EventRepresentationUtil.GetRepresentation( @base.StatementSpec.Annotations, services.Configuration, AssignedType.NONE); if (representation == EventUnderlyingType.MAP) { targetType = BaseNestableEventUtil.MakeMapTypeCompileTime( metadata.Invoke(EventTypeApplicationType.MAP), compiledProperties, null, null, null, null, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); } else if (representation == EventUnderlyingType.OBJECTARRAY) { targetType = BaseNestableEventUtil.MakeOATypeCompileTime( metadata.Invoke(EventTypeApplicationType.OBJECTARR), compiledProperties, null, null, null, null, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); } else if (representation == EventUnderlyingType.AVRO) { targetType = services.EventTypeAvroHandler.NewEventTypeFromNormalized( metadata.Invoke(EventTypeApplicationType.AVRO), services.EventTypeCompileTimeResolver, services.BeanEventTypeFactoryPrivate.EventBeanTypedEventFactory, compiledProperties, @base.StatementRawInfo.Annotations, null, null, null, @base.StatementName); } else if (representation == EventUnderlyingType.JSON) { EventTypeForgeablesPair pair = JsonEventTypeUtility.MakeJsonTypeCompileTimeNewType( metadata.Invoke(EventTypeApplicationType.JSON), compiledProperties, null, null, @base.StatementRawInfo, services); targetType = pair.EventType; additionalForgeables.AddRange(pair.AdditionalForgeables); } else { throw new IllegalStateException("Unrecognized representation " + representation); } } else { if (optionalSelectFrom == null) { throw new IllegalStateException("Missing from-type information for create-window"); } var selectFromType = optionalSelectFrom.EventType; // No columns selected, no wildcard, use the type as is or as a wrapped type if (selectFromType is ObjectArrayEventType) { var oaType = (ObjectArrayEventType) selectFromType; targetType = BaseNestableEventUtil.MakeOATypeCompileTime( metadata.Invoke(EventTypeApplicationType.OBJECTARR), oaType.Types, null, null, oaType.StartTimestampPropertyName, oaType.EndTimestampPropertyName, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); } else if (selectFromType is AvroSchemaEventType) { var avroSchemaEventType = (AvroSchemaEventType) selectFromType; var avro = new ConfigurationCommonEventTypeAvro(); avro.AvroSchema = avroSchemaEventType.Schema; targetType = services.EventTypeAvroHandler.NewEventTypeFromSchema( metadata.Invoke(EventTypeApplicationType.AVRO), services.BeanEventTypeFactoryPrivate.EventBeanTypedEventFactory, avro, null, null); } else if (selectFromType is JsonEventType) { JsonEventType jsonType = (JsonEventType) selectFromType; targetType = JsonEventTypeUtility.MakeJsonTypeCompileTimeExistingType( metadata.Invoke(EventTypeApplicationType.JSON), jsonType, services); } else if (selectFromType is MapEventType) { var mapType = (MapEventType) selectFromType; targetType = BaseNestableEventUtil.MakeMapTypeCompileTime( metadata.Invoke(EventTypeApplicationType.MAP), mapType.Types, null, null, mapType.StartTimestampPropertyName, mapType.EndTimestampPropertyName, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); } else if (selectFromType is BeanEventType) { var beanType = (BeanEventType) selectFromType; targetType = new BeanEventType( services.Container, beanType.Stem, metadata.Invoke(EventTypeApplicationType.CLASS), services.BeanEventTypeFactoryPrivate, null, null, beanType.StartTimestampPropertyName, beanType.EndTimestampPropertyName); } else { targetType = WrapperEventTypeUtil.MakeWrapper( metadata.Invoke(EventTypeApplicationType.WRAPPER), selectFromType, new Dictionary<string, object>(), null, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); } } } services.EventTypeCompileTimeRegistry.NewType(targetType); } catch (EPException ex) { throw new ExprValidationException(ex.Message, ex); } var filter = new FilterSpecCompiled(targetType, typeName, FilterSpecPlanForge.EMPTY, null); return new CreateWindowCompileResult( filter, newSelectClauseSpecRaw, optionalSelectFrom?.EventType, additionalForgeables); }
public override GenericPropertyDesc GetPropertyTypeGeneric(BeanEventType beanEventType, EventAdapterService eventAdapterService) { return(GenericPropertyDesc.ObjectGeneric); }
static StatementSelectionUtil() { STATEMENT_META_EVENT_TYPE = (BeanEventType)SupportEventAdapterService.Service.AddBeanType("StatementRow", typeof(StatementRow), true, true, true); }
/// <summary> /// Returns the property type plus its generic type parameter, if any. /// </summary> /// <param name="eventType">is the event type representing the object</param> /// <param name="eventAdapterService">for event adapters</param> /// <returns> /// type and generic descriptor /// </returns> public abstract GenericPropertyDesc GetPropertyTypeGeneric(BeanEventType eventType, EventAdapterService eventAdapterService);
public override EventPropertyGetter GetGetter(BeanEventType eventType, EventAdapterService eventAdapterService) { FastClass fastClass = eventType.FastClass; InternalEventPropDescriptor propertyDesc = eventType.GetIndexedProperty(PropertyNameAtomic); if (propertyDesc != null) { if (fastClass != null) { MethodInfo method = propertyDesc.ReadMethod; FastMethod fastMethod = fastClass.GetMethod(method); return(new KeyedFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new KeyedMethodPropertyGetter(propertyDesc.ReadMethod, _index, eventAdapterService)); } } // Try the array as a simple property propertyDesc = eventType.GetSimpleProperty(PropertyNameAtomic); if (propertyDesc == null) { return(null); } Type returnType = propertyDesc.ReturnType; if (returnType == typeof(string)) { if (propertyDesc.ReadMethod != null) { MethodInfo method = propertyDesc.ReadMethod; if (fastClass != null) { FastMethod fastMethod = fastClass.GetMethod(method); return(new StringFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new StringMethodPropertyGetter(method, _index, eventAdapterService)); } } else { FieldInfo field = propertyDesc.AccessorField; return(new StringFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsArray) { if (propertyDesc.ReadMethod != null) { MethodInfo method = propertyDesc.ReadMethod; if (fastClass != null) { FastMethod fastMethod = fastClass.GetMethod(method); return(new ArrayFastPropertyGetter(fastMethod, _index, eventAdapterService)); } else { return(new ArrayMethodPropertyGetter(method, _index, eventAdapterService)); } } else { FieldInfo field = propertyDesc.AccessorField; return(new ArrayFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsGenericDictionary()) { } else if (returnType.IsGenericList()) { if (propertyDesc.ReadMethod != null) { MethodInfo method = propertyDesc.ReadMethod; if (fastClass != null) { FastMethod fastMethod = fastClass.GetMethod(method); return(new ListFastPropertyGetter(method, fastMethod, _index, eventAdapterService)); } else { return(new ListMethodPropertyGetter(method, _index, eventAdapterService)); } } else { FieldInfo field = propertyDesc.AccessorField; return(new ListFieldPropertyGetter(field, _index, eventAdapterService)); } } else if (returnType.IsImplementsInterface(typeof(IEnumerable))) { if (propertyDesc.ReadMethod != null) { MethodInfo method = propertyDesc.ReadMethod; if (fastClass != null) { FastMethod fastMethod = fastClass.GetMethod(method); return(new EnumerableFastPropertyGetter(method, fastMethod, _index, eventAdapterService)); } else { return(new EnumerableMethodPropertyGetter(method, _index, eventAdapterService)); } } else { FieldInfo field = propertyDesc.AccessorField; return(new EnumerableFieldPropertyGetter(field, _index, eventAdapterService)); } } return(null); }