Search in sources :

Example 21 with TableDefinition

use of io.siddhi.query.api.definition.TableDefinition in project siddhi by wso2.

the class SiddhiApp method checkDuplicateDefinition.

private void checkDuplicateDefinition(AbstractDefinition definition) {
    TableDefinition existingTableDefinition = tableDefinitionMap.get(definition.getId());
    if (existingTableDefinition != null && (!existingTableDefinition.equals(definition) || definition instanceof StreamDefinition)) {
        throw new DuplicateDefinitionException("Table Definition with same Stream Id '" + definition.getId() + "' already exist : " + existingTableDefinition + ", hence cannot add " + definition, definition.getQueryContextStartIndex(), definition.getQueryContextEndIndex());
    }
    StreamDefinition existingStreamDefinition = streamDefinitionMap.get(definition.getId());
    if (existingStreamDefinition != null && (!existingStreamDefinition.equals(definition) || definition instanceof TableDefinition)) {
        throw new DuplicateDefinitionException("Stream Definition with same Stream Id '" + definition.getId() + "' already exist : " + existingStreamDefinition + ", hence cannot add " + definition, definition.getQueryContextStartIndex(), definition.getQueryContextEndIndex());
    }
    WindowDefinition existingWindowDefinition = windowDefinitionMap.get(definition.getId());
    if (existingWindowDefinition != null && (!existingWindowDefinition.equals(definition) || definition instanceof WindowDefinition)) {
        throw new DuplicateDefinitionException("Stream Definition with same Window Id '" + definition.getId() + "' already exist : " + existingWindowDefinition + ", hence cannot add " + definition, definition.getQueryContextStartIndex(), definition.getQueryContextEndIndex());
    }
    AggregationDefinition existingAggregationDefinition = aggregationDefinitionMap.get(definition.getId());
    if (existingAggregationDefinition != null && (!existingAggregationDefinition.equals(definition) || definition instanceof AggregationDefinition)) {
        throw new DuplicateDefinitionException("Aggregate Definition with same Aggregate Id '" + definition.getId() + "' already exist : " + existingAggregationDefinition + ", hence cannot add " + definition, definition.getQueryContextStartIndex(), definition.getQueryContextEndIndex());
    }
}
Also used : StreamDefinition(io.siddhi.query.api.definition.StreamDefinition) DuplicateDefinitionException(io.siddhi.query.api.exception.DuplicateDefinitionException) AggregationDefinition(io.siddhi.query.api.definition.AggregationDefinition) TableDefinition(io.siddhi.query.api.definition.TableDefinition) WindowDefinition(io.siddhi.query.api.definition.WindowDefinition)

Aggregations

TableDefinition (io.siddhi.query.api.definition.TableDefinition)21 Attribute (io.siddhi.query.api.definition.Attribute)11 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)8 Test (org.testng.annotations.Test)7 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)6 Annotation (io.siddhi.query.api.annotation.Annotation)5 Variable (io.siddhi.query.api.expression.Variable)5 OutputAttribute (io.siddhi.query.api.execution.query.selection.OutputAttribute)4 StreamEventCloner (io.siddhi.core.event.stream.StreamEventCloner)3 CompiledUpdateSet (io.siddhi.core.table.CompiledUpdateSet)3 InMemoryTable (io.siddhi.core.table.InMemoryTable)3 OrderByAttribute (io.siddhi.query.api.execution.query.selection.OrderByAttribute)3 SiddhiQueryContext (io.siddhi.core.config.SiddhiQueryContext)2 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)2 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)2 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)2 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)2 Table (io.siddhi.core.table.Table)2 UpdateSet (io.siddhi.query.api.execution.query.output.stream.UpdateSet)2 ArrayList (java.util.ArrayList)2