Search in sources :

Example 11 with IndexedEventHolder

use of org.wso2.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.

the class AndMultiPrimaryKeyCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
    if (storeEventSet == null) {
        return returnEventChunk.getFirst();
    } else {
        for (StreamEvent storeEvent : storeEventSet) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 12 with IndexedEventHolder

use of org.wso2.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.

the class CompareCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
    Collection<StreamEvent> storeEventSet = findEvents(matchingEvent, indexedEventHolder);
    if (storeEventSet == null) {
        // triggering sequential scan
        Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
        for (StreamEvent storeEvent : storeEvents) {
            matchingEvent.setEvent(storeEventIndex, storeEvent);
            if ((Boolean) expressionExecutor.execute(matchingEvent)) {
                if (storeEventCloner != null) {
                    returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
                } else {
                    returnEventChunk.add(storeEvent);
                }
            }
            matchingEvent.setEvent(storeEventIndex, null);
        }
        return returnEventChunk.getFirst();
    } else {
        for (StreamEvent storeEvent : storeEventSet) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 13 with IndexedEventHolder

use of org.wso2.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.

the class NonCollectionExecutor method find.

public StreamEvent find(StateEvent matchingEvent, IndexedEventHolder indexedEventHolder, StreamEventCloner storeEventCloner) {
    if ((Boolean) expressionExecutor.execute(matchingEvent)) {
        ComplexEventChunk<StreamEvent> returnEventChunk = new ComplexEventChunk<StreamEvent>(false);
        Collection<StreamEvent> storeEvents = indexedEventHolder.getAllEvents();
        for (StreamEvent storeEvent : storeEvents) {
            if (storeEventCloner != null) {
                returnEventChunk.add(storeEventCloner.copyStreamEvent(storeEvent));
            } else {
                returnEventChunk.add(storeEvent);
            }
        }
        return returnEventChunk.getFirst();
    } else {
        return null;
    }
}
Also used : ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 14 with IndexedEventHolder

use of org.wso2.siddhi.core.table.holder.IndexedEventHolder in project siddhi by wso2.

the class NotCollectionExecutor method delete.

@Override
public void delete(StateEvent deletingEvent, IndexedEventHolder indexedEventHolder) {
    Collection<StreamEvent> notStreamEvents = notCollectionExecutor.findEvents(deletingEvent, indexedEventHolder);
    if (notStreamEvents == null) {
        exhaustiveCollectionExecutor.delete(deletingEvent, indexedEventHolder);
    } else if (notStreamEvents.size() == 0) {
        indexedEventHolder.deleteAll();
    } else if (notStreamEvents.size() != indexedEventHolder.getAllEvents().size()) {
        Collection<StreamEvent> allEvents = indexedEventHolder.getAllEvents();
        Set<StreamEvent> returnSet = new HashSet<StreamEvent>();
        for (StreamEvent aEvent : allEvents) {
            if (!notStreamEvents.contains(aEvent)) {
                returnSet.add(aEvent);
            }
        }
        indexedEventHolder.deleteAll(returnSet);
    }
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) HashSet(java.util.HashSet)

Aggregations

StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)10 ComplexEventChunk (org.wso2.siddhi.core.event.ComplexEventChunk)9 StateEvent (org.wso2.siddhi.core.event.state.StateEvent)4 HashSet (java.util.HashSet)3 Map (java.util.Map)2 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)2 IndexedEventHolder (org.wso2.siddhi.core.table.holder.IndexedEventHolder)2 AndMultiPrimaryKeyCollectionExpression (org.wso2.siddhi.core.util.collection.expression.AndMultiPrimaryKeyCollectionExpression)2 AttributeCollectionExpression (org.wso2.siddhi.core.util.collection.expression.AttributeCollectionExpression)2 CollectionExpression (org.wso2.siddhi.core.util.collection.expression.CollectionExpression)2 CompareCollectionExpression (org.wso2.siddhi.core.util.collection.expression.CompareCollectionExpression)2 Collection (java.util.Collection)1 Set (java.util.Set)1 OperationNotSupportedException (org.wso2.siddhi.core.exception.OperationNotSupportedException)1 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)1 PrimaryKeyReferenceHolder (org.wso2.siddhi.core.table.holder.PrimaryKeyReferenceHolder)1 CollectionExecutor (org.wso2.siddhi.core.util.collection.executor.CollectionExecutor)1 AndCollectionExpression (org.wso2.siddhi.core.util.collection.expression.AndCollectionExpression)1 BasicCollectionExpression (org.wso2.siddhi.core.util.collection.expression.BasicCollectionExpression)1 NotCollectionExpression (org.wso2.siddhi.core.util.collection.expression.NotCollectionExpression)1