Search in sources :

Example 16 with StreamEventFactory

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

the class EventTestCase method testEventCreation.

@Test
public void testEventCreation() {
    EventExchangeHolderFactory eventExchangeHolderFactory = new EventExchangeHolderFactory(2);
    AssertJUnit.assertEquals(2, eventExchangeHolderFactory.newInstance().getEvent().getData().length);
    StreamEventFactory streamEventFactory = new StreamEventFactory(2, 3, 4);
    StreamEvent streamEvent = streamEventFactory.newInstance();
    AssertJUnit.assertEquals(2, streamEvent.getBeforeWindowData().length);
    AssertJUnit.assertEquals(3, streamEvent.getOnAfterWindowData().length);
    AssertJUnit.assertEquals(4, streamEvent.getOutputData().length);
}
Also used : EventExchangeHolderFactory(io.siddhi.core.util.event.handler.EventExchangeHolderFactory) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) Test(org.testng.annotations.Test)

Example 17 with StreamEventFactory

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(List<Event> events) {
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        for (Event event : events) {
            try {
                multiProcessReturn.set(new ReturnEventHolder());
                stabilizeStates(event.getTimestamp());
                for (int anEventSequence : eventSequence) {
                    StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                    StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                    StreamEvent newEvent = aStreamEventFactory.newInstance();
                    aStreamEventConverter.convertEvent(event, newEvent);
                    process(anEventSequence, newEvent);
                    if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                        returnEventHolderList.add(multiProcessReturn.get());
                        multiProcessReturn.set(new ReturnEventHolder());
                    }
                }
            } finally {
                multiProcessReturn.set(null);
            }
        }
    }
    for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
        outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
    }
}
Also used : StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList) Event(io.siddhi.core.event.Event) ComplexEvent(io.siddhi.core.event.ComplexEvent) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Example 18 with StreamEventFactory

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(ComplexEvent complexEvent) {
    ComplexEvent aComplexEvent = complexEvent;
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        while (aComplexEvent != null) {
            try {
                multiProcessReturn.set(new ReturnEventHolder());
                stabilizeStates(aComplexEvent.getTimestamp());
                for (int anEventSequence : eventSequence) {
                    StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                    StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                    StreamEvent newEvent = aStreamEventFactory.newInstance();
                    aStreamEventConverter.convertComplexEvent(aComplexEvent, newEvent);
                    process(anEventSequence, newEvent);
                    if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                        returnEventHolderList.add(multiProcessReturn.get());
                        multiProcessReturn.set(new ReturnEventHolder());
                    }
                }
            } finally {
                multiProcessReturn.set(null);
            }
            aComplexEvent = aComplexEvent.getNext();
        }
        for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
            outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
        }
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList)

Example 19 with StreamEventFactory

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(long timestamp, Object[] data) {
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        try {
            multiProcessReturn.set(new ReturnEventHolder());
            stabilizeStates(timestamp);
            for (int anEventSequence : eventSequence) {
                StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                StreamEvent newEvent = aStreamEventFactory.newInstance();
                aStreamEventConverter.convertData(timestamp, data, newEvent);
                process(anEventSequence, newEvent);
                if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                    returnEventHolderList.add(multiProcessReturn.get());
                    multiProcessReturn.set(new ReturnEventHolder());
                }
            }
        } finally {
            multiProcessReturn.set(null);
        }
    }
    for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
        outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
    }
}
Also used : StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList)

Example 20 with StreamEventFactory

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

the class MultiProcessStreamReceiver method receive.

@Override
public void receive(Event event) {
    List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
    synchronized (patternSyncObject) {
        try {
            multiProcessReturn.set(new ReturnEventHolder());
            stabilizeStates(event.getTimestamp());
            for (int anEventSequence : eventSequence) {
                StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
                StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
                StreamEvent newEvent = aStreamEventFactory.newInstance();
                aStreamEventConverter.convertEvent(event, newEvent);
                process(anEventSequence, newEvent);
                if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
                    returnEventHolderList.add(multiProcessReturn.get());
                    multiProcessReturn.set(new ReturnEventHolder());
                }
            }
        } finally {
            multiProcessReturn.set(null);
        }
    }
    for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
        outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
    }
}
Also used : StreamEventConverter(io.siddhi.core.event.stream.converter.StreamEventConverter) StreamEventFactory(io.siddhi.core.event.stream.StreamEventFactory) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ArrayList(java.util.ArrayList)

Aggregations

StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)39 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)23 StreamEvent (io.siddhi.core.event.stream.StreamEvent)21 Attribute (io.siddhi.query.api.definition.Attribute)15 Test (org.testng.annotations.Test)15 ArrayList (java.util.ArrayList)13 StreamEventCloner (io.siddhi.core.event.stream.StreamEventCloner)11 StreamEventConverter (io.siddhi.core.event.stream.converter.StreamEventConverter)9 HashMap (java.util.HashMap)7 Map (java.util.Map)7 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)6 ConversionStreamEventChunk (io.siddhi.core.event.stream.converter.ConversionStreamEventChunk)6 StreamEventClonerHolder (io.siddhi.core.event.stream.holder.StreamEventClonerHolder)6 Event (io.siddhi.core.event.Event)5 Operation (io.siddhi.core.event.stream.Operation)5 ZeroStreamEventConverter (io.siddhi.core.event.stream.converter.ZeroStreamEventConverter)5 SnapshotableStreamEventQueue (io.siddhi.core.event.stream.holder.SnapshotableStreamEventQueue)5 Snapshot (io.siddhi.core.util.snapshot.state.Snapshot)5 SnapshotStateList (io.siddhi.core.util.snapshot.state.SnapshotStateList)5 ComplexEvent (io.siddhi.core.event.ComplexEvent)4