use of io.siddhi.core.exception.OnDemandQueryRuntimeException in project siddhi by wso2.
the class FindOnDemandQueryRuntime 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);
streamEvents = aggregation.find(stateEvent, compiledCondition, siddhiQueryContext);
break;
case DEFAULT:
break;
}
if (streamEvents == null) {
return null;
} else {
if (selector != null) {
if (eventType == MetaStreamEvent.EventType.AGGREGATE) {
return executeSelector(stateEventFactory, null, streamEvents, 1, selector);
} else {
return executeSelector(stateEventFactory, null, streamEvents, 0, selector);
}
} 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 OnDemandQueryRuntimeException("Error executing '" + queryName + "', " + t.getMessage(), t);
}
}
use of io.siddhi.core.exception.OnDemandQueryRuntimeException in project siddhi by wso2.
the class SelectOnDemandQueryRuntime method execute.
public Event[] execute() {
try {
StateEvent stateEvent = new StateEvent(1, 0);
StreamEvent streamEvents = queryableProcessor.query(stateEvent, compiledCondition, compiledSelection, outputAttributes);
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 OnDemandQueryRuntimeException("Error executing '" + queryName + "', " + t.getMessage(), t);
}
}
use of io.siddhi.core.exception.OnDemandQueryRuntimeException in project siddhi by wso2.
the class OnDemandQueryRuntime method execute.
/**
* This method initiates the execution of on-demand Query.
*
* @return an array of Events.
*/
public Event[] execute() {
try {
StateEvent stateEvent = new StateEvent(1, outputAttributes.length);
StreamEvent streamEvent = new StreamEvent(metaStreamEvent.getBeforeWindowData().size(), metaStreamEvent.getOnAfterWindowData().size(), metaStreamEvent.getOutputData().size());
stateEvent.addEvent(0, streamEvent);
ComplexEventChunk complexEventChunk = new ComplexEventChunk(stateEvent, stateEvent);
if (eventType == MetaStreamEvent.EventType.TABLE) {
selector.process(complexEventChunk);
} else {
throw new OnDemandQueryRuntimeException("DELETE, INSERT, UPDATE and UPDATE OR INSERT on-demand Query " + "operations consume only stream events of type \"TABLE\".");
}
return new Event[] {};
} catch (Throwable t) {
throw new OnDemandQueryRuntimeException("Error executing '" + queryName + "', " + t.getMessage(), t);
}
}
Aggregations