Beispiel #1
0
        public static CreateDataFlowDesc WalkCreateDataFlow(EsperEPL2GrammarParser.CreateDataflowContext ctx, IDictionary <ITree, Object> astGraphNodeMap, EngineImportService engineImportService)
        {
            var graphName = ctx.name.Text;

            IList <GraphOperatorSpec> ops     = new List <GraphOperatorSpec>();
            IList <CreateSchemaDesc>  schemas = new List <CreateSchemaDesc>();

            IList <EsperEPL2GrammarParser.GopContext> gopctxs = ctx.gopList().gop();

            foreach (var gopctx in gopctxs)
            {
                if (gopctx.createSchemaExpr() != null)
                {
                    schemas.Add(ASTCreateSchemaHelper.WalkCreateSchema(gopctx.createSchemaExpr()));
                }
                else
                {
                    ops.Add(ParseOp(gopctx, astGraphNodeMap, engineImportService));
                }
            }
            return(new CreateDataFlowDesc(graphName, ops, schemas));
        }
Beispiel #2
0
        private static CreateTableColumn GetColumn(EsperEPL2GrammarParser.CreateTableColumnContext ctx, IDictionary <ITree, ExprNode> astExprNodeMap, EngineImportService engineImportService)
        {
            string columnName = ctx.n.Text;

            ExprNode optExpression = null;

            if (ctx.builtinFunc() != null || ctx.libFunction() != null)
            {
                optExpression = ASTExprHelper.ExprCollectSubNodes(ctx, 0, astExprNodeMap)[0];
            }

            string optTypeName             = null;
            bool?  optTypeIsArray          = null;
            bool?  optTypeIsPrimitiveArray = null;

            if (ctx.createTableColumnPlain() != null)
            {
                EsperEPL2GrammarParser.CreateTableColumnPlainContext sub = ctx.createTableColumnPlain();
                optTypeName             = ASTUtil.UnescapeClassIdent(sub.classIdentifier());
                optTypeIsArray          = sub.b != null;
                optTypeIsPrimitiveArray = ASTCreateSchemaHelper.ValidateIsPrimitiveArray(sub.p);
            }

            bool primaryKey = false;

            if (ctx.p != null)
            {
                if (ctx.p.Text.ToLower() != "primary")
                {
                    throw ASTWalkException.From("Invalid keyword '" + ctx.p.Text + "' encountered, expected 'primary key'");
                }
                if (ctx.k.Text.ToLower() != "key")
                {
                    throw ASTWalkException.From("Invalid keyword '" + ctx.k.Text + "' encountered, expected 'primary key'");
                }
                primaryKey = true;
            }

            IList <AnnotationDesc> annots = Collections.GetEmptyList <AnnotationDesc>();

            if (ctx.annotationEnum() != null)
            {
                annots = new List <AnnotationDesc>(ctx.annotationEnum().Length);
                foreach (EsperEPL2GrammarParser.AnnotationEnumContext anctx in ctx.annotationEnum())
                {
                    annots.Add(ASTAnnotationHelper.Walk(anctx, engineImportService));
                }
            }
            if (ctx.propertyExpressionAnnotation() != null)
            {
                if (annots.IsEmpty())
                {
                    annots = new List <AnnotationDesc>();
                }
                foreach (EsperEPL2GrammarParser.PropertyExpressionAnnotationContext anno in ctx.propertyExpressionAnnotation())
                {
                    annots.Add(new AnnotationDesc(anno.n.Text, anno.v.Text));
                }
            }

            return(new CreateTableColumn(columnName, optExpression, optTypeName, optTypeIsArray, optTypeIsPrimitiveArray, annots, primaryKey));
        }