Search in sources :

Example 46 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class StoreQueryParser method constructStoreQueryRuntime.

private static StoreQueryRuntime constructStoreQueryRuntime(AggregationRuntime aggregation, StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, Within within, Expression per, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors) {
    int metaPosition;
    metaStreamEvent.setEventType(EventType.AGGREGATE);
    initMetaStreamEvent(metaStreamEvent, aggregation.getAggregationDefinition());
    MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, aggregation.getAggregationDefinition());
    CompiledCondition compiledCondition = aggregation.compileExpression(onCondition, within, per, metaStreamInfoHolder, variableExpressionExecutors, tableMap, queryName, siddhiAppContext);
    metaStreamInfoHolder = ((IncrementalAggregateCompileCondition) compiledCondition).getAlteredMatchingMetaInfoHolder();
    FindStoreQueryRuntime findStoreQueryRuntime = new FindStoreQueryRuntime(aggregation, compiledCondition, queryName, metaStreamEvent);
    metaPosition = 1;
    populateFindStoreQueryRuntime(findStoreQueryRuntime, metaStreamInfoHolder, storeQuery.getSelector(), variableExpressionExecutors, siddhiAppContext, tableMap, queryName, metaPosition);
    ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0), 0, ((IncrementalAggregateCompileCondition) compiledCondition).getAdditionalAttributes());
    ((IncrementalAggregateCompileCondition) compiledCondition).setComplexEventPopulater(complexEventPopulater);
    return findStoreQueryRuntime;
}
Also used : CompiledCondition(org.wso2.siddhi.core.util.collection.operator.CompiledCondition) MatchingMetaInfoHolder(org.wso2.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) IncrementalAggregateCompileCondition(org.wso2.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition) FindStoreQueryRuntime(org.wso2.siddhi.core.query.FindStoreQueryRuntime) ComplexEventPopulater(org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater)

Example 47 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class StoreQueryParser method buildExpectedOutputAttributes.

private static List<Attribute> buildExpectedOutputAttributes(StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, int metaPosition, MatchingMetaInfoHolder metaStreamInfoHolder) {
    MetaStateEvent selectMetaStateEvent = new MetaStateEvent(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvents());
    SelectorParser.parse(storeQuery.getSelector(), new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS), siddhiAppContext, selectMetaStateEvent, tableMap, new ArrayList<>(), queryName, metaPosition);
    return selectMetaStateEvent.getOutputStreamDefinition().getAttributeList();
}
Also used : ReturnStream(org.wso2.siddhi.query.api.execution.query.output.stream.ReturnStream) MetaStateEvent(org.wso2.siddhi.core.event.state.MetaStateEvent)

Example 48 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class DefinitionParserHelper method isMultiClientDistributedTransport.

private static boolean isMultiClientDistributedTransport(Sink clientTransport, StreamDefinition streamDefinition, Annotation distributionAnnotation, SiddhiAppContext siddhiAppContext) {
    // fetch the @distribution annotations from the @sink annotation
    List<OptionHolder> destinationOptHolders = createDestinationOptionHolders(distributionAnnotation, streamDefinition, clientTransport, siddhiAppContext);
    List<String> dynamicOptions = Arrays.asList(clientTransport.getSupportedDynamicOptions());
    // If at least one of the @destination contains a static option then multi client transport should be used
    for (OptionHolder optionHolder : destinationOptHolders) {
        for (String key : optionHolder.getDynamicOptionsKeys()) {
            if (!dynamicOptions.contains(key)) {
                return true;
            }
        }
        for (String key : optionHolder.getStaticOptionsKeys()) {
            if (!dynamicOptions.contains(key)) {
                return true;
            }
        }
    }
    return false;
}
Also used : OptionHolder(org.wso2.siddhi.core.util.transport.OptionHolder)

Example 49 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class DefinitionParserHelper method addStreamJunction.

public static void addStreamJunction(StreamDefinition streamDefinition, ConcurrentMap<String, StreamJunction> streamJunctionMap, SiddhiAppContext siddhiAppContext) {
    if (!streamJunctionMap.containsKey(streamDefinition.getId())) {
        StreamJunction streamJunction = new StreamJunction(streamDefinition, siddhiAppContext.getExecutorService(), siddhiAppContext.getBufferSize(), siddhiAppContext);
        streamJunctionMap.putIfAbsent(streamDefinition.getId(), streamJunction);
    }
}
Also used : StreamJunction(org.wso2.siddhi.core.stream.StreamJunction)

Example 50 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class DefinitionParserHelper method addEventTrigger.

public static void addEventTrigger(TriggerDefinition triggerDefinition, ConcurrentMap<String, Trigger> eventTriggerMap, ConcurrentMap<String, StreamJunction> streamJunctionMap, SiddhiAppContext siddhiAppContext) {
    if (!eventTriggerMap.containsKey(triggerDefinition.getId())) {
        Trigger trigger;
        if (triggerDefinition.getAtEvery() != null) {
            trigger = new PeriodicTrigger();
        } else if (triggerDefinition.getAt().trim().equalsIgnoreCase(SiddhiConstants.TRIGGER_START)) {
            trigger = new StartTrigger();
        } else {
            trigger = new CronTrigger();
        }
        StreamJunction streamJunction = streamJunctionMap.get(triggerDefinition.getId());
        trigger.init(triggerDefinition, siddhiAppContext, streamJunction);
        siddhiAppContext.addEternalReferencedHolder(trigger);
        eventTriggerMap.putIfAbsent(trigger.getId(), trigger);
    }
}
Also used : CronTrigger(org.wso2.siddhi.core.trigger.CronTrigger) StartTrigger(org.wso2.siddhi.core.trigger.StartTrigger) Trigger(org.wso2.siddhi.core.trigger.Trigger) CronTrigger(org.wso2.siddhi.core.trigger.CronTrigger) PeriodicTrigger(org.wso2.siddhi.core.trigger.PeriodicTrigger) StreamJunction(org.wso2.siddhi.core.stream.StreamJunction) StartTrigger(org.wso2.siddhi.core.trigger.StartTrigger) PeriodicTrigger(org.wso2.siddhi.core.trigger.PeriodicTrigger)

Aggregations

VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)30 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)28 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)24 ArrayList (java.util.ArrayList)22 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)20 Attribute (org.wso2.siddhi.query.api.definition.Attribute)18 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)17 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)17 SiddhiAppValidationException (org.wso2.siddhi.query.api.exception.SiddhiAppValidationException)13 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)12 AbstractDefinition (org.wso2.siddhi.query.api.definition.AbstractDefinition)12 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)12 HashMap (java.util.HashMap)11 StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)11 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)11 Expression (org.wso2.siddhi.query.api.expression.Expression)11 Table (org.wso2.siddhi.core.table.Table)10 Variable (org.wso2.siddhi.query.api.expression.Variable)10 QueryRuntime (org.wso2.siddhi.core.query.QueryRuntime)8 StreamJunction (org.wso2.siddhi.core.stream.StreamJunction)8