Пример #1
0
        /// <summary>Renders the clause in textual representation. </summary>
        /// <param name="writer">to output to</param>
        /// <param name="formatter">for NewLine-whitespace formatting</param>
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            foreach (OnInsertSplitStreamItem item in Items)
            {
                item.InsertInto.ToEPL(writer, formatter, true);
                item.SelectClause.ToEPL(writer, formatter, true, false);
                if (item.PropertySelects != null)
                {
                    writer.Write(" from ");
                    ContainedEventSelect.ToEPL(writer, formatter, item.PropertySelects);
                    if (item.PropertySelectsStreamName != null)
                    {
                        writer.Write(" as ");
                        writer.Write(item.PropertySelectsStreamName);
                    }
                }

                if (item.WhereClause != null)
                {
                    writer.Write(" where ");
                    item.WhereClause.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                }
            }

            if (!IsFirst)
            {
                writer.Write(" output all");
            }
        }
Пример #2
0
 /// <summary>
 /// Renders the clause in EPL.
 /// </summary>
 /// <param name="writer">to output to</param>
 /// <param name="formatter">for NewLine-whitespace formatting</param>
 public void ToEPL(
     TextWriter writer,
     EPStatementFormatter formatter)
 {
     formatter.BeginOnSet(writer);
     UpdateClause.RenderEPLAssignments(writer, Assignments);
 }
Пример #3
0
 /// <summary>
 ///     Renders the clause in textual representation.
 /// </summary>
 /// <param name="writer">to output to</param>
 /// <param name="formatter"></param>
 public override void ToEPLStream(
     TextWriter writer,
     EPStatementFormatter formatter)
 {
     ToEPLProjectedStream(writer, formatter);
     ToEPLViews(writer, Views);
 }
Пример #4
0
        /// <summary>
        ///     Rendering using the provided formatter.
        /// </summary>
        /// <param name="formatter">to use</param>
        /// <returns>rendered string</returns>
        public string ToEPL(EPStatementFormatter formatter)
        {
            var writer = new StringWriter();

            ToEPL(formatter, writer);
            return(writer.ToString());
        }
Пример #5
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            string delimiter = "";
            int    childNum  = 0;

            foreach (PatternExpr child in Children)
            {
                writer.Write(delimiter);
                child.ToEPL(writer, Precedence, formatter);

                delimiter = " -> ";
                if (OptionalMaxPerSubexpression != null && OptionalMaxPerSubexpression.Count > childNum)
                {
                    var maxExpr = OptionalMaxPerSubexpression[childNum];
                    if (maxExpr != null)
                    {
                        var inner = new StringWriter();
                        maxExpr.ToEPL(inner, ExpressionPrecedenceEnum.MINIMUM);
                        delimiter = " -[" + inner.ToString() + "]> ";
                    }
                }

                childNum++;
            }
        }
Пример #6
0
        /// <summary>Renders the clause in textual representation. </summary>
        /// <param name="writer">to output to</param>
        /// <param name="formatter">for NewLine-whitespace formatting</param>
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            formatter.BeginMergeWhenMatched(writer);
            if (IsMatched)
            {
                writer.Write("when matched");
            }
            else
            {
                writer.Write("when not matched");
            }

            if (OptionalCondition != null)
            {
                writer.Write(" and ");
                OptionalCondition.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
            }

            foreach (OnMergeMatchedAction action in Actions)
            {
                formatter.BeginMergeAction(writer);
                action.ToEPL(writer);
            }
        }
Пример #7
0
        /// <summary>
        ///     Renders the clause in textual representation.
        /// </summary>
        /// <param name="writer">to output to</param>
        /// <param name="optionalWhereClause">where clause if present, or null</param>
        /// <param name="formatter">for newline-whitespace formatting</param>
        public void ToEPL(
            TextWriter writer,
            Expression optionalWhereClause,
            EPStatementFormatter formatter)
        {
            formatter.BeginMerge(writer);
            writer.Write("merge ");
            writer.Write(WindowName);

            if (OptionalAsName != null)
            {
                writer.Write(" as ");
                writer.Write(OptionalAsName);
            }

            if (InsertNoMatch != null)
            {
                writer.Write(" ");
                InsertNoMatch.ToEPL(writer);
            }
            else
            {
                if (optionalWhereClause != null)
                {
                    formatter.BeginMergeWhere(writer);
                    writer.Write("where ");
                    optionalWhereClause.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                }

                foreach (var item in MatchItems)
                {
                    item.ToEPL(writer, formatter);
                }
            }
        }
