Java Code Examples for io.siddhi.query.api.execution.query.Query#updateBy()
The following examples show how to use
io.siddhi.query.api.execution.query.Query#updateBy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableQueryTestCase.java From siddhi with Apache License 2.0 | 6 votes |
@Test public void testCreatingUpdateByQuery() { Query query = Query.query(); query.from( InputStream.stream("cseEventStream"). filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value (9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume") ) ) ).window("lengthBatch", Expression.value(50)) ); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("price", Expression.variable("price")) ); query.updateBy("StockQuote", Expression.compare( Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote"))); }
Example 2
Source File: SimpleQueryTestCase.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void test15() { Query queryString = SiddhiCompiler.parseQuery("" + "from StockStream[7+9.5 > price and 100 >= volume]#window.length(50) " + " " + "select symbol as symbol, price as price, volume as volume " + "update StockQuote \n " + " on symbol==StockQuote.symbol ;" ); AssertJUnit.assertNotNull(queryString); Query query = Query.query(); query.from( InputStream.stream("StockStream"). filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value (9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume") ) ) ).window("length", Expression.value(50)) ); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("price", Expression.variable("price")). select("volume", Expression.variable("volume")) ); query.updateBy("StockQuote", OutputStream.OutputEventType.CURRENT_EVENTS, Expression.compare( Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote"))); AssertJUnit.assertEquals(query, queryString); }
Example 3
Source File: TableQueryTestCase.java From siddhi with Apache License 2.0 | 5 votes |
@Test public void testCreatingUpdateByTypeQuery() { Query query = Query.query(); query.from( InputStream.stream("cseEventStream"). filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value (9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume") ) ) ).window("lengthBatch", Expression.value(50)) ); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("price", Expression.variable("price")). select("volume", Expression.variable("volume")) ); query.updateBy("StockQuote", OutputStream.OutputEventType.ALL_EVENTS, UpdateStream.updateSet(). set( Expression.variable("price").ofStream("StockQuote"), Expression.variable("price")). set( Expression.variable("volume").ofStream("StockQuote"), Expression.variable("volume")), Expression.compare( Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote"))); }
Example 4
Source File: SimpleQueryTestCase.java From siddhi with Apache License 2.0 | 4 votes |
@Test public void test10() { Query queryString = SiddhiCompiler.parseQuery("" + "from StockStream[7+9.5 > price and 100 >= volume]#window.length(50) " + " " + "select symbol as symbol, price as price, volume as volume " + "update StockQuote \n " + " set StockQuote.price = price, \n " + " StockQuote.volume = volume " + " on symbol==StockQuote.symbol ;" ); AssertJUnit.assertNotNull(queryString); Query query = Query.query(); query.from( InputStream.stream("StockStream"). filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value (9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume") ) ) ).window("length", Expression.value(50)) ); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("price", Expression.variable("price")). select("volume", Expression.variable("volume")) ); query.updateBy("StockQuote", OutputStream.OutputEventType.CURRENT_EVENTS, UpdateStream.updateSet(). set( Expression.variable("price").ofStream("StockQuote"), Expression.variable("price")). set( Expression.variable("volume").ofStream("StockQuote"), Expression.variable("volume")), Expression.compare( Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote"))); AssertJUnit.assertEquals(query, queryString); }
Example 5
Source File: SimpleQueryTestCase.java From siddhi with Apache License 2.0 | 4 votes |
@Test public void test14() { Query queryString = SiddhiCompiler.parseQuery("" + "from StockStream[7+9.5 > price and 100 >= volume]#window.length(50) " + " " + "select symbol as symbol, price as price, volume as volume " + "update StockQuote \n " + " set StockQuote.price = price, \n " + " StockQuote.volume = volume " + " on symbol==StockQuote.symbol ;" ); AssertJUnit.assertNotNull(queryString); Query query = Query.query(); query.from( InputStream.stream("StockStream"). filter(Expression.and(Expression.compare(Expression.add(Expression.value(7), Expression.value (9.5)), Compare.Operator.GREATER_THAN, Expression.variable("price")), Expression.compare(Expression.value(100), Compare.Operator.GREATER_THAN_EQUAL, Expression.variable("volume") ) ) ).window("length", Expression.value(50)) ); query.select( Selector.selector(). select("symbol", Expression.variable("symbol")). select("price", Expression.variable("price")). select("volume", Expression.variable("volume")) ); query.updateBy("StockQuote", UpdateStream.updateSet(). set( Expression.variable("price").ofStream("StockQuote"), Expression.variable("price")). set( Expression.variable("volume").ofStream("StockQuote"), Expression.variable("volume")), Expression.compare( Expression.variable("symbol"), Compare.Operator.EQUAL, Expression.variable("symbol").ofStream("StockQuote"))); AssertJUnit.assertEquals(query, queryString); }