use of io.siddhi.core.exception.OperationNotSupportedException in project siddhi by wso2.
the class IndexEventHolder method findEvents.
@Override
public Collection<StreamEvent> findEvents(String attribute, Compare.Operator operator, Object value) {
if (primaryKeyData != null && attribute.equals(primaryKeyAttributes)) {
StreamEvent resultEvent;
HashSet<StreamEvent> resultEventSet;
switch(operator) {
case LESS_THAN:
return ((TreeMap<Object, StreamEvent>) primaryKeyData).headMap(value, false).values();
case GREATER_THAN:
return ((TreeMap<Object, StreamEvent>) primaryKeyData).tailMap(value, false).values();
case LESS_THAN_EQUAL:
return ((TreeMap<Object, StreamEvent>) primaryKeyData).headMap(value, true).values();
case GREATER_THAN_EQUAL:
return ((TreeMap<Object, StreamEvent>) primaryKeyData).tailMap(value, true).values();
case EQUAL:
resultEventSet = new HashSet<StreamEvent>();
resultEvent = primaryKeyData.get(value);
if (resultEvent != null) {
resultEventSet.add(resultEvent);
}
return resultEventSet;
case NOT_EQUAL:
if (primaryKeyData.size() > 0) {
resultEventSet = new HashSet<StreamEvent>(primaryKeyData.values());
} else {
return new HashSet<StreamEvent>();
}
resultEvent = primaryKeyData.get(value);
if (resultEvent != null) {
resultEventSet.remove(resultEvent);
}
return resultEventSet;
}
} else {
HashSet<StreamEvent> resultEventSet = new HashSet<StreamEvent>();
TreeMap<Object, Set<StreamEvent>> currentIndexedData = indexData.get(attribute);
Set<StreamEvent> resultEvents;
switch(operator) {
case LESS_THAN:
for (Set<StreamEvent> eventSet : currentIndexedData.headMap(value, false).values()) {
resultEventSet.addAll(eventSet);
}
return resultEventSet;
case GREATER_THAN:
for (Set<StreamEvent> eventSet : currentIndexedData.tailMap(value, false).values()) {
resultEventSet.addAll(eventSet);
}
return resultEventSet;
case LESS_THAN_EQUAL:
for (Set<StreamEvent> eventSet : currentIndexedData.headMap(value, true).values()) {
resultEventSet.addAll(eventSet);
}
return resultEventSet;
case GREATER_THAN_EQUAL:
for (Set<StreamEvent> eventSet : currentIndexedData.tailMap(value, true).values()) {
resultEventSet.addAll(eventSet);
}
return resultEventSet;
case EQUAL:
resultEvents = currentIndexedData.get(value);
if (resultEvents != null) {
resultEventSet.addAll(resultEvents);
}
return resultEventSet;
case NOT_EQUAL:
if (currentIndexedData.size() > 0) {
resultEventSet = new HashSet<StreamEvent>();
for (Set<StreamEvent> eventSet : currentIndexedData.values()) {
resultEventSet.addAll(eventSet);
}
} else {
resultEventSet = new HashSet<StreamEvent>();
}
resultEvents = currentIndexedData.get(value);
if (resultEvents != null) {
resultEventSet.removeAll(resultEvents);
}
return resultEventSet;
}
}
throw new OperationNotSupportedException(operator + " not supported for '" + value + "' by " + getClass().getName());
}
use of io.siddhi.core.exception.OperationNotSupportedException in project siddhi by wso2.
the class StateInputStreamParser method parse.
private static InnerStateRuntime parse(StateElement stateElement, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, MetaStateEvent metaStateEvent, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, ProcessStreamReceiver> processStreamReceiverMap, StreamPreStateProcessor streamPreStateProcessor, StreamPostStateProcessor streamPostStateProcessor, StateInputStream.Type stateType, boolean multiValue, List<PreStateProcessor> preStateProcessors, boolean isStartState, List<PreStateProcessor> startupPreStateProcessors, SiddhiQueryContext siddhiQueryContext) {
if (stateElement instanceof StreamStateElement) {
BasicSingleInputStream basicSingleInputStream = ((StreamStateElement) stateElement).getBasicSingleInputStream();
SingleStreamRuntime singleStreamRuntime = SingleInputStreamParser.parseInputStream(basicSingleInputStream, variableExpressionExecutors, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, processStreamReceiverMap.get(basicSingleInputStream.getUniqueStreamIds().get(0)), false, false, false, multiValue, siddhiQueryContext);
int stateIndex = metaStateEvent.getStreamEventCount() - 1;
if (streamPreStateProcessor == null) {
if (stateElement instanceof AbsentStreamStateElement) {
AbsentStreamPreStateProcessor absentProcessor = new AbsentStreamPreStateProcessor(stateType, ((AbsentStreamStateElement) stateElement).getWaitingTime().value());
// Set the scheduler
startupPreStateProcessors.add(absentProcessor);
EntryValveProcessor entryValveProcessor = new EntryValveProcessor(siddhiQueryContext.getSiddhiAppContext());
entryValveProcessor.setToLast(absentProcessor);
Scheduler scheduler = SchedulerParser.parse(entryValveProcessor, siddhiQueryContext);
absentProcessor.setScheduler(scheduler);
// Assign the AbsentStreamPreStateProcessor to streamPreStateProcessor
streamPreStateProcessor = absentProcessor;
} else {
streamPreStateProcessor = new StreamPreStateProcessor(stateType);
}
streamPreStateProcessor.init(siddhiQueryContext);
}
streamPreStateProcessor.setStateId(stateIndex);
streamPreStateProcessor.setStartState(isStartState);
streamPreStateProcessor.setNextProcessor(singleStreamRuntime.getProcessorChain());
singleStreamRuntime.setProcessorChain(streamPreStateProcessor);
if (streamPostStateProcessor == null) {
if (stateElement instanceof AbsentStreamStateElement) {
streamPostStateProcessor = new AbsentStreamPostStateProcessor();
} else {
streamPostStateProcessor = new StreamPostStateProcessor();
}
}
streamPostStateProcessor.setStateId(stateIndex);
singleStreamRuntime.getProcessorChain().setToLast(streamPostStateProcessor);
streamPostStateProcessor.setThisStatePreProcessor(streamPreStateProcessor);
streamPreStateProcessor.setThisStatePostProcessor(streamPostStateProcessor);
streamPreStateProcessor.setThisLastProcessor(streamPostStateProcessor);
StreamInnerStateRuntime innerStateRuntime = new StreamInnerStateRuntime(stateType);
innerStateRuntime.setFirstProcessor(streamPreStateProcessor);
innerStateRuntime.setLastProcessor(streamPostStateProcessor);
innerStateRuntime.addStreamRuntime(singleStreamRuntime);
preStateProcessors.add(streamPreStateProcessor);
return innerStateRuntime;
} else if (stateElement instanceof NextStateElement) {
StateElement currentElement = ((NextStateElement) stateElement).getStateElement();
InnerStateRuntime currentInnerStateRuntime = parse(currentElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, variableExpressionExecutors, processStreamReceiverMap, streamPreStateProcessor, streamPostStateProcessor, stateType, multiValue, preStateProcessors, isStartState, startupPreStateProcessors, siddhiQueryContext);
StateElement nextElement = ((NextStateElement) stateElement).getNextStateElement();
InnerStateRuntime nextInnerStateRuntime = parse(nextElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, variableExpressionExecutors, processStreamReceiverMap, streamPreStateProcessor, streamPostStateProcessor, stateType, multiValue, preStateProcessors, false, startupPreStateProcessors, siddhiQueryContext);
currentInnerStateRuntime.getLastProcessor().setNextStatePreProcessor(nextInnerStateRuntime.getFirstProcessor());
NextInnerStateRuntime nextStateRuntime = new NextInnerStateRuntime(currentInnerStateRuntime, nextInnerStateRuntime, stateType);
nextStateRuntime.setFirstProcessor(currentInnerStateRuntime.getFirstProcessor());
nextStateRuntime.setLastProcessor(nextInnerStateRuntime.getLastProcessor());
for (SingleStreamRuntime singleStreamRuntime : currentInnerStateRuntime.getSingleStreamRuntimeList()) {
nextStateRuntime.addStreamRuntime(singleStreamRuntime);
}
for (SingleStreamRuntime singleStreamRuntime : nextInnerStateRuntime.getSingleStreamRuntimeList()) {
nextStateRuntime.addStreamRuntime(singleStreamRuntime);
}
return nextStateRuntime;
} else if (stateElement instanceof EveryStateElement) {
StateElement currentElement = ((EveryStateElement) stateElement).getStateElement();
List<PreStateProcessor> withinEveryPreStateProcessors = new ArrayList<>();
InnerStateRuntime innerStateRuntime = parse(currentElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, variableExpressionExecutors, processStreamReceiverMap, streamPreStateProcessor, streamPostStateProcessor, stateType, multiValue, withinEveryPreStateProcessors, isStartState, startupPreStateProcessors, siddhiQueryContext);
EveryInnerStateRuntime everyInnerStateRuntime = new EveryInnerStateRuntime(innerStateRuntime, stateType);
everyInnerStateRuntime.setFirstProcessor(innerStateRuntime.getFirstProcessor());
everyInnerStateRuntime.setLastProcessor(innerStateRuntime.getLastProcessor());
for (SingleStreamRuntime singleStreamRuntime : innerStateRuntime.getSingleStreamRuntimeList()) {
everyInnerStateRuntime.addStreamRuntime(singleStreamRuntime);
}
everyInnerStateRuntime.getLastProcessor().setNextEveryStatePreProcessor(everyInnerStateRuntime.getFirstProcessor());
for (PreStateProcessor preStateProcessor : withinEveryPreStateProcessors) {
preStateProcessor.setWithinEveryPreStateProcessor(everyInnerStateRuntime.getFirstProcessor());
}
preStateProcessors.addAll(withinEveryPreStateProcessors);
return everyInnerStateRuntime;
} else if (stateElement instanceof LogicalStateElement) {
LogicalStateElement.Type type = ((LogicalStateElement) stateElement).getType();
LogicalPreStateProcessor logicalPreStateProcessor1;
if (((LogicalStateElement) stateElement).getStreamStateElement1() instanceof AbsentStreamStateElement) {
logicalPreStateProcessor1 = new AbsentLogicalPreStateProcessor(type, stateType, ((AbsentStreamStateElement) ((LogicalStateElement) stateElement).getStreamStateElement1()).getWaitingTime());
// Set the scheduler
startupPreStateProcessors.add(logicalPreStateProcessor1);
EntryValveProcessor entryValveProcessor = new EntryValveProcessor(siddhiQueryContext.getSiddhiAppContext());
entryValveProcessor.setToLast(logicalPreStateProcessor1);
Scheduler scheduler = SchedulerParser.parse(entryValveProcessor, siddhiQueryContext);
((SchedulingProcessor) logicalPreStateProcessor1).setScheduler(scheduler);
} else {
logicalPreStateProcessor1 = new LogicalPreStateProcessor(type, stateType);
}
logicalPreStateProcessor1.init(siddhiQueryContext);
LogicalPostStateProcessor logicalPostStateProcessor1;
if (((LogicalStateElement) stateElement).getStreamStateElement1() instanceof AbsentStreamStateElement) {
logicalPostStateProcessor1 = new AbsentLogicalPostStateProcessor(type);
} else {
logicalPostStateProcessor1 = new LogicalPostStateProcessor(type);
}
LogicalPreStateProcessor logicalPreStateProcessor2;
if (((LogicalStateElement) stateElement).getStreamStateElement2() instanceof AbsentStreamStateElement) {
logicalPreStateProcessor2 = new AbsentLogicalPreStateProcessor(type, stateType, ((AbsentStreamStateElement) ((LogicalStateElement) stateElement).getStreamStateElement2()).getWaitingTime());
startupPreStateProcessors.add(logicalPreStateProcessor2);
EntryValveProcessor entryValveProcessor = new EntryValveProcessor(siddhiQueryContext.getSiddhiAppContext());
entryValveProcessor.setToLast(logicalPreStateProcessor2);
Scheduler scheduler = SchedulerParser.parse(entryValveProcessor, siddhiQueryContext);
((SchedulingProcessor) logicalPreStateProcessor2).setScheduler(scheduler);
} else {
logicalPreStateProcessor2 = new LogicalPreStateProcessor(type, stateType);
}
logicalPreStateProcessor2.init(siddhiQueryContext);
LogicalPostStateProcessor logicalPostStateProcessor2;
if (((LogicalStateElement) stateElement).getStreamStateElement2() instanceof AbsentStreamStateElement) {
logicalPostStateProcessor2 = new AbsentLogicalPostStateProcessor(type);
} else {
logicalPostStateProcessor2 = new LogicalPostStateProcessor(type);
}
logicalPostStateProcessor1.setPartnerPreStateProcessor(logicalPreStateProcessor2);
logicalPostStateProcessor2.setPartnerPreStateProcessor(logicalPreStateProcessor1);
logicalPostStateProcessor1.setPartnerPostStateProcessor(logicalPostStateProcessor2);
logicalPostStateProcessor2.setPartnerPostStateProcessor(logicalPostStateProcessor1);
logicalPreStateProcessor1.setPartnerStatePreProcessor(logicalPreStateProcessor2);
logicalPreStateProcessor2.setPartnerStatePreProcessor(logicalPreStateProcessor1);
StateElement stateElement2 = ((LogicalStateElement) stateElement).getStreamStateElement2();
InnerStateRuntime innerStateRuntime2 = parse(stateElement2, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, variableExpressionExecutors, processStreamReceiverMap, logicalPreStateProcessor2, logicalPostStateProcessor2, stateType, multiValue, preStateProcessors, isStartState, startupPreStateProcessors, siddhiQueryContext);
StateElement stateElement1 = ((LogicalStateElement) stateElement).getStreamStateElement1();
InnerStateRuntime innerStateRuntime1 = parse(stateElement1, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, variableExpressionExecutors, processStreamReceiverMap, logicalPreStateProcessor1, logicalPostStateProcessor1, stateType, multiValue, preStateProcessors, isStartState, startupPreStateProcessors, siddhiQueryContext);
LogicalInnerStateRuntime logicalInnerStateRuntime = new LogicalInnerStateRuntime(innerStateRuntime1, innerStateRuntime2, stateType);
logicalInnerStateRuntime.setFirstProcessor(innerStateRuntime1.getFirstProcessor());
logicalInnerStateRuntime.setLastProcessor(innerStateRuntime2.getLastProcessor());
for (SingleStreamRuntime singleStreamRuntime : innerStateRuntime2.getSingleStreamRuntimeList()) {
logicalInnerStateRuntime.addStreamRuntime(singleStreamRuntime);
}
for (SingleStreamRuntime singleStreamRuntime : innerStateRuntime1.getSingleStreamRuntimeList()) {
logicalInnerStateRuntime.addStreamRuntime(singleStreamRuntime);
}
return logicalInnerStateRuntime;
} else if (stateElement instanceof CountStateElement) {
int minCount = ((CountStateElement) stateElement).getMinCount();
int maxCount = ((CountStateElement) stateElement).getMaxCount();
if (minCount == SiddhiConstants.ANY) {
minCount = 0;
}
if (maxCount == SiddhiConstants.ANY) {
maxCount = Integer.MAX_VALUE;
}
CountPreStateProcessor countPreStateProcessor = new CountPreStateProcessor(minCount, maxCount, stateType);
countPreStateProcessor.init(siddhiQueryContext);
CountPostStateProcessor countPostStateProcessor = new CountPostStateProcessor(minCount, maxCount);
countPreStateProcessor.setCountPostStateProcessor(countPostStateProcessor);
StateElement currentElement = ((CountStateElement) stateElement).getStreamStateElement();
InnerStateRuntime innerStateRuntime = parse(currentElement, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, metaStateEvent, variableExpressionExecutors, processStreamReceiverMap, countPreStateProcessor, countPostStateProcessor, stateType, true, preStateProcessors, isStartState, startupPreStateProcessors, siddhiQueryContext);
return new CountInnerStateRuntime((StreamInnerStateRuntime) innerStateRuntime);
} else {
throw new OperationNotSupportedException();
}
}
use of io.siddhi.core.exception.OperationNotSupportedException in project siddhi by wso2.
the class IndexEventHolder method delete.
@Override
public void delete(String attribute, Compare.Operator operator, Object value) {
if (isOperationLogEnabled) {
if (!isFullSnapshot()) {
operationChangeLog.add(new Operation(DELETE_BY_OPERATOR, new Object[] { attribute, operator, value }));
} else {
operationChangeLog.clear();
forceFullSnapshot = true;
}
}
if (primaryKeyData != null && attribute.equals(primaryKeyAttributes)) {
switch(operator) {
case LESS_THAN:
for (Iterator<StreamEvent> iterator = ((TreeMap<Object, StreamEvent>) primaryKeyData).headMap(value, false).values().iterator(); iterator.hasNext(); ) {
StreamEvent toDeleteEvent = iterator.next();
iterator.remove();
deleteFromIndexes(toDeleteEvent);
}
return;
case GREATER_THAN:
for (Iterator<StreamEvent> iterator = ((TreeMap<Object, StreamEvent>) primaryKeyData).tailMap(value, false).values().iterator(); iterator.hasNext(); ) {
StreamEvent toDeleteEvent = iterator.next();
iterator.remove();
deleteFromIndexes(toDeleteEvent);
}
return;
case LESS_THAN_EQUAL:
for (Iterator<StreamEvent> iterator = ((TreeMap<Object, StreamEvent>) primaryKeyData).headMap(value, true).values().iterator(); iterator.hasNext(); ) {
StreamEvent toDeleteEvent = iterator.next();
iterator.remove();
deleteFromIndexes(toDeleteEvent);
}
return;
case GREATER_THAN_EQUAL:
for (Iterator<StreamEvent> iterator = ((TreeMap<Object, StreamEvent>) primaryKeyData).tailMap(value, true).values().iterator(); iterator.hasNext(); ) {
StreamEvent toDeleteEvent = iterator.next();
iterator.remove();
deleteFromIndexes(toDeleteEvent);
}
return;
case EQUAL:
StreamEvent deletedEvent = primaryKeyData.remove(value);
if (deletedEvent != null) {
deleteFromIndexes(deletedEvent);
}
return;
case NOT_EQUAL:
StreamEvent streamEvent = primaryKeyData.get(value);
deleteAll();
if (streamEvent != null) {
add(streamEvent);
}
return;
}
} else {
switch(operator) {
case LESS_THAN:
for (Iterator<Set<StreamEvent>> iterator = indexData.get(attribute).headMap(value, false).values().iterator(); iterator.hasNext(); ) {
Set<StreamEvent> deletedEventSet = iterator.next();
deleteFromIndexesAndPrimaryKey(attribute, deletedEventSet);
iterator.remove();
}
return;
case GREATER_THAN:
for (Iterator<Set<StreamEvent>> iterator = indexData.get(attribute).tailMap(value, false).values().iterator(); iterator.hasNext(); ) {
Set<StreamEvent> deletedEventSet = iterator.next();
deleteFromIndexesAndPrimaryKey(attribute, deletedEventSet);
iterator.remove();
}
return;
case LESS_THAN_EQUAL:
for (Iterator<Set<StreamEvent>> iterator = indexData.get(attribute).headMap(value, true).values().iterator(); iterator.hasNext(); ) {
Set<StreamEvent> deletedEventSet = iterator.next();
deleteFromIndexesAndPrimaryKey(attribute, deletedEventSet);
iterator.remove();
}
return;
case GREATER_THAN_EQUAL:
for (Iterator<Set<StreamEvent>> iterator = indexData.get(attribute).tailMap(value, true).values().iterator(); iterator.hasNext(); ) {
Set<StreamEvent> deletedEventSet = iterator.next();
deleteFromIndexesAndPrimaryKey(attribute, deletedEventSet);
iterator.remove();
}
return;
case EQUAL:
Set<StreamEvent> deletedEventSet = indexData.get(attribute).remove(value);
if (deletedEventSet != null && deletedEventSet.size() > 0) {
deleteFromIndexesAndPrimaryKey(attribute, deletedEventSet);
}
return;
case NOT_EQUAL:
Set<StreamEvent> matchingEventSet = indexData.get(attribute).get(value);
deleteAll();
for (StreamEvent matchingEvent : matchingEventSet) {
add(matchingEvent);
}
return;
}
}
throw new OperationNotSupportedException(operator + " not supported for '" + value + "' by " + getClass().getName());
}
use of io.siddhi.core.exception.OperationNotSupportedException in project siddhi by wso2.
the class EventHolderPasser method parse.
public static EventHolder parse(AbstractDefinition tableDefinition, StreamEventFactory tableStreamEventFactory, SiddhiAppContext siddhiAppContext, boolean isCacheTable) {
ZeroStreamEventConverter eventConverter = new ZeroStreamEventConverter();
PrimaryKeyReferenceHolder[] primaryKeyReferenceHolders = null;
Map<String, Integer> indexMetaData = new HashMap<String, Integer>();
// primaryKey.
Annotation primaryKeyAnnotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_PRIMARY_KEY, tableDefinition.getAnnotations());
if (primaryKeyAnnotation != null) {
if (primaryKeyAnnotation.getElements().size() == 0) {
throw new SiddhiAppValidationException(SiddhiConstants.ANNOTATION_PRIMARY_KEY + " annotation " + "contains " + primaryKeyAnnotation.getElements().size() + " element, at '" + tableDefinition.getId() + "'");
}
primaryKeyReferenceHolders = primaryKeyAnnotation.getElements().stream().map(element -> element.getValue().trim()).map(key -> new PrimaryKeyReferenceHolder(key, tableDefinition.getAttributePosition(key))).toArray(PrimaryKeyReferenceHolder[]::new);
}
for (Annotation indexAnnotation : AnnotationHelper.getAnnotations(SiddhiConstants.ANNOTATION_INDEX, tableDefinition.getAnnotations())) {
if (indexAnnotation.getElements().size() == 0) {
throw new SiddhiAppValidationException(SiddhiConstants.ANNOTATION_INDEX + " annotation of " + "in-memory table should contain only one index element, but found " + indexAnnotation.getElements().size() + " element", indexAnnotation.getQueryContextStartIndex(), indexAnnotation.getQueryContextEndIndex());
} else if (indexAnnotation.getElements().size() > 1) {
throw new SiddhiAppValidationException(SiddhiConstants.ANNOTATION_INDEX + " annotation of the " + "in-memory table should only contain one index element but found " + indexAnnotation.getElements().size() + " elements. To use multiple indexes, " + "define multiple '@index(<index key>)' annotations with one index element " + "per each index key", indexAnnotation.getQueryContextStartIndex(), indexAnnotation.getQueryContextEndIndex());
}
for (Element element : indexAnnotation.getElements()) {
Integer previousValue = indexMetaData.put(element.getValue().trim(), tableDefinition.getAttributePosition(element.getValue().trim()));
if (previousValue != null) {
throw new SiddhiAppValidationException("Multiple " + SiddhiConstants.ANNOTATION_INDEX + " " + "annotations defined with same attribute '" + element.getValue().trim() + "', at '" + tableDefinition.getId() + "'", indexAnnotation.getQueryContextStartIndex(), indexAnnotation.getQueryContextEndIndex());
}
}
}
// not support indexBy.
Annotation indexByAnnotation = AnnotationHelper.getAnnotation(SiddhiConstants.ANNOTATION_INDEX_BY, tableDefinition.getAnnotations());
if (indexByAnnotation != null) {
throw new OperationNotSupportedException(SiddhiConstants.ANNOTATION_INDEX_BY + " annotation is not " + "supported anymore, please use @PrimaryKey or @Index annotations instead," + " at '" + tableDefinition.getId() + "'");
}
if (primaryKeyReferenceHolders != null || indexMetaData.size() > 0) {
boolean isNumeric = false;
if (primaryKeyReferenceHolders != null) {
if (primaryKeyReferenceHolders.length == 1) {
Attribute.Type type = tableDefinition.getAttributeType(primaryKeyReferenceHolders[0].getPrimaryKeyAttribute());
if (type == Attribute.Type.DOUBLE || type == Attribute.Type.FLOAT || type == Attribute.Type.INT || type == Attribute.Type.LONG) {
isNumeric = true;
}
}
}
if (isCacheTable) {
return new IndexEventHolderForCache(tableStreamEventFactory, eventConverter, primaryKeyReferenceHolders, isNumeric, indexMetaData, tableDefinition, siddhiAppContext);
} else {
return new IndexEventHolder(tableStreamEventFactory, eventConverter, primaryKeyReferenceHolders, isNumeric, indexMetaData, tableDefinition, siddhiAppContext);
}
} else {
MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
for (Attribute attribute : tableDefinition.getAttributeList()) {
metaStreamEvent.addOutputData(attribute);
}
StreamEventCloner streamEventCloner = new StreamEventCloner(metaStreamEvent, tableStreamEventFactory);
return new ListEventHolder(tableStreamEventFactory, eventConverter, new StreamEventClonerHolder(streamEventCloner));
}
}
use of io.siddhi.core.exception.OperationNotSupportedException in project siddhi by wso2.
the class InputStreamParser method parse.
/**
* Parse an InputStream returning corresponding StreamRuntime
*
* @param inputStream input stream to be parsed
* @param streamDefinitionMap map containing user given stream definitions
* @param tableDefinitionMap table definition map
* @param windowDefinitionMap window definition map
* @param aggregationDefinitionMap aggregation definition map
* @param tableMap Table Map
* @param windowMap event window map
* @param aggregationMap aggregator map
* @param executors List to hold VariableExpressionExecutors to update after query parsing
* @param outputExpectsExpiredEvents is expired events sent as output
* @param siddhiQueryContext Siddhi query context.
* @return StreamRuntime
*/
public static StreamRuntime parse(InputStream inputStream, Query query, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, Map<String, Window> windowMap, Map<String, AggregationRuntime> aggregationMap, List<VariableExpressionExecutor> executors, boolean outputExpectsExpiredEvents, SiddhiQueryContext siddhiQueryContext) {
if (inputStream instanceof BasicSingleInputStream || inputStream instanceof SingleInputStream) {
SingleInputStream singleInputStream = (SingleInputStream) inputStream;
ProcessStreamReceiver processStreamReceiver = new ProcessStreamReceiver(singleInputStream.getStreamId(), siddhiQueryContext);
return SingleInputStreamParser.parseInputStream((SingleInputStream) inputStream, executors, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, new MetaStreamEvent(), processStreamReceiver, true, outputExpectsExpiredEvents, false, false, siddhiQueryContext);
} else if (inputStream instanceof JoinInputStream) {
return JoinInputStreamParser.parseInputStream(((JoinInputStream) inputStream), query, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, windowMap, aggregationMap, executors, outputExpectsExpiredEvents, siddhiQueryContext);
} else if (inputStream instanceof StateInputStream) {
MetaStateEvent metaStateEvent = new MetaStateEvent(inputStream.getAllStreamIds().size());
return StateInputStreamParser.parseInputStream(((StateInputStream) inputStream), metaStateEvent, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, tableMap, executors, siddhiQueryContext);
} else {
throw new OperationNotSupportedException();
}
}
Aggregations