public static ExprNodePropOrStreamSet GetAggregatedProperties(IList<ExprAggregateNode> aggregateNodes) { // Get a list of properties being aggregated in the clause. ExprNodePropOrStreamSet propertiesAggregated = new ExprNodePropOrStreamSet(); ExprNodeIdentifierAndStreamRefVisitor visitor = new ExprNodeIdentifierAndStreamRefVisitor(true); foreach (ExprNode selectAggExprNode in aggregateNodes) { visitor.Reset(); selectAggExprNode.Accept(visitor); IList<ExprNodePropOrStreamDesc> properties = visitor.Refs; propertiesAggregated.AddAll(properties); } return propertiesAggregated; }
public FilterExprAnalyzerAffector GetFilterExprAnalyzerAffector() { var visitor = new ExprNodeIdentifierAndStreamRefVisitor(false); foreach (ExprNode lhsNode in _lhs) { lhsNode.Accept(visitor); } var indexedPropertyStreams = new HashSet <int>(); foreach (ExprNodePropOrStreamDesc @ref in visitor.GetRefs()) { indexedPropertyStreams.Add(@ref.StreamNum); } if (indexedPropertyStreams.Count == 0 || indexedPropertyStreams.Count > 1) { return (null); // there are no properties from any streams that could be used for building an index, or the properties come from different disjoint streams } var streamNumIndex = indexedPropertyStreams.First(); var keyExpressions = new List <Pair <ExprNode, int[]> >(); var dependencies = new HashSet <int>(); foreach (ExprNode node in _rhs) { visitor.Reset(); dependencies.Clear(); node.Accept(visitor); foreach (ExprNodePropOrStreamDesc @ref in visitor.GetRefs()) { dependencies.Add(@ref.StreamNum); } if (dependencies.Contains(streamNumIndex)) { return(null); } var pair = new Pair <ExprNode, int[]>(node, CollectionUtil.IntArray(dependencies)); keyExpressions.Add(pair); } return(new FilterExprAnalyzerAffectorIndexProvision(OperationName, _lhs, keyExpressions, streamNumIndex)); }
public static ExprNodePropOrStreamSet GetNonAggregatedProps( EventType[] types, IList<ExprNode> exprNodes, ContextPropertyRegistry contextPropertyRegistry) { // Determine all event properties in the clause ExprNodePropOrStreamSet nonAggProps = new ExprNodePropOrStreamSet(); ExprNodeIdentifierAndStreamRefVisitor visitor = new ExprNodeIdentifierAndStreamRefVisitor(false); foreach (ExprNode node in exprNodes) { visitor.Reset(); node.Accept(visitor); AddNonAggregatedProps(nonAggProps, visitor.Refs, types, contextPropertyRegistry); } return nonAggProps; }
public static ExprNodePropOrStreamSet GetGroupByPropertiesValidateHasOne(ExprNode[] groupByNodes) { // Get the set of properties refered to by all group-by expression nodes. ExprNodePropOrStreamSet propertiesGroupBy = new ExprNodePropOrStreamSet(); ExprNodeIdentifierAndStreamRefVisitor visitor = new ExprNodeIdentifierAndStreamRefVisitor(true); foreach (ExprNode groupByNode in groupByNodes) { visitor.Reset(); groupByNode.Accept(visitor); IList<ExprNodePropOrStreamDesc> propertiesNode = visitor.Refs; propertiesGroupBy.AddAll(propertiesNode); // For each group-by expression node, require at least one property. if (propertiesNode.IsEmpty()) { throw new ExprValidationException("Group-by expressions must refer to property names"); } } return propertiesGroupBy; }