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


Java SiddhiCompiler类代码示例

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


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

示例1: addExecutionPlan

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的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

示例2: test1

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test1() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  StockStream[price>3]#window.length(50) " +
            "select symbol, avg(price) as avgPrice " +
            "group by symbol " +
            "having (price >= 20) " +
            "insert all events into StockQuote; "
    );
    AssertJUnit.assertNotNull(query);

    Query api = Query.query().from(InputStream.stream("StockStream").
            filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression
                    .value(3))).
            window("length", Expression.value(50))).
            select(Selector.selector().select(Expression.variable("symbol")).
                    select("avgPrice", Expression.function("avg", Expression.variable("price"))).
                    groupBy(Expression.variable("symbol")).
                    having(Expression.compare(
                            Expression.variable("price"),
                            Compare.Operator.GREATER_THAN_EQUAL,
                            Expression.value(20)))).
            insertInto("StockQuote", OutputStream.OutputEventType.ALL_EVENTS);
    AssertJUnit.assertEquals(api, query);

}
 
开发者ID:wso2,项目名称:siddhi,代码行数:26,代码来源:SimpleQueryTestCase.java

示例3: test2

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test2() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  StockStream [price >= 20]#window.lengthBatch(50) " +
            "select symbol, avg(price) as avgPrice " +
            "group by symbol " +
            "having avgPrice>50 " +
            "insert into StockQuote; "
    );
    AssertJUnit.assertNotNull(query);

    Query api = Query.query().from(InputStream.stream("StockStream").
            filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL,
                    Expression.value(20))).
            window("lengthBatch", Expression.value(50))).
            select(Selector.selector().
                    select(Expression.variable("symbol")).
                    select("avgPrice", Expression.function("avg", Expression.variable("price"))).
                    groupBy(Expression.variable("symbol")).
                    having(Expression.compare(
                            Expression.variable("avgPrice"),
                            Compare.Operator.GREATER_THAN,
                            Expression.value(50)))).
            insertInto("StockQuote");
    AssertJUnit.assertEquals(api, query);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:26,代码来源:SimpleQueryTestCase.java

示例4: test4

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test4() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  AllStockQuotes#window.lenghtBatch(50)  " +
            "select symbol, avg(price) as avgPrice " +
            "return ;"
    );
    AssertJUnit.assertNotNull(query);

    Query api = Query.query().from(InputStream.stream("AllStockQuotes").
            window("lenghtBatch", Expression.value(50))).
            select(Selector.selector().
                    select("symbol", Expression.variable("symbol")).
                    select("avgPrice", Expression.function("avg", Expression.variable("price")))).
            returns();
    AssertJUnit.assertEquals(api, query);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:17,代码来源:SimpleQueryTestCase.java

示例5: test5

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test5() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  AllStockQuotes[price==Foo.price and Foo.try<5]  " +
            "select symbol, avg(price) as avgPrice " +
            "return ;"
    );
    AssertJUnit.assertNotNull(query);
    Query api = Query.query().from(InputStream.stream("AllStockQuotes").
            filter(Expression.and(Expression.compare(Expression.variable("price"), Compare.Operator.EQUAL,
                    Expression.variable("price").ofStream("Foo")), Expression.compare(Expression.variable("try")
                    .ofStream("Foo"), Compare.Operator.LESS_THAN, Expression.value(5))))).
            select(Selector.selector().
                    select("symbol", Expression.variable("symbol")).
                    select("avgPrice", Expression.function("avg", Expression.variable("price"))));
    AssertJUnit.assertEquals(api, query);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:17,代码来源:SimpleQueryTestCase.java

