use of io.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.
the class OverwriteTableIndexOperator method tryUpdate.
@Override
public ComplexEventChunk<StateEvent> tryUpdate(ComplexEventChunk<StateEvent> updatingOrAddingEventChunk, Object storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor) {
updatingOrAddingEventChunk.reset();
while (updatingOrAddingEventChunk.hasNext()) {
StateEvent overwritingOrAddingEvent = updatingOrAddingEventChunk.next();
((IndexedEventHolder) storeEvents).overwrite(addingStreamEventExtractor.getAddingStreamEvent(overwritingOrAddingEvent));
}
return null;
}
use of io.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.
the class OperatorParser method constructOperatorForCache.
public static Operator constructOperatorForCache(Object storeEvents, Expression expression, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext, boolean updateCachePolicyAttribute, CacheTable cacheTable) {
if (storeEvents instanceof IndexedEventHolder && updateCachePolicyAttribute) {
CollectionExpression collectionExpression = CollectionExpressionParser.parseCollectionExpression(expression, matchingMetaInfoHolder, (IndexedEventHolder) storeEvents);
CollectionExecutor collectionExecutor = CollectionExpressionParser.buildCollectionExecutor(collectionExpression, matchingMetaInfoHolder, variableExpressionExecutors, tableMap, true, ProcessingMode.BATCH, false, siddhiQueryContext, true, cacheTable);
if (collectionExpression instanceof CompareCollectionExpression && ((CompareCollectionExpression) collectionExpression).getOperator() == Compare.Operator.EQUAL && (collectionExpression.getCollectionScope() == INDEXED_RESULT_SET || collectionExpression.getCollectionScope() == PRIMARY_KEY_RESULT_SET) && ((IndexedEventHolder) storeEvents).getPrimaryKeyReferenceHolders() != null && ((IndexedEventHolder) storeEvents).getPrimaryKeyReferenceHolders().length == 1 && ((IndexedEventHolder) storeEvents).getPrimaryKeyReferenceHolders()[0].getPrimaryKeyAttribute().equals(((AttributeCollectionExpression) ((CompareCollectionExpression) collectionExpression).getAttributeCollectionExpression()).getAttribute())) {
return new OverwriteTableIndexOperatorForCache(collectionExecutor, siddhiQueryContext.getName(), cacheTable);
} else if (collectionExpression instanceof AndMultiPrimaryKeyCollectionExpression && collectionExpression.getCollectionScope() == PRIMARY_KEY_RESULT_SET) {
return new OverwriteTableIndexOperatorForCache(collectionExecutor, siddhiQueryContext.getName(), cacheTable);
} else {
return new IndexOperatorForCache(collectionExecutor, siddhiQueryContext.getName(), cacheTable);
}
}
return constructOperator(storeEvents, expression, matchingMetaInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);
}
use of io.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.
the class OperatorParser method constructOperator.
public static Operator constructOperator(Object storeEvents, Expression expression, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
if (storeEvents instanceof IndexedEventHolder) {
CollectionExpression collectionExpression = CollectionExpressionParser.parseCollectionExpression(expression, matchingMetaInfoHolder, (IndexedEventHolder) storeEvents);
CollectionExecutor collectionExecutor = CollectionExpressionParser.buildCollectionExecutor(collectionExpression, matchingMetaInfoHolder, variableExpressionExecutors, tableMap, true, ProcessingMode.BATCH, false, siddhiQueryContext, false, null);
if (collectionExpression instanceof CompareCollectionExpression && ((CompareCollectionExpression) collectionExpression).getOperator() == Compare.Operator.EQUAL && (collectionExpression.getCollectionScope() == INDEXED_RESULT_SET || collectionExpression.getCollectionScope() == PRIMARY_KEY_RESULT_SET) && ((IndexedEventHolder) storeEvents).getPrimaryKeyReferenceHolders() != null && ((IndexedEventHolder) storeEvents).getPrimaryKeyReferenceHolders().length == 1 && ((IndexedEventHolder) storeEvents).getPrimaryKeyReferenceHolders()[0].getPrimaryKeyAttribute().equals(((AttributeCollectionExpression) ((CompareCollectionExpression) collectionExpression).getAttributeCollectionExpression()).getAttribute())) {
return new OverwriteTableIndexOperator(collectionExecutor, siddhiQueryContext.getName());
} else if (collectionExpression instanceof AndMultiPrimaryKeyCollectionExpression && collectionExpression.getCollectionScope() == PRIMARY_KEY_RESULT_SET) {
return new OverwriteTableIndexOperator(collectionExecutor, siddhiQueryContext.getName());
} else {
return new IndexOperator(collectionExecutor, siddhiQueryContext.getName());
}
} else if (storeEvents instanceof ComplexEventChunk) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(expression, matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
return new EventChunkOperator(expressionExecutor, matchingMetaInfoHolder.getStoreEventIndex());
} else if (storeEvents instanceof SnapshotableStreamEventQueue) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(expression, matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
return new SnapshotableEventQueueOperator(expressionExecutor, matchingMetaInfoHolder.getStoreEventIndex());
} else if (storeEvents instanceof Map) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(expression, matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
return new MapOperator(expressionExecutor, matchingMetaInfoHolder.getStoreEventIndex());
} else if (storeEvents instanceof Collection) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(expression, matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
return new CollectionOperator(expressionExecutor, matchingMetaInfoHolder.getStoreEventIndex());
} else {
throw new OperationNotSupportedException(storeEvents.getClass() + " is not supported by OperatorParser!");
}
}
use of io.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.
the class OverwriteTableIndexOperatorForCache method tryUpdate.
@Override
public ComplexEventChunk<StateEvent> tryUpdate(ComplexEventChunk<StateEvent> updatingOrAddingEventChunk, Object storeEvents, InMemoryCompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor) {
updatingOrAddingEventChunk.reset();
while (updatingOrAddingEventChunk.hasNext()) {
StateEvent overwritingOrAddingEvent = updatingOrAddingEventChunk.next();
((IndexedEventHolder) storeEvents).overwrite(addingStreamEventExtractor.getAddingStreamEvent(overwritingOrAddingEvent));
}
return null;
}
Aggregations