Пример #8
0
        /// <summary>Renders the clause in textual representation. </summary>
        /// <param name="writer">to output to</param>
        /// <param name="formatter">for NewLine-whitespace formatting</param>
        /// <param name="isTopLevel">to indicate if this insert-into-clause is inside other clauses.</param>
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter,
            bool isTopLevel)
        {
            formatter.BeginInsertInto(writer, isTopLevel);
            writer.Write("insert ");
            if (StreamSelector != StreamSelector.ISTREAM_ONLY)
            {
                writer.Write(StreamSelector.GetEPL());
                writer.Write(" ");
            }

            writer.Write("into ");
            writer.Write(StreamName);

            if (ColumnNames.Count > 0)
            {
                writer.Write("(");
                string delimiter = "";
                foreach (var name in ColumnNames)
                {
                    writer.Write(delimiter);
                    writer.Write(name);
                    delimiter = ", ";
                }

                writer.Write(")");
            }
        }
Пример #9
0
 public override void ToPrecedenceFreeEPL(
     TextWriter writer,
     EPStatementFormatter formatter)
 {
     writer.Write("not ");
     Children[0].ToEPL(writer, Precedence, formatter);
 }
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            HashFunction?.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);

            writer.Write(" from ");
            Filter.ToEPL(writer, formatter);
        }
Пример #11
0
 /// <summary>RenderAny as EPL. </summary>
 /// <param name="writer">to output to</param>
 /// <param name="formatter">formatter</param>
 public void ToEPL(
     TextWriter writer,
     EPStatementFormatter formatter)
 {
     writer.Write("create context ");
     writer.Write(ContextName);
     writer.Write(" as ");
     Descriptor.ToEPL(writer, formatter);
 }
Пример #12
0
 public void ToEPL(
     TextWriter writer,
     EPStatementFormatter formatter)
 {
     writer.Write("group ");
     Expression.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
     writer.Write(" as ");
     writer.Write(Label);
 }
 public void ToEPL(
     TextWriter writer,
     EPStatementFormatter formatter)
 {
     Filter.ToEPL(writer, formatter);
     if (OptionalAsName != null)
     {
         writer.Write(" as ");
         writer.Write(OptionalAsName);
     }
 }
Пример #14
0
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            if (IsNow)
            {
                writer.Write("@now and");
            }

            writer.Write("after ");
            TimePeriod.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
        }
Пример #15
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            string delimiter = "";

            foreach (PatternExpr child in Children)
            {
                writer.Write(delimiter);
                child.ToEPL(writer, Precedence, formatter);
                delimiter = " or ";
            }
        }
Пример #16
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            if ((Children == null) || (Children.Count == 0))
            {
                return;
            }

            PatternExpr patternExpr = Children[0];

            patternExpr?.ToEPL(writer, Precedence, formatter);
        }
Пример #17
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            if (Single != null)
            {
                writer.Write("[");
                Single.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                writer.Write("]");
            }
            else
            {
                if (Low != null || High != null)
                {
                    writer.Write("[");
                    if ((Low != null) && (High != null))
                    {
                        Low.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                        writer.Write(":");
                        High.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                    }
                    else if (Low != null)
                    {
                        Low.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                        writer.Write(":");
                    }
                    else
                    {
                        writer.Write(":");
                        High.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                    }

                    writer.Write("] ");
                }
            }

            PatternExprPrecedenceEnum precedence = Precedence;

            if (Children[0] is PatternMatchUntilExpr)
            {
                precedence = PatternExprPrecedenceEnum.MAXIMIM;
            }

            Children[0].ToEPL(writer, precedence, formatter);

            if (Children.Count > 1)
            {
                writer.Write(" until ");
                Children[1].ToEPL(writer, Precedence, formatter);
            }
        }
Пример #18
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            writer.Write("every ");
            PatternExprPrecedenceEnum precedence = Precedence;

            if (Children[0] is PatternEveryExpr)
            {
                precedence = PatternExprPrecedenceEnum.MAXIMIM;
            }

            Children[0].ToEPL(writer, precedence, formatter);
        }
Пример #19
0
 public virtual void ToEPL(
     TextWriter writer,
     PatternExprPrecedenceEnum parentPrecedence,
     EPStatementFormatter formatter)
 {
     if (Precedence.GetLevel() < parentPrecedence.GetLevel())
     {
         writer.Write("(");
         ToPrecedenceFreeEPL(writer, formatter);
         writer.Write(")");
     }
     else
     {
         ToPrecedenceFreeEPL(writer, formatter);
     }
 }
