List
Provides examples on basic list functions provided via siddhi-execution-list extension.
For information of performing scatter and gather using list:tokenize()
, and list:collect()
refer the examples in Data Pipelining section. For information on all list functions, refer the Siddhi APIs.
define stream ProductComboStream (
product1 string, product2 string, product3 string);
@info(name = 'Create-list')
from ProductComboStream
select list:create(product1, product2, product3)
as productList
insert into NewListStream;
@info(name = 'Check-list')
from NewListStream
select list:isList(productList) as isList,
list:contains(productList, 'Cake')
as isCakePresent,
list:isEmpty(productList) as isEmpty,
list:get(productList, 1) as valueAt1,
list:size(productList) as size
insert into ListAnalysisStream;
@info(name = 'Clone-and-update')
from NewListStream
select list:remove(
list:add(list:clone(productList), "Toffee"),
"Cake") as productList
insert into UpdatedListStream;
|
Defines |
|
|
|
Create a list with values of |
|
|
|
|
|
Check if |
|
Check if |
|
Check if |
|
Get the value at index |
|
Get size of |
|
|
|
|
|
Clone |
|
Input
Below event is sent to ProductComboStream
,
['Ice Cream'
, 'Chocolate'
, 'Cake'
]
Output
After processing, the following events will be arriving at each stream:
- NewListStream:
[[Ice Cream, Chocolate, Cake]
] - ListAnalysisStream:
[true
,true
,false
,Chocolate
,3
] - UpdatedListStream:
[[Ice Cream, Chocolate, Toffee]
]