private LinearAggregationFactoryDesc HandleTableAccessWindow( ExprNode[] childNodes, AggregationStateType stateType, ExprValidationContext validationContext, TableMetadataColumnAggregation tableAccess) { var original = (ExprAggMultiFunctionLinearAccessNodeFactoryAccess) tableAccess.Factory; if (childNodes.Length == 0 || childNodes.Length == 1 && childNodes[0] is ExprWildcard) { var componentType = original.ContainedEventType.UnderlyingType; var accessor = new AggregationAccessorWindowNoEval(componentType); var factory = new ExprAggMultiFunctionLinearAccessNodeFactoryAccess(this, accessor, TypeHelper.GetArrayType(componentType), original.ContainedEventType, null, null, null); return new LinearAggregationFactoryDesc(factory, factory.ContainedEventType, null); } if (childNodes.Length == 1) { // Expressions apply to events held, thereby validate in terms of event value expressions var paramNode = childNodes[0]; var streams = TableServiceUtil.StreamTypeFromTableColumn(tableAccess, validationContext.StreamTypeService.EngineURIQualifier); var localValidationContext = new ExprValidationContext(streams, validationContext); paramNode = ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.AGGPARAM, paramNode, localValidationContext); var paramNodeEval = paramNode.ExprEvaluator; var factory = new ExprAggMultiFunctionLinearAccessNodeFactoryAccess(this, new AggregationAccessorWindowWEval(0, paramNodeEval, paramNodeEval.ReturnType), TypeHelper.GetArrayType(paramNodeEval.ReturnType), original.ContainedEventType, null, null, null); return new LinearAggregationFactoryDesc(factory, null, paramNodeEval.ReturnType); } throw new ExprValidationException("Invalid number of parameters"); }
private LinearAggregationFactoryDesc HandleCreateTable( ExprNode[] childNodes, AggregationStateType stateType, ExprValidationContext validationContext) { var message = "For tables columns, the " + stateType.GetName().ToLowerInvariant() + " aggregation function requires the 'window(*)' declaration"; if (stateType != AggregationStateType.WINDOW) { throw new ExprValidationException(message); } if (childNodes.Length == 0 || childNodes.Length > 1 || !(childNodes[0] is ExprWildcard)) { throw new ExprValidationException(message); } if (validationContext.StreamTypeService.StreamNames.Length == 0) { throw new ExprValidationException( GetErrorPrefix(stateType) + " requires that the event type is provided"); } var containedType = validationContext.StreamTypeService.EventTypes[0]; var componentType = containedType.UnderlyingType; var accessor = new AggregationAccessorWindowNoEval(componentType); var stateFactory = validationContext.EngineImportService.AggregationFactoryFactory.MakeLinear( validationContext.StatementExtensionSvcContext, this, 0); var factory = new ExprAggMultiFunctionLinearAccessNodeFactoryAccess( this, accessor, TypeHelper.GetArrayType(componentType), containedType, null, stateFactory, null); return(new LinearAggregationFactoryDesc(factory, factory.ContainedEventType, null)); }
private LinearAggregationFactoryDesc HandleCreateTable(ExprNode[] childNodes, AggregationStateType stateType, ExprValidationContext validationContext) { var message = "For tables columns, the " + stateType.GetName().ToLower() + " aggregation function requires the 'window(*)' declaration"; if (stateType != AggregationStateType.WINDOW) { throw new ExprValidationException(message); } if (childNodes.Length == 0 || childNodes.Length > 1 || !(childNodes[0] is ExprWildcard)) { throw new ExprValidationException(message); } if (validationContext.StreamTypeService.StreamNames.Length == 0) { throw new ExprValidationException(GetErrorPrefix(stateType) + " requires that the event type is provided"); } var containedType = validationContext.StreamTypeService.EventTypes[0]; var componentType = containedType.UnderlyingType; AggregationAccessor accessor = new AggregationAccessorWindowNoEval(componentType); ExprNode me = this; AggregationStateFactory stateFactory = new ProxyAggregationStateFactory { ProcCreateAccess = (methodResolutionService, agentInstanceId, groupId, aggregationId, join, groupKey, passThru) => methodResolutionService.MakeAccessAggLinearNonJoin(agentInstanceId, groupId, aggregationId, 0, passThru), ProcAggregationExpression = () => me, }; var factory = new ExprAggMultiFunctionLinearAccessNodeFactoryAccess(this, accessor, TypeHelper.GetArrayType(componentType), containedType, null, stateFactory, null); return(new LinearAggregationFactoryDesc(factory, factory.ContainedEventType, null)); }
private LinearAggregationFactoryDesc HandleIntoTable( ExprNode[] childNodes, AggregationStateType stateType, ExprValidationContext validationContext) { var message = "For into-table use 'window(*)' or ''window(stream.*)' instead"; if (stateType != AggregationStateType.WINDOW) { throw new ExprValidationException(message); } if (childNodes.Length == 0 || childNodes.Length > 1) { throw new ExprValidationException(message); } if (validationContext.StreamTypeService.StreamNames.Length == 0) { throw new ExprValidationException( GetErrorPrefix(stateType) + " requires that at least one stream is provided"); } int streamNum; if (childNodes[0] is ExprWildcard) { if (validationContext.StreamTypeService.StreamNames.Length != 1) { throw new ExprValidationException( GetErrorPrefix(stateType) + " with wildcard requires a single stream"); } streamNum = 0; } else if (childNodes[0] is ExprStreamUnderlyingNode) { var und = (ExprStreamUnderlyingNode)childNodes[0]; streamNum = und.StreamId; } else { throw new ExprValidationException(message); } var containedType = validationContext.StreamTypeService.EventTypes[streamNum]; var componentType = containedType.UnderlyingType; var accessor = new AggregationAccessorWindowNoEval(componentType); AggregationAgent agent; if (streamNum == 0) { agent = AggregationAgentDefault.INSTANCE; } else { agent = new AggregationAgentRewriteStream(streamNum); } var factory = new ExprAggMultiFunctionLinearAccessNodeFactoryAccess( this, accessor, TypeHelper.GetArrayType(componentType), containedType, null, null, agent); return(new LinearAggregationFactoryDesc(factory, factory.ContainedEventType, null)); }