示例6: test1

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test1() throws SiddhiParserException {

    AggregationDefinition aggregationDefinitionQuery = SiddhiCompiler
            .parseAggregationDefinition("define aggregation StockAggregation " + "from StockStream "
                    + "select StockStream.timestamp as timestamp, StockStream.symbol as symbol, "
                    + "       StockStream.price as price " + "   group by StockStream.symbol "
                    + "aggregate by timestamp " + "every seconds ... days ;");

    AggregationDefinition aggregationDefinition = AggregationDefinition.id("StockAggregation")
            .from(InputStream.stream("StockStream"))
            .select(Selector.basicSelector()
                    .select("timestamp", Expression.variable("timestamp").ofStream("StockStream"))
                    .select("symbol", Expression.variable("symbol").ofStream("StockStream"))
                    .select("price", Expression.variable("price").ofStream("StockStream"))
                    .groupBy(Expression.variable("symbol").ofStream("StockStream")))
            .aggregateBy(Expression.variable("timestamp"))
            .every(TimePeriod.range(TimePeriod.Duration.SECONDS, TimePeriod.Duration.DAYS));

    AssertJUnit.assertEquals(aggregationDefinition, aggregationDefinitionQuery);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:22,代码来源:DefineAggregationTestCase.java

示例7: test2

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test2() throws SiddhiParserException {

    AggregationDefinition aggregationDefinitionQuery = SiddhiCompiler
            .parseAggregationDefinition("define aggregation StockAggregationDefinition " + "from StockStream "
                    + "select StockStream.timestamp, StockStream.symbol as symbol, "
                    + "       StockStream.price as price " + "   group by StockStream.symbol "
                    + "aggregate by timestamp " + "every seconds, minutes, hours ;");

    AggregationDefinition aggregationDefinition = AggregationDefinition.id("StockAggregationDefinition")
            .from(InputStream.stream("StockStream"))
            .select(Selector.basicSelector().select(Expression.variable("timestamp").ofStream("StockStream"))
                    .select("symbol", Expression.variable("symbol").ofStream("StockStream"))
                    .select("price", Expression.variable("price").ofStream("StockStream"))
                    .groupBy(Expression.variable("symbol").ofStream("StockStream")))
            .aggregateBy(Expression.variable("timestamp")).every(TimePeriod.interval(TimePeriod.Duration.SECONDS,
                    TimePeriod.Duration.MINUTES, TimePeriod.Duration.HOURS));

    AssertJUnit.assertEquals(aggregationDefinition, aggregationDefinitionQuery);

}
 
开发者ID:wso2,项目名称:siddhi,代码行数:22,代码来源:DefineAggregationTestCase.java

示例8: testMultilevelNestedAnnotations1

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void testMultilevelNestedAnnotations1() throws SiddhiParserException {
    StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition(
            "@sink(url='http://foo.com/test/{{data}}', " +
                    "   @map(type='xml', " +
                    "@payload('<test><time>{{time}}</time></test>')" +
                    "   )" +
                    ") " +
                    "define stream fooStream (id int, name string);"
    );

    AssertJUnit.assertEquals(
            StreamDefinition
                    .id("fooStream")
                    .attribute("id", Attribute.Type.INT)
                    .attribute("name", Attribute.Type.STRING)
                    .annotation(Annotation.annotation("sink")
                            .element("url", "http://foo.com/test/{{data}}")
                            .annotation(Annotation.annotation("map")
                                    .element("type", "xml")
                                    .annotation(Annotation.annotation("payload")
                                            .element("<test><time>{{time}}</time></test>")))),
            streamDefinition);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:25,代码来源:DefineStreamTestCase.java

示例9: test4

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test4() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from e1=Stream1[price>20] -> not Stream2[price>e1.price] for 2 sec " +
            "select e1.symbol as symbol1 " +
            "insert into OutputStream ;");
    AssertJUnit.assertNotNull(query);

    Query api = Query.query();
    api.from(
            InputStream.patternStream(State.next(
                    State.stream(InputStream.stream("e1", "Stream1")
                            .filter(Expression.compare(Expression.variable("price"),
                                    Compare.Operator.GREATER_THAN,
                                    Expression.value(20)))),
                    State.logicalNot(State.stream(InputStream.stream("Stream2")
                            .filter(Expression.compare(Expression.variable("price"),
                                    Compare.Operator.GREATER_THAN,
                                    Expression.variable("price").ofStream("e1")))))
                            .waitingTime(new TimeConstant(2000)))
            ))
            .select(Selector.selector().select("symbol1", Expression.variable("symbol").ofStream("e1")))
            .insertInto("OutputStream");

    AssertJUnit.assertEquals(api, query);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:26,代码来源:AbsentPatternTestCase.java

示例10: test1

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test1() {
    Partition partition = SiddhiCompiler.parsePartition("partition with (200>volume as 'LessValue' or 200<=volume" +
            " as 'HighValue' of cseEventStream) begin from cseEventStream select sum(volume) as sumvolume insert " +
            "into StockStream ;  end ");

    AssertJUnit.assertEquals(Partition.partition().
                    with("cseEventStream",
                            Partition.range("LessValue",
                                    Expression.compare(
                                            Expression.value(200),
                                            Compare.Operator.GREATER_THAN,
                                            Expression.variable("volume"))
                            ),
                            Partition.range("HighValue",
                                    Expression.compare(
                                            Expression.value(200),
                                            Compare.Operator.LESS_THAN_EQUAL,
                                            Expression.variable("volume"))
                            )).toString().split("queryList")[0],
            partition.toString().split("queryList")[0]);
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:23,代码来源:DefinePartitionTestCase.java

示例11: test1

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test1() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  StockStream[price>3]#window.length(50) " +
                    "select symbol, avg(price) as avgPrice " +
                    "group by symbol " +
                    "having (price >= 20) " +
                    "insert all events into StockQuote; "
    );
    Assert.assertNotNull(query);

    Query api = Query.query().from(InputStream.stream("StockStream").
            filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN, Expression.value(3))).
            window("length", Expression.value(50))).
            select(Selector.selector().select(Expression.variable("symbol")).
                    select("avgPrice", Expression.function("avg", Expression.variable("price"))).
                    groupBy(Expression.variable("symbol")).
                    having(Expression.compare(
                            Expression.variable("price"),
                            Compare.Operator.GREATER_THAN_EQUAL,
                            Expression.value(20)))).
            insertInto("StockQuote", OutputStream.OutputEventType.ALL_EVENTS);
    Assert.assertEquals(api, query);


}
 
