Java Code Examples for io.siddhi.query.api.definition.StreamDefinition#id()
The following examples show how to use
io.siddhi.query.api.definition.StreamDefinition#id() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SiddhiStreamSchema.java From flink-siddhi with Apache License 2.0 | 5 votes |
public StreamDefinition getStreamDefinition(String streamId) { StreamDefinition streamDefinition = StreamDefinition.id(streamId); for (int i = 0; i < getFieldNames().length; i++) { streamDefinition.attribute(getFieldNames()[i], SiddhiTypeFactory.getAttributeType(getFieldTypes()[i])); } return streamDefinition; }
Example 2
Source File: SiddhiQLBaseVisitorImpl.java From siddhi with Apache License 2.0 | 5 votes |
/** * {@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!"); } if (source.isFaultStream) { throw newSiddhiParserException(ctx, " FaultStreams cannot be explicitly 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); } }
Example 3
Source File: DefineStreamTestCase.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testStreamDefinition6() { StreamDefinition streamDefinition = StreamDefinition.id("Foo"); streamDefinition.setId("StockStream"); streamDefinition.attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT); StreamDefinition streamDefinition2 = StreamDefinition.id("StockStream").attribute("symbol", Attribute.Type .STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT); Assert.assertEquals(streamDefinition, streamDefinition2); Assert.assertEquals(streamDefinition.hashCode(), streamDefinition2.hashCode()); streamDefinition.annotation(Annotation.annotation("Foo")); Assert.assertTrue(streamDefinition.equalsIgnoreAnnotations(streamDefinition2)); Assert.assertFalse(streamDefinition.equals(streamDefinition2)); }
Example 4
Source File: DefineStreamTestCase.java From siddhi with Apache License 2.0 | 4 votes |
@Test(expectedExceptions = SiddhiAppValidationException.class) public void testStreamIdNull() { StreamDefinition streamDefinition = StreamDefinition.id(null); SiddhiApp.siddhiApp("Test").defineStream(streamDefinition); }