Ejemplo n.º 1
0
        public ExprTableIdentNode GetTableIdentNode(StreamTypeService streamTypeService, string unresolvedPropertyName, string streamOrPropertyName)
        {
            var propertyPrefixed = unresolvedPropertyName;

            if (streamOrPropertyName != null)
            {
                propertyPrefixed = streamOrPropertyName + "." + unresolvedPropertyName;
            }
            var col = FindTableColumnMayByPrefixed(streamTypeService, propertyPrefixed);

            if (col == null)
            {
                return(null);
            }
            var pair = col.Pair;

            if (pair.Column is TableMetadataColumnAggregation)
            {
                var agg  = (TableMetadataColumnAggregation)pair.Column;
                var node = new ExprTableIdentNode(streamOrPropertyName, unresolvedPropertyName);
                var eval = ExprTableEvalStrategyFactory.GetTableAccessEvalStrategy(node, pair.TableMetadata.TableName, pair.StreamNum, agg);
                node.Eval = eval;
                return(node);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public Pair <ExprNode, IList <ExprChainedSpec> > GetTableNodeChainable(
            StreamTypeService streamTypeService,
            IList <ExprChainedSpec> chainSpec,
            EngineImportService engineImportService)
        {
            chainSpec = new List <ExprChainedSpec>(chainSpec);

            var unresolvedPropertyName = chainSpec[0].Name;
            var col = FindTableColumnMayByPrefixed(streamTypeService, unresolvedPropertyName);

            if (col == null)
            {
                return(null);
            }
            var pair = col.Pair;

            if (pair.Column is TableMetadataColumnAggregation)
            {
                var agg = (TableMetadataColumnAggregation)pair.Column;

                if (chainSpec.Count > 1)
                {
                    var candidateAccessor = chainSpec[1].Name;
                    var exprNode          = (ExprAggregateNodeBase)ASTAggregationHelper.TryResolveAsAggregation(engineImportService, false, candidateAccessor, new LazyAllocatedMap <ConfigurationPlugInAggregationMultiFunction, PlugInAggregationMultiFunctionFactory>(), streamTypeService.EngineURIQualifier);
                    if (exprNode != null)
                    {
                        var identNode = new ExprTableIdentNodeSubpropAccessor(pair.StreamNum, col.OptionalStreamName, agg, exprNode);
                        exprNode.AddChildNodes(chainSpec[1].Parameters);
                        chainSpec.RemoveAt(0);
                        chainSpec.RemoveAt(0);
                        return(new Pair <ExprNode, IList <ExprChainedSpec> >(identNode, chainSpec));
                    }
                }

                var node = new ExprTableIdentNode(null, unresolvedPropertyName);
                var eval = ExprTableEvalStrategyFactory.GetTableAccessEvalStrategy(node, pair.TableMetadata.TableName, pair.StreamNum, agg);
                node.Eval = eval;
                chainSpec.RemoveAt(0);
                return(new Pair <ExprNode, IList <ExprChainedSpec> >(node, chainSpec));
            }
            return(null);
        }
        public static IDictionary <ExprTableAccessNode, ExprTableAccessEvalStrategy> AttachTableAccess(
            EPServicesContext services,
            AgentInstanceContext agentInstanceContext,
            ExprTableAccessNode[] tableNodes)
        {
            if (tableNodes == null || tableNodes.Length == 0)
            {
                return(Collections.GetEmptyMap <ExprTableAccessNode, ExprTableAccessEvalStrategy>());
            }

            IDictionary <ExprTableAccessNode, ExprTableAccessEvalStrategy> strategies =
                new Dictionary <ExprTableAccessNode, ExprTableAccessEvalStrategy>();

            foreach (var tableNode in tableNodes)
            {
                var state         = services.TableService.GetState(tableNode.TableName, agentInstanceContext.AgentInstanceId);
                var tableMetadata = services.TableService.GetTableMetadata(tableNode.TableName);
                var strategy      = ExprTableEvalStrategyFactory.GetTableAccessEvalStrategy(agentInstanceContext.StatementContext.IsWritesToTables, tableNode, state, tableMetadata);
                strategies.Put(tableNode, strategy);
            }

            return(strategies);
        }