Search in sources :

Example 51 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class TestStoreContainingInMemoryTable method objectListToComplexEventChunk.

private ComplexEventChunk<StreamEvent> objectListToComplexEventChunk(List<Object[]> records) {
    ComplexEventChunk<StreamEvent> complexEventChunk = new ComplexEventChunk<>();
    for (Object[] record : records) {
        StreamEvent event = storeEventPool.newInstance();
        event.setOutputData(record);
        complexEventChunk.add(event);
    }
    return complexEventChunk;
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Example 52 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class TestStoreForCacheMiss method objectListToComplexEventChunk.

private ComplexEventChunk<StreamEvent> objectListToComplexEventChunk(List<Object[]> records) {
    ComplexEventChunk<StreamEvent> complexEventChunk = new ComplexEventChunk<>();
    for (Object[] record : records) {
        StreamEvent event = storeEventPool.newInstance();
        event.setOutputData(record);
        complexEventChunk.add(event);
    }
    return complexEventChunk;
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Example 53 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class TestStoreForCacheMiss method convForDelete.

private ComplexEventChunk<StreamEvent> convForDelete(List<Map<String, Object>> deleteConditionParameterMaps) {
    List<Object[]> objectList = new LinkedList<>();
    for (Map<String, Object> parameterMap : deleteConditionParameterMaps) {
        List<Object> outputData = new ArrayList<>();
        List<Attribute> attributeList = inMemoryTable.getTableDefinition().getAttributeList();
        for (int i = 0; i < attributeList.size(); i++) {
            if (parameterMap.get(attributeList.get(i).getName()) != null) {
                outputData.add(parameterMap.get(attributeList.get(i).getName()));
            } else {
                outputData.add(null);
            }
        }
        objectList.add(outputData.toArray());
    }
    ComplexEventChunk<StreamEvent> complexEventChunk = new ComplexEventChunk<>();
    for (Object[] record : objectList) {
        StreamEvent event = new StreamEvent(0, 0, record.length);
        // StateEvent stateEvent = new StateEvent(2, record.length);
        event.setOutputData(record);
        // stateEvent.addEvent(0, event);
        complexEventChunk.add(event);
    }
    return complexEventChunk;
}
Also used : ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) Attribute(io.siddhi.query.api.definition.Attribute) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList)

Example 54 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class TestStoreForCacheMiss method query.

@Override
protected RecordIterator<Object[]> query(Map<String, Object> parameterMap, CompiledCondition compiledCondition, CompiledSelection compiledSelection, Attribute[] outputAttributes) {
    StreamEvent outEvent = inMemoryTable.find(compiledCondition, findMatchingEvent);
    List<Object[]> objects = new LinkedList<>();
    CompiledSelectionWithCache compiledSelectionWithCache = null;
    if (outEvent != null) {
        compiledSelectionWithCache = (CompiledSelectionWithCache) compiledSelection;
        StateEventFactory stateEventFactory = new StateEventFactory(compiledSelectionWithCache.getMetaStateEvent());
        Event[] cacheResultsAfterSelection = executeSelector(stateEventFactory, null, outEvent, compiledSelectionWithCache.getStoreEventIndex(), compiledSelectionWithCache.getQuerySelector());
        if (compiledSelectionWithCache.getQuerySelector() != null & compiledSelectionWithCache.getQuerySelector().getAttributeProcessorList().size() != 0) {
            compiledSelectionWithCache.getQuerySelector().process(generateResetComplexEventChunk(outEvent.getOutputData().length, stateEventFactory));
        }
        if (cacheResultsAfterSelection != null) {
            for (Event event : cacheResultsAfterSelection) {
                objects.add(event.getData());
            }
        }
    }
    return new TestStoreWithCacheIterator(objects.iterator());
}
Also used : StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) StateEventFactory(io.siddhi.core.event.state.StateEventFactory) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) Event(io.siddhi.core.event.Event) ComplexEvent(io.siddhi.core.event.ComplexEvent) StateEvent(io.siddhi.core.event.state.StateEvent) LinkedList(java.util.LinkedList)

Example 55 with StreamEvent

use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.

the class TestStoreForCacheMiss method generateResetComplexEventChunk.

private ComplexEventChunk<ComplexEvent> generateResetComplexEventChunk(int outputDataSize, StateEventFactory stateEventFactory) {
    StreamEvent streamEvent = new StreamEvent(outputDataSize, 0, outputDataSize);
    streamEvent.setType(ComplexEvent.Type.RESET);
    StateEvent stateEvent = stateEventFactory.newInstance();
    stateEvent.addEvent(0, streamEvent);
    stateEvent.setType(ComplexEvent.Type.RESET);
    ComplexEventChunk<ComplexEvent> complexEventChunk = new ComplexEventChunk<>();
    complexEventChunk.add(stateEvent);
    return complexEventChunk;
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) StateEvent(io.siddhi.core.event.state.StateEvent)

Aggregations

StreamEvent (io.siddhi.core.event.stream.StreamEvent)203 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)92 ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)74 StateEvent (io.siddhi.core.event.state.StateEvent)52 ComplexEvent (io.siddhi.core.event.ComplexEvent)33 ArrayList (java.util.ArrayList)27 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)26 Map (java.util.Map)24 Event (io.siddhi.core.event.Event)23 Test (org.testng.annotations.Test)23 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)20 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)18 Attribute (io.siddhi.query.api.definition.Attribute)17 HashMap (java.util.HashMap)17 Operation (io.siddhi.core.event.stream.Operation)12 LinkedList (java.util.LinkedList)12 SnapshotableStreamEventQueue (io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue)11 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)10 HashSet (java.util.HashSet)10 StreamEventConverter (io.siddhi.core.event.stream.converter.StreamEventConverter)8