Search in sources :

Example 1 with StoreQueryRuntimeException

use of org.ballerinalang.siddhi.core.exception.StoreQueryRuntimeException in project ballerina by ballerina-lang.

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.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StoreQueryRuntimeException(org.ballerinalang.siddhi.core.exception.StoreQueryRuntimeException) ArrayList(java.util.ArrayList) Event(org.ballerinalang.siddhi.core.event.Event) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) ComplexEvent(org.ballerinalang.siddhi.core.event.ComplexEvent) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StateEvent(org.ballerinalang.siddhi.core.event.state.StateEvent) StateEvent(org.ballerinalang.siddhi.core.event.state.StateEvent)

Example 2 with StoreQueryRuntimeException

use of org.ballerinalang.siddhi.core.exception.StoreQueryRuntimeException in project ballerina by ballerina-lang.

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.ballerinalang.siddhi.core.event.stream.StreamEvent) StoreQueryRuntimeException(org.ballerinalang.siddhi.core.exception.StoreQueryRuntimeException) ArrayList(java.util.ArrayList) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) Event(org.ballerinalang.siddhi.core.event.Event) StateEvent(org.ballerinalang.siddhi.core.event.state.StateEvent) StateEvent(org.ballerinalang.siddhi.core.event.state.StateEvent)

Aggregations

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