Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of the issue when removal of the last event in the InMemory table… #1844

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public void remove() {
}
if (previousToLastReturned != null) {
previousToLastReturned.setNext(lastReturned.getNext());
if (lastReturned.getNext() == null) {
last = previousToLastReturned;
}
} else {
first = lastReturned.getNext();
if (first == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,61 @@ public void receive(Event[] events) {

}

@Test
public void deleteFromTableTest6() throws InterruptedException {
log.info("deleteFromTableTest6");

SiddhiManager siddhiManager = new SiddhiManager();

String streams = "" +
"define stream StockStream (symbol string, price float, vol long); " +
"define stream DeleteStockStream (symbol string, price float, vol long); " +
"define stream CountStockStream (symbol string); " +
"define table StockTable (symbol string, price float, volume long); ";
String query = "" +
"@info(name = 'query1') " +
"from StockStream " +
"select symbol, price, vol as volume " +
"insert into StockTable ;" +
"" +
"@info(name = 'query2') " +
"from DeleteStockStream[vol>=100] " +
"delete StockTable " +
" on StockTable.symbol==symbol ;" +
"" +
"@info(name = 'query3') " +
"from CountStockStream#window.length(0) join StockTable" +
" on CountStockStream.symbol==StockTable.symbol " +
"select CountStockStream.symbol as symbol " +
"insert into CountResultsStream ;";

SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query);

InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream");
InputHandler deleteStockStream = siddhiAppRuntime.getInputHandler("DeleteStockStream");
InputHandler countStockStream = siddhiAppRuntime.getInputHandler("CountStockStream");

siddhiAppRuntime.addCallback("CountResultsStream", new StreamCallback() {
@Override
public void receive(Event[] events) {
EventPrinter.print(events);
inEventCount += events.length;
}
});
siddhiAppRuntime.start();

stockStream.send(new Object[]{"WSO2", 55.6f, 100L});
stockStream.send(new Object[]{"IBM", 75.6f, 100L});
// Remove last event in the StockTable
deleteStockStream.send(new Object[]{"IBM", 57.6f, 100L});

stockStream.send(new Object[]{"WSO2", 57.6f, 100L});
countStockStream.send(new Object[]{"WSO2"});

Thread.sleep(500);
AssertJUnit.assertEquals(2, inEventCount);
siddhiAppRuntime.shutdown();

}

}