开发者ID:sacjaya,项目名称:siddhi-3,代码行数:26,代码来源:SimpleQueryTestCase.java

示例12: test2

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test2() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  StockStream [price >= 20]#window.lengthBatch(50) " +
                    "select symbol, avg(price) as avgPrice " +
                    "group by symbol " +
                    "having avgPrice>50 " +
                    "insert into StockQuote; "
    );
    Assert.assertNotNull(query);

    Query api = Query.query().from(InputStream.stream("StockStream").
            filter(Expression.compare(Expression.variable("price"), Compare.Operator.GREATER_THAN_EQUAL, Expression.value(20))).
            window("lengthBatch", Expression.value(50))).
            select(Selector.selector().
                    select(Expression.variable("symbol")).
                    select("avgPrice", Expression.function("avg", Expression.variable("price"))).
                    groupBy(Expression.variable("symbol")).
                    having(Expression.compare(
                            Expression.variable("avgPrice"),
                            Compare.Operator.GREATER_THAN,
                            Expression.value(50)))).
            insertInto("StockQuote");
    Assert.assertEquals(api, query);
}
 
开发者ID:sacjaya,项目名称:siddhi-3,代码行数:25,代码来源:SimpleQueryTestCase.java

示例13: test4

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void test4() throws SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  AllStockQuotes#window.lenghtBatch(50)  " +
                    "select symbol, avg(price) as avgPrice " +
                    "return ;"
    );
    Assert.assertNotNull(query);

    Query api = Query.query().from(InputStream.stream("AllStockQuotes").
            window("lenghtBatch", Expression.value(50))).
            select(Selector.selector().
                    select("symbol", Expression.variable("symbol")).
                    select("avgPrice", Expression.function("avg", Expression.variable("price")))).
            returns();
    Assert.assertEquals(api, query);
}
 
开发者ID:sacjaya,项目名称:siddhi-3,代码行数:17,代码来源:SimpleQueryTestCase.java

示例14: Test

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void Test() throws RecognitionException, SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  cseEventStream#transform.avgStream(price) " +
                                            "insert into StockQuote ;"

    );
    Assert.assertNotNull(query);
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:9,代码来源:TransformTestCase.java

示例15: Test1

import org.wso2.siddhi.query.compiler.SiddhiCompiler; //导入依赖的package包/类
@Test
public void Test1() throws RecognitionException, SiddhiParserException {
    Query query = SiddhiCompiler.parseQuery("from  cseEventStream#transform.exthj:avgStream(price) " +
                                            "insert into StockQuote ;"

    );
    Assert.assertNotNull(query);
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:9,代码来源:TransformTestCase.java


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