Search in sources :

Example 1 with StoreQueryRuntimeException

use of org.wso2.siddhi.core.exception.StoreQueryRuntimeException in project siddhi by wso2.

the class SelectStoreQueryRuntime method execute.

public Event[] execute() {
    try {
        StateEvent stateEvent = new StateEvent(1, 0);
        StreamEvent streamEvents = queryableProcessor.query(stateEvent, compiledCondition, compiledSelection);
        if (streamEvents == null) {
            return null;
        } else {
            List<Event> events = new ArrayList<Event>();
            while (streamEvents != null) {
                events.add(new Event(streamEvents.getTimestamp(), streamEvents.getOutputData()));
                streamEvents = streamEvents.getNext();
            }
            return events.toArray(new Event[0]);
        }
    } catch (Throwable t) {
        throw new StoreQueryRuntimeException("Error executing '" + queryName + "', " + t.getMessage(), t);
    }
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) StoreQueryRuntimeException(org.wso2.siddhi.core.exception.StoreQueryRuntimeException) ArrayList(java.util.ArrayList) StateEvent(org.wso2.siddhi.core.event.state.StateEvent) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) Event(org.wso2.siddhi.core.event.Event) StateEvent(org.wso2.siddhi.core.event.state.StateEvent)

Example 2 with StoreQueryRuntimeException

use of org.wso2.siddhi.core.exception.StoreQueryRuntimeException in project siddhi by wso2.

the class FindStoreQueryRuntime method execute.

@Override
public Event[] execute() {
    try {
        StateEvent stateEvent = new StateEvent(1, 0);
        StreamEvent streamEvents = null;
        switch(eventType) {
            case TABLE:
                streamEvents = table.find(stateEvent, compiledCondition);
                break;
            case WINDOW:
                streamEvents = window.find(stateEvent, compiledCondition);
                break;
            case AGGREGATE:
                stateEvent = new StateEvent(2, 0);
                StreamEvent streamEvent = new StreamEvent(0, 2, 0);
                stateEvent.addEvent(0, streamEvent);
                streamEvents = aggregation.find(stateEvent, compiledCondition);
                break;
            case DEFAULT:
                break;
        }
        if (streamEvents == null) {
            return null;
        } else {
            if (selector != null) {
                return executeSelector(streamEvents, eventType);
            } else {
                List<Event> events = new ArrayList<Event>();
                while (streamEvents != null) {
                    events.add(new Event(streamEvents.getTimestamp(), streamEvents.getOutputData()));
                    streamEvents = streamEvents.getNext();
                }
                return events.toArray(new Event[0]);
            }
        }
    } catch (Throwable t) {
        throw new StoreQueryRuntimeException("Error executing '" + queryName + "', " + t.getMessage(), t);
    }
}
Also used : MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) StoreQueryRuntimeException(org.wso2.siddhi.core.exception.StoreQueryRuntimeException) ArrayList(java.util.ArrayList) StateEvent(org.wso2.siddhi.core.event.state.StateEvent) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent) Event(org.wso2.siddhi.core.event.Event) StateEvent(org.wso2.siddhi.core.event.state.StateEvent)

Aggregations

ArrayList (java.util.ArrayList)2 Event (org.wso2.siddhi.core.event.Event)2 StateEvent (org.wso2.siddhi.core.event.state.StateEvent)2 StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)2 StoreQueryRuntimeException (org.wso2.siddhi.core.exception.StoreQueryRuntimeException)2 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)1 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)1