Search in sources :

Example 46 with ComplexEventChunk

use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.

the class IncrementalAggregateCompileCondition method createAggregateSelectionEventChunk.

private ComplexEventChunk<StreamEvent> createAggregateSelectionEventChunk(ComplexEventChunk<StreamEvent> complexEventChunkToHoldMatches, List<ExpressionExecutor> outputExpressionExecutors) {
    ComplexEventChunk<StreamEvent> aggregateSelectionComplexEventChunk = new ComplexEventChunk<>(true);
    StreamEvent resetEvent = streamEventPoolForTableMeta.borrowEvent();
    resetEvent.setType(ComplexEvent.Type.RESET);
    while (complexEventChunkToHoldMatches.hasNext()) {
        StreamEvent streamEvent = complexEventChunkToHoldMatches.next();
        StreamEvent newStreamEvent = streamEventPoolForAggregateMeta.borrowEvent();
        Object[] outputData = new Object[newStreamEvent.getOutputData().length];
        for (int i = 0; i < outputExpressionExecutors.size(); i++) {
            outputData[i] = outputExpressionExecutors.get(i).execute(streamEvent);
        }
        newStreamEvent.setTimestamp(streamEvent.getTimestamp());
        newStreamEvent.setOutputData(outputData);
        aggregateSelectionComplexEventChunk.add(newStreamEvent);
    }
    for (ExpressionExecutor expressionExecutor : outputExpressionExecutors) {
        expressionExecutor.execute(resetEvent);
    }
    return aggregateSelectionComplexEventChunk;
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 47 with ComplexEventChunk

use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.

the class IndexOperator method update.

@Override
public void update(ComplexEventChunk<StateEvent> updatingEventChunk, Object storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet) {
    updatingEventChunk.reset();
    while (updatingEventChunk.hasNext()) {
        StateEvent updatingEvent = updatingEventChunk.next();
        StreamEvent streamEvents = collectionExecutor.find(updatingEvent, (IndexedEventHolder) storeEvents, null);
        if (streamEvents != null) {
            ComplexEventChunk<StreamEvent> foundEventChunk = new ComplexEventChunk<>(false);
            foundEventChunk.add(streamEvents);
            update((IndexedEventHolder) storeEvents, compiledUpdateSet, updatingEvent, foundEventChunk);
        }
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) StateEvent(org.wso2.siddhi.core.event.state.StateEvent)

Example 48 with ComplexEventChunk

use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.

the class IndexOperator method delete.

@Override
public void delete(ComplexEventChunk<StateEvent> deletingEventChunk, Object storeEvents) {
    deletingEventChunk.reset();
    while (deletingEventChunk.hasNext()) {
        StateEvent deletingEvent = deletingEventChunk.next();
        collectionExecutor.delete(deletingEvent, (IndexedEventHolder) storeEvents);
    }
}
Also used : StateEvent(org.wso2.siddhi.core.event.state.StateEvent)

Example 49 with ComplexEventChunk

use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.

the class AnyAndCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    Collection<StreamEvent> resultEventSet = findEvents(matchingEvent, indexedEventHolder);
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    if (resultEventSet != null) {
        for (StreamEvent resultEvent : resultEventSet) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(resultEvent));
            } else {
                returnEventChunk.add(resultEvent);
            }
        }
        return returnEventChunk.getFirst();
    } else {
        return exhaustiveCollectionExecutor.find(matchingEvent, indexedEventHolder, storeEventCloner);
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 50 with ComplexEventChunk

use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.

the class ExhaustiveCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
    for (StreamEvent storeEvent : storeEvents) {
        matchingEvent.setEvent(storeEventIndex, storeEvent);
        if ((Boolean) expressionExecutor.execute(matchingEvent)) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        matchingEvent.setEvent(storeEventIndex, null);
    }
    return returnEventChunk.getFirst();
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Aggregations

StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)72 ComplexEventChunk (org.wso2.siddhi.core.event.ComplexEventChunk)69 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)44 ArrayList (java.util.ArrayList)30 StateEvent (org.wso2.siddhi.core.event.state.StateEvent)26 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)19 GroupedComplexEvent (org.wso2.siddhi.core.event.GroupedComplexEvent)17 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)13 Map (java.util.Map)12 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)8 HashMap (java.util.HashMap)6 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)5 AttributeProcessor (org.wso2.siddhi.core.query.selector.attribute.processor.AttributeProcessor)4 SiddhiAppValidationException (org.wso2.siddhi.query.api.exception.SiddhiAppValidationException)4 Collection (java.util.Collection)3 Event (org.wso2.siddhi.core.event.Event)3 SiddhiAppRuntimeException (org.wso2.siddhi.core.exception.SiddhiAppRuntimeException)3 Table (org.wso2.siddhi.core.table.Table)3 Iterator (java.util.Iterator)2 StreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)2