当前位置: 首页>>代码示例>>Java>>正文


Java SiddhiParserException类代码示例

本文整理汇总了Java中org.wso2.siddhi.query.compiler.exception.SiddhiParserException的典型用法代码示例。如果您正苦于以下问题:Java SiddhiParserException类的具体用法?Java SiddhiParserException怎么用?Java SiddhiParserException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SiddhiParserException类属于org.wso2.siddhi.query.compiler.exception包,在下文中一共展示了SiddhiParserException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClusTree2D_23

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
@Test
public void testClusTree2D_23() throws Exception {
    logger.info("ClusTreeStreamProcessorExtension Test - Test case with non existing stream");
    SiddhiManager siddhiManager = new SiddhiManager();
    //String inputStream = "define stream InputStream (x double, y double);";

    String query = (
            "@info(name = 'query1') " +
                    "from InputStream#streamingml:clusTree(2, 10, 20, 2, -50, x, y) " +
                    "select closestCentroidCoordinate1, closestCentroidCoordinate2, x, y " +
                    "insert into OutputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(query);
    } catch (Exception e) {
        logger.info("Error caught");
        AssertJUnit.assertTrue(e instanceof SiddhiParserException);
        AssertJUnit.assertTrue(e.getMessage().contains("Syntax error in SiddhiQL, no viable alternative at input "
                + "'@info(name = query1)"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:21,代码来源:ClusTreeStreamProcessorExtensionTest.java

示例2: testClusTree2D_26

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
@Test
public void testClusTree2D_26() throws Exception {
    logger.info("ClusTreeStreamProcessorExtension Test - Test case with one empty parameter");
    SiddhiManager siddhiManager = new SiddhiManager();
    String inputStream = "define stream InputStream (x double, y double);";

    String query = (
            "@info(name = 'query1') " +
                    "from InputStream#streamingml:clusTree(2, 10, 20, 2,, x, y) " +
                    "select closestCentroidCoordinate1, closestCentroidCoordinate2, x, y " +
                    "insert into OutputStream;");
    try {
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inputStream + query);
    } catch (Exception e) {
        logger.info("Error caught");
        AssertJUnit.assertTrue(e instanceof SiddhiParserException);
        AssertJUnit.assertTrue(e.getMessage().contains("Syntax error in SiddhiQL, no viable " +
                "alternative at input 'InputStream#streamingml:clusTree(2, 10, 20, 2,,"));
    }
}
 
开发者ID:wso2-extensions,项目名称:siddhi-gpl-execution-streamingml,代码行数:21,代码来源:ClusTreeStreamProcessorExtensionTest.java

示例3: parse

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
public static List<ExecutionPlan> parse(String source) throws SiddhiParserException {
        try {

            ANTLRInputStream input = new ANTLRInputStream(source);
            SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer(input);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);
            ParseTree tree = parser.query(); // parse

            SiddhiQLGrammarVisitor eval = new SiddhiQLGrammarBasedVisitorImpl();
            System.out.println(eval.visit(tree));
//          return (List<ExecutionPlan>) eval.visit(tree);
          return null;

        } catch (Throwable e) {
            throw new SiddhiParserException(e.getMessage(), e);
        }
    }
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:19,代码来源:SiddhiCompiler.java

示例4: visitDefinitionStream

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitDefinitionStream(@NotNull SiddhiQLGrammarParser.DefinitionStreamContext ctx) {

    StreamDefinition streamDefinition = QueryFactory.createStreamDefinition();
    streamDefinition.name(ctx.source().getText());

    List<Attribute> attributeList = (List<Attribute>) visitDefinition(ctx.definition());
    if (attributeList != null) {
        for (Attribute attribute : attributeList) {
            streamDefinition.attribute(attribute.getName(), attribute.getType());
        }
    } else {
        throw new SiddhiParserException("Operation not supported :fromSource and likeSource");
    }
    return streamDefinition;
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:25,代码来源:SiddhiQLGrammarBasedVisitorImpl.java

示例5: visitDefinitionTable

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitDefinitionTable(@NotNull SiddhiQLGrammarParser.DefinitionTableContext ctx) {
    TableDefinition tableDefinition = QueryFactory.createTableDefinition();
    tableDefinition.name(ctx.source().getText());

    List<Attribute> attributeList = (List<Attribute>) visitDefinition(ctx.definition());
    if (attributeList != null) {
        for (Attribute attribute : attributeList) {
            tableDefinition.attribute(attribute.getName(), attribute.getType());
        }
    } else {
        throw new SiddhiParserException("Operation not supported :fromSource and likeSource");
    }

    for (int i = 0; i < ctx.parameterName().size(); i++) {
        tableDefinition.fromParameter((String) visit(ctx.parameterName(i)), (String) visit(ctx.parameterValue(i)));
    }
    return tableDefinition;
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:28,代码来源:SiddhiQLGrammarBasedVisitorImpl.java

示例6: visitStandardStream

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitStandardStream(@NotNull SiddhiQLGrammarParser.StandardStreamContext ctx) {
    TransformedStream stream = QueryFactory.inputStream((String) visitSource(ctx.source()));
    for (int i = 2; i < ctx.getChildCount(); i++) {
        Object handler = visit(ctx.getChild(i));
        if (handler instanceof Filter) {
            ((BasicStream) stream).setFilter((Filter) handler);
        } else if (handler instanceof Transformer) {
            ((BasicStream) stream).setTransformer((Transformer) handler);
        } else if (handler instanceof Window) {
            stream.window((Window) handler);
        } else {
            throw new SiddhiParserException("Unsupported operation " + ctx.getChild(i).getText());
        }

    }
    return stream;
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:27,代码来源:SiddhiQLGrammarBasedVisitorImpl.java

示例7: addExecutionPlan

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
public ExecutionPlanReference addExecutionPlan(String executionPlan) throws SiddhiParserException {
    List<ExecutionPlan> executionPlanList = SiddhiCompiler.parse(executionPlan);
    ExecutionPlanReference executionPlanReference = new ExecutionPlanReference();
    for (ExecutionPlan plan : executionPlanList) {
        if (plan instanceof Query) {
            executionPlanReference.addQueryReference(addQuery((Query) plan));
        } else if (plan instanceof StreamDefinition) {
            executionPlanReference.addInputHandler(defineStream((StreamDefinition) plan));
        } else if (plan instanceof TableDefinition) {
            defineTable((TableDefinition) plan);
        } else if (plan instanceof PartitionDefinition) {
            definePartition((PartitionDefinition) plan);
        } else {
            throw new OperationNotSupportedException(plan.getClass().getName() + " is not supported as an execution plan element ");
        }
    }

    return executionPlanReference;
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:20,代码来源:SiddhiManager.java

示例8: testQuery4

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
@Test(expected = QueryNotExistException.class)
public void testQuery4() throws InterruptedException, SiddhiParserException {

    log.info("QueryNotExistException for Callback assignment test");

    SiddhiManager siddhiManager = new SiddhiManager();

    InputHandler inputHandler = siddhiManager.defineStream("define stream cseStream ( symbol string, price float, volume int )");


    siddhiManager.addCallback("test", new QueryCallback() {
        @Override

        public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
            EventPrinter.print(timeStamp, inEvents, removeEvents);
            Assert.assertTrue("IBM".equals(inEvents[0].getData(0)) || "WSO2".equals(inEvents[0].getData(0)));
            count++;
        }
    });

    String queryReference = siddhiManager.addQuery("from cseStream[price>10] " +
                                                   "select symbol, price, volume " +
                                                   "insert into outStream;");
    siddhiManager.shutdown();
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:26,代码来源:CallbackTestCase.java

示例9: main

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, SiddhiParserException {

        // Create Siddhi Manager
        SiddhiManager siddhiManager = new SiddhiManager();

        siddhiManager.defineStream("define stream cseEventStream ( symbol string, price float, volume int )");
        siddhiManager.addQuery("from  cseEventStream [ price >= 50 ] " +
                               "select symbol, price "+
                               "insert into StockQuote ;");

        siddhiManager.addCallback("StockQuote", new StreamCallback() {
            @Override
            public void receive(Event[] events) {
                EventPrinter.print(events);
            }
        });
        InputHandler inputHandler = siddhiManager.getInputHandler("cseEventStream");
        inputHandler.send(new Object[]{"IBM", 75.6f, 100});
        inputHandler.send(new Object[]{"GOOG", 50f, 100});
        inputHandler.send(new Object[]{"IBM", 76.6f, 100});
        inputHandler.send(new Object[]{"WSO2", 45.6f, 100});
        Thread.sleep(500);

        siddhiManager.shutdown();
    }
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:26,代码来源:SimpleFilterSample.java

示例10: parse

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
public static List<ExecutionPlan> parse(String source) throws SiddhiParserException {
    try {
        SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
        lexer.setCharStream(new ANTLRStringStream(source));
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);

        SiddhiQLGrammarParser.executionPlan_return r = parser.executionPlan();
        CommonTree t = (CommonTree) r.getTree();

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
        nodes.setTokenStream(tokens);
        SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
        return walker.executionPlan();
    } catch (Throwable e) {
        throw new SiddhiParserException(e.getMessage(), e);
    }
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:19,代码来源:SiddhiCompiler.java

示例11: parseStreamDefinition

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
public static StreamDefinition parseStreamDefinition(String source) throws SiddhiParserException {
    try {
        SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
        lexer.setCharStream(new ANTLRStringStream(source));
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);

        SiddhiQLGrammarParser.definitionStreamFinal_return r = parser.definitionStreamFinal();
        CommonTree t = (CommonTree) r.getTree();

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
        nodes.setTokenStream(tokens);
        SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
        return walker.definitionStreamFinal();
    } catch (Throwable e) {
        throw new SiddhiParserException(e.getMessage(), e);
    }
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:19,代码来源:SiddhiCompiler.java

示例12: parsePartitionDefinition

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
public static PartitionDefinition parsePartitionDefinition(String source) throws SiddhiParserException {
    try {
        SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
        lexer.setCharStream(new ANTLRStringStream(source));
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);

        SiddhiQLGrammarParser.definitionPartitionFinal_return r = parser.definitionPartitionFinal();
        CommonTree t = (CommonTree) r.getTree();

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
        nodes.setTokenStream(tokens);
        SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
        return walker.definitionPartitionFinal();
    } catch (Throwable e) {
        throw new SiddhiParserException(e.getMessage(), e);
    }
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:19,代码来源:SiddhiCompiler.java

示例13: parseQuery

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
public static Query parseQuery(String source) throws SiddhiParserException {
    try {
        SiddhiQLGrammarLexer lexer = new SiddhiQLGrammarLexer();
        lexer.setCharStream(new ANTLRStringStream(source));
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        SiddhiQLGrammarParser parser = new SiddhiQLGrammarParser(tokens);

        SiddhiQLGrammarParser.queryFinal_return r = parser.queryFinal();
        CommonTree t = (CommonTree) r.getTree();

        CommonTreeNodeStream nodes = new CommonTreeNodeStream(t);
        nodes.setTokenStream(tokens);
        SiddhiQLGrammarWalker walker = new SiddhiQLGrammarWalker(nodes);
        return walker.queryFinal();
    } catch (Throwable e) {
        throw new SiddhiParserException(e.getMessage(), e);
    }
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:19,代码来源:SiddhiCompiler.java

示例14: testPartitionDefinition

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
@Test
public void testPartitionDefinition() throws RecognitionException, SiddhiParserException {
    PartitionDefinition partitionDefinition =
            SiddhiCompiler.parsePartitionDefinition("define partition bySymbolLarge by cseStream.symbol, range cseStream.volume >= 100 as 'Large'");
    Assert.assertEquals(new PartitionDefinition().name("bySymbolLarge")
                                .partitionBy(Expression.variable("cseStream", "symbol"))
                                .partitionBy(Condition.compare(Expression.variable("cseStream", "volume"),
                                                               Operator.GREATER_THAN_EQUAL,
                                                               Expression.value(100)), "Large"),
                        partitionDefinition);
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:12,代码来源:DefinePartitionTestCase.java

示例15: Test4

import org.wso2.siddhi.query.compiler.exception.SiddhiParserException; //导入依赖的package包/类
@Test
public void Test4() throws RecognitionException, SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from every a1 = infoStock[action == \"buy\"] or\n" +
                                            "    a2 = infoStock[action == \"buy\"] ->\n" +
                                            "          b1 = cseEventStream[price > 70] ->\n" +
                                            "          b2 = cseEventStream[price > 75]\n" +
                                            "select coalesce(a1.action, a2.action) as action,\n" +
                                            "   b1.price as priceA,\n" +
                                            "   b2.price as priceB\n" +
                                            "insert into StockQuote\n");
    Assert.assertNotNull(query);
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:13,代码来源:PatternTestCase.java


注:本文中的org.wso2.siddhi.query.compiler.exception.SiddhiParserException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。