Пример #20
0
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            string delimiter = "";

            foreach (CreateContextClause context in Contexts)
            {
                writer.Write(delimiter);
                writer.Write("context ");
                writer.Write(context.ContextName);
                writer.Write(" as ");
                context.Descriptor.ToEPL(writer, formatter);
                delimiter = ", ";
            }
        }
Пример #21
0
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            string delimiter = "";

            foreach (ContextDescriptorCategoryItem item in Items)
            {
                writer.Write(delimiter);
                item.ToEPL(writer, formatter);
                delimiter = ", ";
            }

            writer.Write(" from ");
            Filter.ToEPL(writer, formatter);
        }
Пример #22
0
        /// <summary>
        /// Renders the clause in textual representation.
        /// </summary>
        /// <param name="writer">to output to</param>
        /// <param name="formatter">for NewLine-whitespace formatting</param>
        /// <param name="isTopLevel">to indicate if this select-clause is inside other clauses.</param>
        /// <param name="andDelete">indicator whether select and delete.</param>
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter,
            bool isTopLevel,
            bool andDelete)
        {
            formatter.BeginSelect(writer, isTopLevel);
            writer.Write("select ");
            if (andDelete)
            {
                writer.Write("and delete ");
            }

            if (IsDistinct)
            {
                writer.Write("distinct ");
            }

            if (_streamSelector == StreamSelector.ISTREAM_ONLY)
            {
                // the default, no action
            }
            else if (_streamSelector == StreamSelector.RSTREAM_ONLY)
            {
                writer.Write("rstream ");
            }
            else if (_streamSelector == StreamSelector.RSTREAM_ISTREAM_BOTH)
            {
                writer.Write("irstream ");
            }

            if (_selectList != null && !_selectList.IsEmpty())
            {
                string delimiter = "";
                foreach (SelectClauseElement element in _selectList)
                {
                    writer.Write(delimiter);
                    element.ToEPLElement(writer);
                    delimiter = ", ";
                }
            }
            else
            {
                writer.Write('*');
            }
        }
Пример #23
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            writer.Write("every-distinct(");
            string delimiter = "";

            foreach (Expression expr in Expressions)
            {
                writer.Write(delimiter);
                expr.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                delimiter = ",";
            }

            writer.Write(") ");

            Children[0].ToEPL(writer, Precedence, formatter);
        }
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            if (IsNow)
            {
                writer.Write("@now and");
            }

            writer.Write("pattern [");
            Pattern?.ToEPL(writer, PatternExprPrecedenceEnum.MINIMUM, formatter);

            writer.Write("]");
            if (IsInclusive)
            {
                writer.Write("@Inclusive");
            }
        }
Пример #25
0
        /// <summary>
        ///     Print.
        /// </summary>
        /// <param name="writer">to print to</param>
        /// <param name="annotations">annotations</param>
        /// <param name="formatter">for newline-whitespace formatting</param>
        public static void ToEPL(
            TextWriter writer,
            IList<AnnotationPart> annotations,
            EPStatementFormatter formatter)
        {
            if (annotations == null || annotations.IsEmpty())
            {
                return;
            }

            foreach (var part in annotations)
            {
                if (part.Name == null)
                {
                    continue;
                }

                formatter.BeginAnnotation(writer);
                part.ToEPL(writer);
            }
        }
Пример #26
0
        /// <summary>
        /// Print.
        /// </summary>
        /// <param name="writer">to print to</param>
        /// <param name="scripts">scripts</param>
        /// <param name="formatter">for newline-whitespace formatting</param>
        public static void ToEPL(
            TextWriter writer,
            IList<ScriptExpression> scripts,
            EPStatementFormatter formatter)
        {
            if ((scripts == null) || (scripts.IsEmpty()))
            {
                return;
            }

            foreach (ScriptExpression part in scripts)
            {
                if (part.Name == null)
                {
                    continue;
                }

                formatter.BeginExpressionDecl(writer);
                part.ToEPL(writer);
            }
        }
        public void ToEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            writer.Write("coalesce ");
            string delimiter = "";

            foreach (ContextDescriptorHashSegmentedItem item in Items)
            {
                writer.Write(delimiter);
                item.ToEPL(writer, formatter);
                delimiter = ", ";
            }

            writer.Write(" granularity ");
            writer.Write(Convert.ToString(Granularity));
            if (IsPreallocate)
            {
                writer.Write(" preallocate");
            }
        }
