Search in sources :

Example 1 with ConversionStreamEventChunk

use of org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project ballerina by ballerina-lang.

the class Scheduler method setStreamEventPool.

public void setStreamEventPool(StreamEventPool streamEventPool) {
    this.streamEventPool = streamEventPool;
    streamEventChunk = new ConversionStreamEventChunk((StreamEventConverter) null, streamEventPool);
}
Also used : ConversionStreamEventChunk(org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk) StreamEventConverter(org.ballerinalang.siddhi.core.event.stream.converter.StreamEventConverter)

Example 2 with ConversionStreamEventChunk

use of org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project ballerina by ballerina-lang.

the class ComplexEventChunkTestCase method eventChunkRemoveTest2.

@Test
public void eventChunkRemoveTest2() {
    StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
    streamEvent1.setOutputData(new Object[] { "IBM", 700L, 1L });
    StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
    streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 2L });
    StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
    streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 3L });
    StreamEvent streamEvent4 = new StreamEvent(0, 0, 3);
    streamEvent4.setOutputData(new Object[] { "WSO2", 700L, 4L });
    streamEvent1.setNext(streamEvent2);
    streamEvent2.setNext(streamEvent3);
    streamEvent3.setNext(streamEvent4);
    StreamEventPool streamEventPool = new StreamEventPool(0, 0, 3, 5);
    ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventPool);
    streamEventChunk.convertAndAssign(streamEvent1);
    while (streamEventChunk.hasNext()) {
        count++;
        streamEventChunk.next();
        if (count == 1 || count == 2) {
            streamEventChunk.remove();
        }
    }
    StreamEvent streamEvent = streamEventChunk.getFirst();
    AssertJUnit.assertEquals(streamEvent3, streamEvent);
    AssertJUnit.assertEquals(streamEvent4, streamEvent.getNext());
}
Also used : ConversionStreamEventChunk(org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StreamEventPool(org.ballerinalang.siddhi.core.event.stream.StreamEventPool) Test(org.testng.annotations.Test)

Example 3 with ConversionStreamEventChunk

use of org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project ballerina by ballerina-lang.

the class ComplexEventChunkTestCase method eventChunkRemoveTest1.

@Test
public void eventChunkRemoveTest1() {
    StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
    streamEvent1.setOutputData(new Object[] { "IBM", 700L, 1L });
    StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
    streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 2L });
    StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
    streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 3L });
    streamEvent1.setNext(streamEvent2);
    streamEvent2.setNext(streamEvent3);
    StreamEventPool streamEventPool = new StreamEventPool(0, 0, 3, 5);
    ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventPool);
    streamEventChunk.convertAndAssign(streamEvent1);
    while (streamEventChunk.hasNext()) {
        count++;
        streamEventChunk.next();
        if (count == 1) {
            streamEventChunk.remove();
        }
    }
    AssertJUnit.assertEquals(streamEvent2, streamEventChunk.getFirst());
}
Also used : ConversionStreamEventChunk(org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StreamEventPool(org.ballerinalang.siddhi.core.event.stream.StreamEventPool) Test(org.testng.annotations.Test)

Example 4 with ConversionStreamEventChunk

use of org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project ballerina by ballerina-lang.

the class ComplexEventChunkTestCase method eventChunkRemoveTest4.

@Test
public void eventChunkRemoveTest4() {
    StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
    streamEvent1.setOutputData(new Object[] { "IBM", 700L, 100L });
    StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
    streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 100L });
    StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
    streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 100L });
    StreamEvent streamEvent4 = new StreamEvent(0, 0, 3);
    streamEvent4.setOutputData(new Object[] { "WSO2", 700L, 100L });
    streamEvent1.setNext(streamEvent2);
    streamEvent2.setNext(streamEvent3);
    streamEvent3.setNext(streamEvent4);
    StreamEventPool streamEventPool = new StreamEventPool(0, 0, 3, 5);
    ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventPool);
    streamEventChunk.convertAndAssign(streamEvent1);
    while (streamEventChunk.hasNext()) {
        count++;
        streamEventChunk.next();
        if (count == 2 || count == 4) {
            streamEventChunk.remove();
        }
    }
    StreamEvent streamEvent = streamEventChunk.getFirst();
    AssertJUnit.assertEquals(streamEvent1, streamEvent);
    AssertJUnit.assertEquals(streamEvent3, streamEvent.getNext());
    AssertJUnit.assertNull(streamEvent.getNext().getNext());
}
Also used : ConversionStreamEventChunk(org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StreamEventPool(org.ballerinalang.siddhi.core.event.stream.StreamEventPool) Test(org.testng.annotations.Test)

Example 5 with ConversionStreamEventChunk

use of org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk in project ballerina by ballerina-lang.

the class ComplexEventChunkTestCase method eventChunkRemoveTest3.

@Test
public void eventChunkRemoveTest3() {
    StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
    streamEvent1.setOutputData(new Object[] { "IBM", 700L, 100L });
    StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
    streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 100L });
    StreamEvent streamEvent3 = new StreamEvent(0, 0, 3);
    streamEvent3.setOutputData(new Object[] { "WSO2", 700L, 100L });
    StreamEvent streamEvent4 = new StreamEvent(0, 0, 3);
    streamEvent4.setOutputData(new Object[] { "WSO2", 700L, 100L });
    streamEvent1.setNext(streamEvent2);
    streamEvent2.setNext(streamEvent3);
    streamEvent3.setNext(streamEvent4);
    StreamEventPool streamEventPool = new StreamEventPool(0, 0, 3, 5);
    ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventPool);
    streamEventChunk.convertAndAssign(streamEvent1);
    while (streamEventChunk.hasNext()) {
        streamEventChunk.next();
        streamEventChunk.remove();
    }
    AssertJUnit.assertNull(streamEventChunk.getFirst());
}
Also used : ConversionStreamEventChunk(org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) StreamEventPool(org.ballerinalang.siddhi.core.event.stream.StreamEventPool) Test(org.testng.annotations.Test)

Aggregations

ConversionStreamEventChunk (org.ballerinalang.siddhi.core.event.stream.converter.ConversionStreamEventChunk)7 StreamEvent (org.ballerinalang.siddhi.core.event.stream.StreamEvent)6 StreamEventPool (org.ballerinalang.siddhi.core.event.stream.StreamEventPool)6 Test (org.testng.annotations.Test)6 StreamEventConverter (org.ballerinalang.siddhi.core.event.stream.converter.StreamEventConverter)1