Search in sources :

Example 1 with IndexedEventHolder

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;
}
Also used : IndexedEventHolder(io.siddhi.core.table.holder.IndexedEventHolder) StateEvent(io.siddhi.core.event.state.StateEvent)

Example 2 with IndexedEventHolder

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);
}
Also used : IndexOperatorForCache(io.siddhi.core.util.collection.operator.IndexOperatorForCache) OverwriteTableIndexOperatorForCache(io.siddhi.core.util.collection.operator.OverwriteTableIndexOperatorForCache) CompareCollectionExpression(io.siddhi.core.util.collection.expression.CompareCollectionExpression) AttributeCollectionExpression(io.siddhi.core.util.collection.expression.AttributeCollectionExpression) IndexedEventHolder(io.siddhi.core.table.holder.IndexedEventHolder) AndMultiPrimaryKeyCollectionExpression(io.siddhi.core.util.collection.expression.AndMultiPrimaryKeyCollectionExpression) CollectionExecutor(io.siddhi.core.util.collection.executor.CollectionExecutor) OverwriteTableIndexOperatorForCache(io.siddhi.core.util.collection.operator.OverwriteTableIndexOperatorForCache) CollectionExpression(io.siddhi.core.util.collection.expression.CollectionExpression) CompareCollectionExpression(io.siddhi.core.util.collection.expression.CompareCollectionExpression) AndMultiPrimaryKeyCollectionExpression(io.siddhi.core.util.collection.expression.AndMultiPrimaryKeyCollectionExpression) AttributeCollectionExpression(io.siddhi.core.util.collection.expression.AttributeCollectionExpression)

Example 3 with IndexedEventHolder

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!");
    }
}
Also used : OverwriteTableIndexOperator(io.siddhi.core.util.collection.operator.OverwriteTableIndexOperator) OperationNotSupportedException(io.siddhi.core.exception.OperationNotSupportedException) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) ExpressionExecutor(io.siddhi.core.executor.ExpressionExecutor) AttributeCollectionExpression(io.siddhi.core.util.collection.expression.AttributeCollectionExpression) AndMultiPrimaryKeyCollectionExpression(io.siddhi.core.util.collection.expression.AndMultiPrimaryKeyCollectionExpression) EventChunkOperator(io.siddhi.core.util.collection.operator.EventChunkOperator) CollectionOperator(io.siddhi.core.util.collection.operator.CollectionOperator) OverwriteTableIndexOperator(io.siddhi.core.util.collection.operator.OverwriteTableIndexOperator) IndexOperator(io.siddhi.core.util.collection.operator.IndexOperator) MapOperator(io.siddhi.core.util.collection.operator.MapOperator) CompareCollectionExpression(io.siddhi.core.util.collection.expression.CompareCollectionExpression) IndexedEventHolder(io.siddhi.core.table.holder.IndexedEventHolder) CollectionExecutor(io.siddhi.core.util.collection.executor.CollectionExecutor) SnapshotableEventQueueOperator(io.siddhi.core.util.collection.operator.SnapshotableEventQueueOperator) Collection(java.util.Collection) CollectionExpression(io.siddhi.core.util.collection.expression.CollectionExpression) CompareCollectionExpression(io.siddhi.core.util.collection.expression.CompareCollectionExpression) AndMultiPrimaryKeyCollectionExpression(io.siddhi.core.util.collection.expression.AndMultiPrimaryKeyCollectionExpression) AttributeCollectionExpression(io.siddhi.core.util.collection.expression.AttributeCollectionExpression) Map(java.util.Map) SnapshotableStreamEventQueue(io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue)

Example 4 with IndexedEventHolder

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;
}
Also used : IndexedEventHolder(io.siddhi.core.table.holder.IndexedEventHolder) StateEvent(io.siddhi.core.event.state.StateEvent)

Aggregations

IndexedEventHolder (io.siddhi.core.table.holder.IndexedEventHolder)4 StateEvent (io.siddhi.core.event.state.StateEvent)2 CollectionExecutor (io.siddhi.core.util.collection.executor.CollectionExecutor)2 AndMultiPrimaryKeyCollectionExpression (io.siddhi.core.util.collection.expression.AndMultiPrimaryKeyCollectionExpression)2 AttributeCollectionExpression (io.siddhi.core.util.collection.expression.AttributeCollectionExpression)2 CollectionExpression (io.siddhi.core.util.collection.expression.CollectionExpression)2 CompareCollectionExpression (io.siddhi.core.util.collection.expression.CompareCollectionExpression)2 ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)1 SnapshotableStreamEventQueue (io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue)1 OperationNotSupportedException (io.siddhi.core.exception.OperationNotSupportedException)1 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)1 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)1 CollectionOperator (io.siddhi.core.util.collection.operator.CollectionOperator)1 EventChunkOperator (io.siddhi.core.util.collection.operator.EventChunkOperator)1 IndexOperator (io.siddhi.core.util.collection.operator.IndexOperator)1 IndexOperatorForCache (io.siddhi.core.util.collection.operator.IndexOperatorForCache)1 MapOperator (io.siddhi.core.util.collection.operator.MapOperator)1 OverwriteTableIndexOperator (io.siddhi.core.util.collection.operator.OverwriteTableIndexOperator)1 OverwriteTableIndexOperatorForCache (io.siddhi.core.util.collection.operator.OverwriteTableIndexOperatorForCache)1 SnapshotableEventQueueOperator (io.siddhi.core.util.collection.operator.SnapshotableEventQueueOperator)1