本文整理汇总了Java中org.wso2.siddhi.query.api.annotation.Annotation类的典型用法代码示例。如果您正苦于以下问题:Java Annotation类的具体用法?Java Annotation怎么用?Java Annotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Annotation类属于org.wso2.siddhi.query.api.annotation包,在下文中一共展示了Annotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitPartition
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Partition visitPartition(@NotNull SiddhiQLParser.PartitionContext ctx) {
Partition partition = Partition.partition();
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
partition.annotation((Annotation) visit(annotationContext));
}
for (SiddhiQLParser.Partition_with_streamContext with_streamContext : ctx.partition_with_stream()) {
partition.with((PartitionType) visit(with_streamContext));
}
for (SiddhiQLParser.QueryContext queryContext : ctx.query()) {
partition.addQuery((Query) visit(queryContext));
}
populateQueryContext(partition, ctx);
return partition;
}
示例2: testFilterQuery48
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testFilterQuery48() throws InterruptedException {
log.info("Filter test48");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type
.STRING).attribute("price", Attribute.Type.FLOAT).attribute("available", Attribute.Type.BOOL);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").
filter(Expression.not(Expression.variable("price"))));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(
Selector.selector().
select("symbol", Expression.variable("symbol")).
select("price", Expression.variable("price")).
select("available", Expression.variable("available"))
);
query.insertInto("StockQuote");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
}
示例3: testFilterQuery49
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Test(expectedExceptions = SiddhiAppCreationException.class)
public void testFilterQuery49() throws InterruptedException {
log.info("Filter test49");
SiddhiManager siddhiManager = new SiddhiManager();
StreamDefinition cseEventStream = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type
.STRING).attribute("price", Attribute.Type.FLOAT).attribute("available", Attribute.Type.BOOL);
Query query = new Query();
query.from(InputStream.stream("cseEventStream").
filter(Expression.variable("price")));
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.select(
Selector.selector().
select("symbol", Expression.variable("symbol")).
select("price", Expression.variable("price")).
select("available", Expression.variable("available"))
);
query.insertInto("StockQuote");
SiddhiApp siddhiApp = new SiddhiApp("ep1");
siddhiApp.defineStream(cseEventStream);
siddhiApp.addQuery(query);
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(siddhiApp);
}
示例4: testFilterQuery10
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Test
public void testFilterQuery10() throws InterruptedException, ValidatorException {
log.info("Filter test10");
SiddhiManager siddhiManager = new SiddhiManager();
ExecutionPlan executionPlan = new ExecutionPlan("plan1");
StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
executionPlan.defineStream(streamDefinition);
Query query = new Query();
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.NOT_EQUAL, Expression.value(50))));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")));
query.insertInto("outputStream");
streamDefinitionMap.put("cseEventStream", streamDefinition);
//StreamValidator.validate(streamDefinitionMap, streamDefinition);
// QueryValidator.validate(query, streamDefinitionMap);
executionPlan.addQuery(query);
ExecutionPlanRuntime executionPlanRuntime = siddhiManager.addExecutionPlan(executionPlan);
executionPlanRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
count++;
}
});
InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
inputHandler.send(new Object[]{"WSO2", 40f, 50});
inputHandler.send(new Object[]{"WSO2", 20f, 100});
Thread.sleep(100);
Assert.assertEquals(1, count);
siddhiManager.shutdown();
}
示例5: visitDefinition_stream
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public StreamDefinition visitDefinition_stream(@NotNull SiddhiQLParser.Definition_streamContext ctx) {
Source source = (Source) visit(ctx.source());
if (source.isInnerStream) {
throw newSiddhiParserException(ctx, " InnerStreams cannot be defined!");
}
try {
StreamDefinition streamDefinition = StreamDefinition.id(source.streamId);
populateQueryContext(streamDefinition, ctx);
List<SiddhiQLParser.Attribute_nameContext> attribute_names = ctx.attribute_name();
List<SiddhiQLParser.Attribute_typeContext> attribute_types = ctx.attribute_type();
for (int i = 0; i < attribute_names.size(); i++) {
SiddhiQLParser.Attribute_nameContext attributeNameContext = attribute_names.get(i);
SiddhiQLParser.Attribute_typeContext attributeTypeContext = attribute_types.get(i);
streamDefinition.attribute((String) visit(attributeNameContext), (Attribute.Type) visit
(attributeTypeContext));
}
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
streamDefinition.annotation((Annotation) visit(annotationContext));
}
return streamDefinition;
} catch (Throwable t) {
throw newSiddhiParserException(ctx, t.getMessage(), t);
}
}
示例6: visitDefinition_table
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public TableDefinition visitDefinition_table(@NotNull SiddhiQLParser.Definition_tableContext ctx) {
// definition_table
// : annotation* DEFINE TABLE source '(' attribute_name attribute_type (',' attribute_name attribute_type )*
// ')' definition_store?
// ;
Source source = (Source) visit(ctx.source());
if (source.isInnerStream) {
throw newSiddhiParserException(ctx, "'#' cannot be used, because Tables can't be defined as " +
"InnerStream!");
}
TableDefinition tableDefinition = TableDefinition.id(source.streamId);
List<SiddhiQLParser.Attribute_nameContext> attribute_names = ctx.attribute_name();
List<SiddhiQLParser.Attribute_typeContext> attribute_types = ctx.attribute_type();
for (int i = 0; i < attribute_names.size(); i++) {
SiddhiQLParser.Attribute_nameContext attributeNameContext = attribute_names.get(i);
SiddhiQLParser.Attribute_typeContext attributeTypeContext = attribute_types.get(i);
tableDefinition.attribute((String) visit(attributeNameContext), (Attribute.Type) visit
(attributeTypeContext));
}
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
tableDefinition.annotation((Annotation) visit(annotationContext));
}
populateQueryContext(tableDefinition, ctx);
return tableDefinition;
}
示例7: visitDefinition_window
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Override
public Object visitDefinition_window(@NotNull SiddhiQLParser.Definition_windowContext ctx) {
Source source = (Source) visit(ctx.source());
if (source.isInnerStream) {
throw newSiddhiParserException(ctx, "'#' cannot be used, because Windows can't be defined as InnerStream!");
}
WindowDefinition windowDefinition = WindowDefinition.id(source.streamId);
List<SiddhiQLParser.Attribute_nameContext> attribute_names = ctx.attribute_name();
List<SiddhiQLParser.Attribute_typeContext> attribute_types = ctx.attribute_type();
for (int i = 0; i < attribute_names.size(); i++) {
SiddhiQLParser.Attribute_nameContext attributeNameContext = attribute_names.get(i);
SiddhiQLParser.Attribute_typeContext attributeTypeContext = attribute_types.get(i);
windowDefinition.attribute((String) visit(attributeNameContext), (Attribute.Type) visit
(attributeTypeContext));
}
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
windowDefinition.annotation((Annotation) visit(annotationContext));
}
AttributeFunction attributeFunction = (AttributeFunction) visit(ctx.function_operation());
Window window = new Window(attributeFunction.getNamespace(), attributeFunction.getName(), attributeFunction
.getParameters());
windowDefinition.window(window);
// Optional output event type
if (ctx.output_event_type() != null) {
windowDefinition.setOutputEventType((OutputStream.OutputEventType) visit(ctx.output_event_type()));
}
populateQueryContext(windowDefinition, ctx);
return windowDefinition;
}
示例8: visitQuery
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Query visitQuery(@NotNull SiddhiQLParser.QueryContext ctx) {
// query
// : annotation* query_input query_section? output_rate? (query_output | query_publish)
// ;
try {
Query query = Query.query().from((InputStream) visit(ctx.query_input()));
if (ctx.query_section() != null) {
query.select((Selector) visit(ctx.query_section()));
}
if (ctx.output_rate() != null) {
query.output((OutputRate) visit(ctx.output_rate()));
}
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
query.annotation((Annotation) visit(annotationContext));
}
if (ctx.query_output() != null) {
query.outStream((OutputStream) visit(ctx.query_output()));
}
populateQueryContext(query, ctx);
return query;
} finally {
activeStreams.clear();
}
}
示例9: visitApp_annotation
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Annotation visitApp_annotation(@NotNull SiddhiQLParser.App_annotationContext ctx) {
Annotation annotation = new Annotation((String) visit(ctx.name()));
for (SiddhiQLParser.Annotation_elementContext elementContext : ctx.annotation_element()) {
annotation.element((Element) visit(elementContext));
}
populateQueryContext(annotation, ctx);
return annotation;
}
示例10: visitAnnotation
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Annotation visitAnnotation(@NotNull SiddhiQLParser.AnnotationContext ctx) {
Annotation annotation = Annotation.annotation((String) visit(ctx.name()));
for (SiddhiQLParser.Annotation_elementContext elementContext : ctx.annotation_element()) {
annotation.element((Element) visit(elementContext));
}
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
annotation.annotation((Annotation) visit(annotationContext));
}
populateQueryContext(annotation, ctx);
return annotation;
}
示例11: visitDefinition_aggregation
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Override
public AggregationDefinition visitDefinition_aggregation(
@NotNull SiddhiQLParser.Definition_aggregationContext ctx) {
// Read the name of the aggregation
String aggregationName = (String) visitAggregation_name(ctx.aggregation_name());
// Create the aggregation using the extracted aggregation name
AggregationDefinition aggregationDefinition = AggregationDefinition.id(aggregationName);
// Get all annotation and populate the aggregation
for (SiddhiQLParser.AnnotationContext annotationContext : ctx.annotation()) {
aggregationDefinition.annotation((Annotation) visit(annotationContext));
}
// Attach the input stream
BasicSingleInputStream basicSingleInputStream = (BasicSingleInputStream) visit(ctx.standard_stream());
aggregationDefinition.from(basicSingleInputStream);
// Extract the selector and attach it to the new aggregation
BasicSelector selector = (BasicSelector) visit(ctx.group_by_query_selection());
aggregationDefinition.select(selector);
// Get the variable (if available) and aggregate on that variable
if (ctx.attribute_reference() != null) {
Variable aggregatedBy = (Variable) visit(ctx.attribute_reference());
aggregationDefinition.aggregateBy(aggregatedBy);
}
// Extract the specified time-durations and attache it to the aggregation definition
TimePeriod timePeriod = (TimePeriod) visit(ctx.aggregation_time());
aggregationDefinition.every(timePeriod);
populateQueryContext(aggregationDefinition, ctx);
return aggregationDefinition;
}
示例12: test4
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Test
public void test4() throws SiddhiParserException {
TableDefinition streamDefinition = SiddhiCompiler.parseTableDefinition("" +
" @from(datasource='MyDatabase','CUSTOM')" +
" define table cseStream ( symbol string, price int, volume float )");
AssertJUnit.assertEquals(TableDefinition.
id("cseStream").
attribute("symbol", Attribute.Type.STRING).
attribute("price", Attribute.Type.INT).
attribute("volume", Attribute.Type.FLOAT).annotation(Annotation.annotation("from").element
("datasource", "MyDatabase").element("CUSTOM")).toString(),
streamDefinition.toString());
}
示例13: testEqualObjects
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Test
public void testEqualObjects() throws SiddhiParserException {
StreamDefinition streamDefinition = SiddhiCompiler.parseStreamDefinition("@Foo(name='bar','Custom')define " +
"stream cseStream ( symbol string, price int, volume float )");
AssertJUnit.assertEquals(StreamDefinition.
id("cseStream").
attribute("symbol", Attribute.Type.STRING).
attribute("price", Attribute.Type.INT).
attribute("volume", Attribute.Type.FLOAT).annotation(Annotation.annotation("Foo").element
("name", "bar").element("Custom")),
streamDefinition);
}
示例14: testQueryParser
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Test
public void testQueryParser() {
StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT);
StreamDefinition outStreamDefinition = StreamDefinition.id("outputStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT);
Query query = new Query();
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("volume"), Compare.Operator.NOT_EQUAL, Expression.value(50))));
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")));
query.insertInto("outputStream");
Map<String, AbstractDefinition> definitionMap = new HashMap<String, AbstractDefinition>();
definitionMap.put("cseEventStream", streamDefinition);
definitionMap.put("outputStream", outStreamDefinition);
SiddhiContext context = new SiddhiContext();
QueryRuntime runtime = QueryParser.parse(query, context, definitionMap);
}
示例15: testFilterQuery13
import org.wso2.siddhi.query.api.annotation.Annotation; //导入依赖的package包/类
@Test
public void testFilterQuery13() throws InterruptedException, ValidatorException {
log.info("Filter test13");
SiddhiManager siddhiManager = new SiddhiManager();
ExecutionPlan executionPlan = new ExecutionPlan("plan1");
StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.FLOAT).attribute("volume", Attribute.Type.INT).attribute("validity", Attribute.Type.BOOL);
executionPlan.defineStream(streamDefinition);
Query query = new Query();
query.annotation(Annotation.annotation("info").element("name", "query1"));
query.from(InputStream.stream("cseEventStream").filter(Expression.compare(Expression.variable("validity"), Compare.Operator.EQUAL, Expression.value(true))));
query.insertInto("outputStream");
query.select(Selector.selector().select("symbol", Expression.variable("symbol")).select("price", Expression.variable("price")).select("volume", Expression.variable("volume")));
streamDefinitionMap.put("cseEventStream", streamDefinition);
//StreamValidator.validate(streamDefinitionMap, streamDefinition);
// QueryValidator.validate(query, streamDefinitionMap);
executionPlan.addQuery(query);
ExecutionPlanRuntime executionPlanRuntime = siddhiManager.addExecutionPlan(executionPlan);
executionPlanRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
count++;
}
});
InputHandler inputHandler = executionPlanRuntime.getInputHandler("cseEventStream");
inputHandler.send(new Object[]{"WSO2", 50d, 50, true});
inputHandler.send(new Object[]{"IBM", 55d, 100, false});
Thread.sleep(100);
Assert.assertEquals(1, count);
siddhiManager.shutdown();
}