Пример #28
0
        /// <summary>
        /// Print.
        /// </summary>
        /// <param name="writer">to print to</param>
        /// <param name="expressionDeclarations">expression declarations</param>
        /// <param name="formatter">for newline-whitespace formatting</param>
        public static void ToEPL(
            TextWriter writer,
            IList <ExpressionDeclaration> expressionDeclarations,
            EPStatementFormatter formatter)
        {
            if ((expressionDeclarations == null) || (expressionDeclarations.IsEmpty()))
            {
                return;
            }

            foreach (var part in expressionDeclarations)
            {
                if (part.Name == null)
                {
                    continue;
                }

                formatter.BeginExpressionDecl(writer);
                part.ToEPL(writer);
            }
        }
Пример #29
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            EPStatementFormatter formatter)
        {
            if (TagName != null)
            {
                writer.Write(TagName);
                writer.Write('=');
            }

            Filter.ToEPL(writer, formatter);
            if (OptionalConsumptionLevel != null)
            {
                writer.Write("@consume");
                if (OptionalConsumptionLevel != 1)
                {
                    writer.Write("(");
                    writer.Write(Convert.ToString(OptionalConsumptionLevel));
                    writer.Write(")");
                }
            }
        }
Пример #30
0
        /// <summary>
        ///     Renders the object model in it's EPL syntax textual representation, using a whitespace-formatter as provided.
        /// </summary>
        /// <param name="formatter">the formatter to use</param>
        /// <param name="writer">writer to use</param>
        /// <throws>IllegalStateException if required clauses do not exist</throws>
        public void ToEPL(
            EPStatementFormatter formatter,
            TextWriter writer)
        {
            AnnotationPart.ToEPL(writer, Annotations, formatter);
            ExpressionDeclaration.ToEPL(writer, ExpressionDeclarations, formatter);
            ScriptExpression.ToEPL(writer, ScriptExpressions, formatter);
            ClassProvidedExpression.ToEPL(writer, ClassProvidedExpressions, formatter);

            if (ContextName != null)
            {
                formatter.BeginContext(writer);
                writer.Write("context ");
                writer.Write(ContextName);
            }

            if (CreateIndex != null)
            {
                formatter.BeginCreateIndex(writer);
                CreateIndex.ToEPL(writer);
                return;
            }

            if (CreateSchema != null)
            {
                formatter.BeginCreateSchema(writer);
                CreateSchema.ToEPL(writer);
                return;
            }

            if (CreateExpression != null)
            {
                formatter.BeginCreateExpression(writer);
                CreateExpression.ToEPL(writer);
                return;
            }

            if (CreateClass != null)
            {
                formatter.BeginCreateExpression(writer);
                CreateClass.ToEPL(writer);
                return;
            }

            if (CreateContext != null)
            {
                formatter.BeginCreateContext(writer);
                CreateContext.ToEPL(writer, formatter);
                return;
            }

            if (CreateWindow != null)
            {
                formatter.BeginCreateWindow(writer);
                CreateWindow.ToEPL(writer);

                writer.Write(" as ");

                if (SelectClause == null || SelectClause.SelectList.IsEmpty() && !CreateWindow.Columns.IsEmpty())
                {
                    CreateWindow.ToEPLCreateTablePart(writer);
                }
                else
                {
                    SelectClause.ToEPL(writer, formatter, false, false);
                    if (CreateWindow.AsEventTypeName != null)
                    {
                        writer.Write(" from ");
                        writer.Write(CreateWindow.AsEventTypeName);
                    }

                    CreateWindow.ToEPLInsertPart(writer);
                }

                return;
            }

            if (CreateVariable != null)
            {
                formatter.BeginCreateVariable(writer);
                CreateVariable.ToEPL(writer);
                return;
            }

            if (CreateTable != null)
            {
                formatter.BeginCreateTable(writer);
                CreateTable.ToEPL(writer);
                return;
            }

            if (CreateDataFlow != null)
            {
                formatter.BeginCreateDataFlow(writer);
                CreateDataFlow.ToEPL(writer, formatter);
                return;
            }

            var displayWhereClause = true;

            if (UpdateClause != null)
            {
                formatter.BeginUpdate(writer);
                UpdateClause.ToEPL(writer);
            }
            else if (OnExpr != null)
            {
                formatter.BeginOnTrigger(writer);
                writer.Write("on ");
                FromClause.Streams[0].ToEPL(writer, formatter);

                if (OnExpr is OnDeleteClause onDeleteClause)
                {
                    formatter.BeginOnDelete(writer);
                    writer.Write("delete from ");
                    onDeleteClause.ToEPL(writer);
                }
                else if (OnExpr is OnUpdateClause onUpdateClause)
                {
                    formatter.BeginOnUpdate(writer);
                    writer.Write("update ");
                    onUpdateClause.ToEPL(writer);
                }
                else if (OnExpr is OnSelectClause onSelectClause)
                {
                    InsertInto?.ToEPL(writer, formatter, true);
                    SelectClause.ToEPL(writer, formatter, true, onSelectClause.IsDeleteAndSelect);
                    writer.Write(" from ");
                    onSelectClause.ToEPL(writer);
                }
                else if (OnExpr is OnSetClause onSetClause)
                {
                    onSetClause.ToEPL(writer, formatter);
                }
                else if (OnExpr is OnMergeClause onMergeClause)
                {
                    onMergeClause.ToEPL(writer, WhereClause, formatter);
                    displayWhereClause = false;
                }
                else
                {
                    var split = (OnInsertSplitStreamClause)OnExpr;
                    InsertInto.ToEPL(writer, formatter, true);
                    SelectClause.ToEPL(writer, formatter, true, false);
                    if (WhereClause != null)
                    {
                        writer.Write(" where ");
                        WhereClause.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
                    }

                    split.ToEPL(writer, formatter);
                    displayWhereClause = false;
                }
            }
            else
            {
                IntoTableClause?.ToEPL(writer);

                if (SelectClause == null)
                {
                    throw new IllegalStateException("Select-clause has not been defined");
                }

                if (FromClause == null)
                {
                    throw new IllegalStateException("From-clause has not been defined");
                }

                if (FireAndForgetClause is FireAndForgetUpdate fireAndForgetUpdate)
                {
                    writer.Write("update ");
                    FromClause.ToEPLOptions(writer, formatter, false);
                    writer.Write(" ");
                    UpdateClause.RenderEPLAssignments(writer, fireAndForgetUpdate.Assignments);
                }
                else if (FireAndForgetClause is FireAndForgetInsert fireAndForgetInsert)
                {
                    InsertInto.ToEPL(writer, formatter, true);
                    if (fireAndForgetInsert.IsUseValuesKeyword)
                    {
                        writer.Write(" values (");
                        var delimiter = "";
                        foreach (var element in SelectClause.SelectList)
                        {
                            writer.Write(delimiter);
                            element.ToEPLElement(writer);
                            delimiter = ", ";
                        }

                        writer.Write(")");
                    }
                    else
                    {
                        SelectClause.ToEPL(writer, formatter, true, false);
                    }
                }
                else if (FireAndForgetClause is FireAndForgetDelete)
                {
                    writer.Write("delete ");
                    FromClause.ToEPLOptions(writer, formatter, true);
                }
                else
                {
                    InsertInto?.ToEPL(writer, formatter, true);
                    SelectClause.ToEPL(writer, formatter, true, false);
                    FromClause.ToEPLOptions(writer, formatter, true);
                }
            }

            MatchRecognizeClause?.ToEPL(writer);

            if (WhereClause != null && displayWhereClause)
            {
                formatter.BeginWhere(writer);
                writer.Write("where ");
                WhereClause.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
            }

            if (GroupByClause != null)
            {
                formatter.BeginGroupBy(writer);
                writer.Write("group by ");
                GroupByClause.ToEPL(writer);
            }

            if (HavingClause != null)
            {
                formatter.BeginHaving(writer);
                writer.Write("having ");
                HavingClause.ToEPL(writer, ExpressionPrecedenceEnum.MINIMUM);
            }

            if (OutputLimitClause != null)
            {
                formatter.BeginOutput(writer);
                writer.Write("output ");
                OutputLimitClause.ToEPL(writer);
            }

            if (OrderByClause != null)
            {
                formatter.BeginOrderBy(writer);
                writer.Write("order by ");
                OrderByClause.ToEPL(writer);
            }

            if (RowLimitClause != null)
            {
                formatter.BeginLimit(writer);
                writer.Write("limit ");
                RowLimitClause.ToEPL(writer);
            }

            if (ForClause != null)
            {
                formatter.BeginFor(writer);
                ForClause.ToEPL(writer);
            }
        }