// settable for view-sharing /// <summary> /// Constructor. /// </summary> /// <param name="stmtEngineServices">is the engine services for the statement</param> /// <param name="schedulingService">implementation for schedule registration</param> /// <param name="scheduleBucket">is for ordering scheduled callbacks within the view statements</param> /// <param name="epStatementHandle">is the statements-own handle for use in registering callbacks with services</param> /// <param name="viewResultionService">is a service for resolving view namespace and name to a view factory</param> /// <param name="patternResolutionService">is the service that resolves pattern objects for the statement</param> /// <param name="statementExtensionSvcContext">provide extension points for custom statement resources</param> /// <param name="statementStopService">for registering a callback invoked when a statement is stopped</param> /// <param name="methodResolutionService">is a service for resolving static methods and aggregation functions</param> /// <param name="patternContextFactory">is the pattern-level services and context information factory</param> /// <param name="filterService">is the filtering service</param> /// <param name="statementResultService">handles awareness of listeners/subscriptions for a statement customizing output produced</param> /// <param name="internalEventEngineRouteDest">routing destination</param> /// <param name="annotations">The annotations.</param> /// <param name="statementAgentInstanceRegistry">The statement agent instance registry.</param> /// <param name="defaultAgentInstanceLock">The default agent instance lock.</param> /// <param name="contextDescriptor">The context descriptor.</param> /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param> /// <param name="matchRecognizeStatePoolStmtSvc">The match recognize state pool statement SVC.</param> /// <param name="statelessSelect">if set to <c>true</c> [stateless select].</param> /// <param name="contextControllerFactoryService">The context controller factory service.</param> /// <param name="defaultAgentInstanceScriptContext">The default agent instance script context.</param> /// <param name="aggregationServiceFactoryService">The aggregation service factory service.</param> /// <param name="scriptingService">The scripting service.</param> /// <param name="writesToTables">if set to <c>true</c> [writes to tables].</param> /// <param name="statementUserObject">The statement user object.</param> /// <param name="statementSemiAnonymousTypeRegistry">The statement semi anonymous type registry.</param> /// <param name="priority">The priority.</param> public StatementContext( StatementContextEngineServices stmtEngineServices, SchedulingService schedulingService, ScheduleBucket scheduleBucket, EPStatementHandle epStatementHandle, ViewResolutionService viewResultionService, PatternObjectResolutionService patternResolutionService, StatementExtensionSvcContext statementExtensionSvcContext, StatementStopService statementStopService, MethodResolutionService methodResolutionService, PatternContextFactory patternContextFactory, FilterService filterService, StatementResultService statementResultService, InternalEventRouteDest internalEventEngineRouteDest, Attribute[] annotations, StatementAIResourceRegistry statementAgentInstanceRegistry, IReaderWriterLock defaultAgentInstanceLock, ContextDescriptor contextDescriptor, PatternSubexpressionPoolStmtSvc patternSubexpressionPoolSvc, MatchRecognizeStatePoolStmtSvc matchRecognizeStatePoolStmtSvc, bool statelessSelect, ContextControllerFactoryService contextControllerFactoryService, AgentInstanceScriptContext defaultAgentInstanceScriptContext, AggregationServiceFactoryService aggregationServiceFactoryService, ScriptingService scriptingService, bool writesToTables, object statementUserObject, StatementSemiAnonymousTypeRegistry statementSemiAnonymousTypeRegistry, int priority) { _stmtEngineServices = stmtEngineServices; SchedulingService = schedulingService; ScheduleBucket = scheduleBucket; EpStatementHandle = epStatementHandle; ViewResolutionService = viewResultionService; PatternResolutionService = patternResolutionService; StatementExtensionServicesContext = statementExtensionSvcContext; StatementStopService = statementStopService; MethodResolutionService = methodResolutionService; PatternContextFactory = patternContextFactory; FilterService = filterService; _statementResultService = statementResultService; InternalEventEngineRouteDest = internalEventEngineRouteDest; ScheduleAdjustmentService = stmtEngineServices.ConfigSnapshot.EngineDefaults.ExecutionConfig.IsAllowIsolatedService ? new ScheduleAdjustmentService() : null; Annotations = annotations; StatementAgentInstanceRegistry = statementAgentInstanceRegistry; DefaultAgentInstanceLock = defaultAgentInstanceLock; ContextDescriptor = contextDescriptor; PatternSubexpressionPoolSvc = patternSubexpressionPoolSvc; MatchRecognizeStatePoolStmtSvc = matchRecognizeStatePoolStmtSvc; IsStatelessSelect = statelessSelect; ContextControllerFactoryService = contextControllerFactoryService; DefaultAgentInstanceScriptContext = defaultAgentInstanceScriptContext; AggregationServiceFactoryService = aggregationServiceFactoryService; ScriptingService = scriptingService; IsWritesToTables = writesToTables; StatementUserObject = statementUserObject; StatementSemiAnonymousTypeRegistry = statementSemiAnonymousTypeRegistry; Priority = priority; }
/// <summary> /// Ctor. /// </summary> /// <param name="revisionEventTypeName">name</param> /// <param name="spec">specification</param> /// <param name="statementStopService">for stop handling</param> /// <param name="eventAdapterService">for nested property handling</param> /// <param name="eventTypeIdGenerator">The event type id generator.</param> public VAERevisionProcessorDeclared( string revisionEventTypeName, RevisionSpec spec, StatementStopService statementStopService, EventAdapterService eventAdapterService, EventTypeIdGenerator eventTypeIdGenerator) : base(spec, revisionEventTypeName, eventAdapterService) { // on statement stop, remove versions statementStopService.StatementStopped += () => _statePerKey.Clear(); _statePerKey = new Dictionary <object, RevisionStateDeclared>().WithNullSupport(); _baseEventType = spec.BaseEventType; _fullKeyGetters = PropertyUtility.GetGetters(_baseEventType, spec.KeyPropertyNames); // sort non-key properties, removing keys _groups = PropertyUtility.AnalyzeGroups(spec.ChangesetPropertyNames, spec.DeltaTypes, spec.DeltaNames); var propertyDesc = CreatePropertyDescriptors(spec, _groups); TypeDescriptors = PropertyUtility.GetPerType(_groups, spec.ChangesetPropertyNames, spec.KeyPropertyNames); var metadata = EventTypeMetadata.CreateValueAdd(revisionEventTypeName, TypeClass.REVISION); RevisionEventType = new RevisionEventType(metadata, eventTypeIdGenerator.GetTypeId(revisionEventTypeName), propertyDesc, eventAdapterService); }
public EventType CreateRevisionType(String namedWindowName, String name, StatementStopService statementStopService, EventAdapterService eventAdapterService, EventTypeIdGenerator eventTypeIdGenerator) { RevisionSpec spec = SpecificationsByRevisionName.Get(name); ValueAddEventProcessor processor; if (spec.PropertyRevision == PropertyRevisionEnum.OVERLAY_DECLARED) { processor = new VAERevisionProcessorDeclared(name, spec, statementStopService, eventAdapterService, eventTypeIdGenerator); } else { processor = new VAERevisionProcessorMerge(name, spec, statementStopService, eventAdapterService, eventTypeIdGenerator); } ProcessorsByNamedWindow.Put(namedWindowName, processor); return(processor.ValueAddEventType); }
public SubSelectStrategyFactoryIndexShare( string statementName, int statementId, int subqueryNum, EventType[] outerEventTypesSelect, NamedWindowProcessor optionalNamedWindowProcessor, TableMetadata optionalTableMetadata, bool fullTableScan, IndexHint optionalIndexHint, SubordPropPlan joinedPropPlan, ExprEvaluator filterExprEval, AggregationServiceFactoryDesc aggregationServiceFactory, ExprEvaluator[] groupByKeys, TableService tableService, Attribute[] annotations, StatementStopService statementStopService) { _optionalNamedWindowProcessor = optionalNamedWindowProcessor; _optionalTableMetadata = optionalTableMetadata; _filterExprEval = filterExprEval; _aggregationServiceFactory = aggregationServiceFactory; _groupByKeys = groupByKeys; _tableService = tableService; bool isLogging; ILog log; if (optionalTableMetadata != null) { isLogging = optionalTableMetadata.IsQueryPlanLogging; log = TableServiceImpl.QueryPlanLog; _queryPlan = SubordinateQueryPlanner.PlanSubquery(outerEventTypesSelect, joinedPropPlan, false, fullTableScan, optionalIndexHint, true, subqueryNum, false, optionalTableMetadata.EventTableIndexMetadataRepo, optionalTableMetadata.UniqueKeyProps, true, statementName, statementId, annotations); if (_queryPlan != null) { for (int i = 0; i < _queryPlan.IndexDescs.Length; i++) { optionalTableMetadata.AddIndexReference(_queryPlan.IndexDescs[i].IndexName, statementName); } } } else { isLogging = optionalNamedWindowProcessor.RootView.IsQueryPlanLogging; log = NamedWindowRootView.QueryPlanLog; _queryPlan = SubordinateQueryPlanner.PlanSubquery(outerEventTypesSelect, joinedPropPlan, false, fullTableScan, optionalIndexHint, true, subqueryNum, optionalNamedWindowProcessor.IsVirtualDataWindow, optionalNamedWindowProcessor.EventTableIndexMetadataRepo, optionalNamedWindowProcessor.OptionalUniqueKeyProps, false, statementName, statementId, annotations); if (_queryPlan != null && _queryPlan.IndexDescs != null) { SubordinateQueryPlannerUtil.AddIndexMetaAndRef(_queryPlan.IndexDescs, optionalNamedWindowProcessor.EventTableIndexMetadataRepo, statementName); statementStopService.StatementStopped += () => { for (int i = 0; i < _queryPlan.IndexDescs.Length; i++) { bool last = optionalNamedWindowProcessor.EventTableIndexMetadataRepo.RemoveIndexReference(_queryPlan.IndexDescs[i].IndexMultiKey, statementName); if (last) { optionalNamedWindowProcessor.EventTableIndexMetadataRepo.RemoveIndex(_queryPlan.IndexDescs[i].IndexMultiKey); optionalNamedWindowProcessor.RemoveAllInstanceIndexes(_queryPlan.IndexDescs[i].IndexMultiKey); } } }; } } SubordinateQueryPlannerUtil.QueryPlanLogOnSubq(isLogging, log, _queryPlan, subqueryNum, annotations); }
public EventType CreateRevisionType(String namedWindowName, String typeName, StatementStopService statementStopService, EventAdapterService eventAdapterService, EventTypeIdGenerator eventTypeIdGenerator) { return(null); }
/// <summary> /// Ctor. /// </summary> /// <param name="revisioneventTypeName">name</param> /// <param name="spec">specification</param> /// <param name="statementStopService">for stop handling</param> /// <param name="eventAdapterService">for nested property handling</param> /// <param name="eventTypeIdGenerator">The event type id generator.</param> public VAERevisionProcessorMerge(String revisioneventTypeName, RevisionSpec spec, StatementStopService statementStopService, EventAdapterService eventAdapterService, EventTypeIdGenerator eventTypeIdGenerator) : base(spec, revisioneventTypeName, eventAdapterService) { // on statement stop, remove versions statementStopService.StatementStopped += () => _statePerKey.Clear(); _statePerKey = new Dictionary <Object, RevisionStateMerge>(); // For all changeset properties, add type descriptors (property number, getter etc) var propertyDesc = new Dictionary <String, RevisionPropertyTypeDesc>(); var count = 0; foreach (String property in spec.ChangesetPropertyNames) { var fullGetter = spec.BaseEventType.GetGetter(property); var propertyNumber = count; var paramList = new RevisionGetterParameters(property, propertyNumber, fullGetter, null); // if there are no groups (full event property only), then simply use the full event getter EventPropertyGetter revisionGetter = new ProxyEventPropertyGetter( eventBean => { var riv = (RevisionEventBeanMerge)eventBean; return(riv.GetVersionedValue(paramList)); }, eventBean => null, eventBean => true); var type = spec.BaseEventType.GetPropertyType(property); if (type == null) { foreach (EventType deltaType in spec.DeltaTypes) { var dtype = deltaType.GetPropertyType(property); if (dtype != null) { type = dtype; break; } } } var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, paramList, type); propertyDesc.Put(property, propertyTypeDesc); count++; } count = 0; foreach (String property in spec.KeyPropertyNames) { var keyPropertyNumber = count; EventPropertyGetter revisionGetter; if (spec.KeyPropertyNames.Length == 1) { revisionGetter = new ProxyEventPropertyGetter { ProcGet = eventBean => ((RevisionEventBeanMerge)eventBean).Key, ProcIsExistsProperty = eventBean => true, ProcGetFragment = eventBean => null }; } else { revisionGetter = new ProxyEventPropertyGetter { ProcGet = eventBean => { var riv = (RevisionEventBeanMerge)eventBean; return(((MultiKeyUntyped)riv.Key).Keys[keyPropertyNumber]); }, ProcIsExistsProperty = eventBean => true, ProcGetFragment = eventBean => null }; } var type = spec.BaseEventType.GetPropertyType(property); if (type == null) { foreach (EventType deltaType in spec.DeltaTypes) { var dtype = deltaType.GetPropertyType(property); if (dtype != null) { type = dtype; break; } } } var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type); propertyDesc.Put(property, propertyTypeDesc); count++; } // compile for each event type a list of getters and indexes within the overlay foreach (EventType deltaType in spec.DeltaTypes) { RevisionTypeDesc typeDesc = MakeTypeDesc(deltaType, spec.PropertyRevision); TypeDescriptors.Put(deltaType, typeDesc); } _infoFullType = MakeTypeDesc(spec.BaseEventType, spec.PropertyRevision); // how to handle updates to a full event if (spec.PropertyRevision == PropertyRevisionEnum.MERGE_DECLARED) { _updateStrategy = new UpdateStrategyDeclared(spec); } else if (spec.PropertyRevision == PropertyRevisionEnum.MERGE_NON_NULL) { _updateStrategy = new UpdateStrategyNonNull(spec); } else if (spec.PropertyRevision == PropertyRevisionEnum.MERGE_EXISTS) { _updateStrategy = new UpdateStrategyExists(spec); } else { throw new ArgumentException("Unknown revision type '" + spec.PropertyRevision + "'"); } EventTypeMetadata metadata = EventTypeMetadata.CreateValueAdd(revisioneventTypeName, TypeClass.REVISION); RevisionEventType = new RevisionEventType(metadata, eventTypeIdGenerator.GetTypeId(revisioneventTypeName), propertyDesc, eventAdapterService); }