Skip to main content

List

This extension provides capability to generate and manipulate list data objects.

Features

collect

Collects multiple values to construct a list.

Syntax

<OBJECT> list:collect(<OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)
<OBJECT> list:collect(<OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value, <BOOL> is.distinct)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
valueValue of the list elementOBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes
is.distinctIf true only distinct elements are collectedfalseBOOLYesYes

Examples EXAMPLE 1

insert into OutputStream
select list:collect(symbol) as stockSymbols
from StockStream#window.lengthBatch(10);

For the window expiry of 10 events, the collect() function will collect attributes of symbol to a single list and return as stockSymbols.

merge

Collects multiple lists to merge as a single list.

Syntax

<OBJECT> list:merge(<OBJECT> list)
<OBJECT> list:merge(<OBJECT> list, <BOOL> is.distinct)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listList to be mergedOBJECTNoYes
is.distinctWhether to return list with distinct valuesfalseBOOLYesYes

Examples EXAMPLE 1

insert into OutputStream
select list:merge(list) as stockSymbols
from StockStream#window.lengthBatch(2);

For the window expiry of 2 events, the merge() function will collect attributes of list and merge them to a single list, returned as stockSymbols.

add

Function returns the updated list after adding the given value.

Syntax

<OBJECT> list:add(<OBJECT> list, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)
<OBJECT> list:add(<OBJECT> list, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value, <INT> index)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list to which the value should be added.OBJECTNoYes
valueThe value to be added.OBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes
indexThe index in which the value should to be added.lastINTYesYes

Examples EXAMPLE 1

list:add(stockSymbols, 'IBM')

Function returns the updated list after adding the value IBM in the last index.

EXAMPLE 2

list:add(stockSymbols, 'IBM', 0)

Function returns the updated list after adding the value IBM in the 0th index.

addAll

Function returns the updated list after adding all the values from the given list.

Syntax

<OBJECT> list:addAll(<OBJECT> to.list, <OBJECT> from.list)
<OBJECT> list:addAll(<OBJECT> to.list, <OBJECT> from.list, <BOOL> is.distinct)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
to.listThe list into which the values need to copied.OBJECTNoYes
from.listThe list from which the values are copied.OBJECTNoYes
is.distinctIf true returns list with distinct valuesfalseBOOLYesYes

Examples EXAMPLE 1

list:putAll(toList, fromList)

If toList contains values ('IBM', 'GDN'), and if fromList contains values ('IBM', 'XYZ') then the function returns updated toList with values ('IBM', 'GDN', 'IBM', 'XYZ').

EXAMPLE 2

list:putAll(toList, fromList, true)

If toList contains values ('IBM', 'GDN'), and if fromList contains values ('IBM', 'XYZ') then the function returns updated toList with values ('IBM', 'GDN', 'XYZ').

clear

Function returns the cleared list.

Syntax

<OBJECT> list:clear(<OBJECT> list)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list which needs to be clearedOBJECTNoYes

Examples EXAMPLE 1

list:clear(stockDetails)

Returns an empty list.

clone

Function returns the cloned list.

Syntax

<OBJECT> list:clone(<OBJECT> list)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list to which needs to be cloned.OBJECTNoYes

Examples EXAMPLE 1

list:clone(stockSymbols)

Function returns cloned list of stockSymbols.

contains

Function checks whether the list contains the specific value.

Syntax

<BOOL> list:contains(<OBJECT> list, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list that needs to be checked on whether it contains the value or not.OBJECTNoYes
valueThe value that needs to be checked.OBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes

Examples EXAMPLE 1

list:contains(stockSymbols, 'IBM')

Returns true if the stockSymbols list contains value IBM else it returns false.

containsAll

Function checks whether the list contains all the values in the given list.

Syntax

<BOOL> list:containsAll(<OBJECT> list, <OBJECT> given.list)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list that needs to be checked on whether it contains all the values or not.OBJECTNoYes
given.listThe list which contains all the values to be checked.OBJECTNoYes

Examples EXAMPLE 1

list:containsAll(stockSymbols, latestStockSymbols)

Returns true if the stockSymbols list contains values in latestStockSymbols else it returns false.

create

Function creates a list containing all values provided.

Syntax

<OBJECT> list:create()
<OBJECT> list:create(<OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value1)
<OBJECT> list:create(<OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value1, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> ...)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
value1Value 1OBJECT INT LONG FLOAT DOUBLE BOOL STRINGYesYes

Examples EXAMPLE 1

list:create(1, 2, 3, 4, 5, 6)

This returns a list with values 1, 2, 3, 4, 5 and 6.

EXAMPLE 2

list:create()

This returns an empty list.

get

Function returns the value at the specific index, null if index is out of range.

Syntax

<OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> list:get(<OBJECT> list, <INT> index)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listAttribute containing the listOBJECTNoYes
indexIndex of the elementINTNoYes

Examples EXAMPLE 1

list:get(stockSymbols, 1)

This returns the element in the 1st index in the stockSymbols list.

indexOf

Function returns the last index of the given element.

Syntax

<INT> list:indexOf(<OBJECT> list, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list to be checked to get index of an element.OBJECTNoYes
valueValue for which last index needs to be identified.OBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes

Examples EXAMPLE 1

list:indexOf(stockSymbols. `IBM`)

Returns the last index of the element IBM if present else it returns -1.

isEmpty

Function checks if the list is empty.

Syntax

<BOOL> list:isEmpty(<OBJECT> list)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list that needs to be checked whether it's empty or not.OBJECTNoYes

Examples EXAMPLE 1

list:isEmpty(stockSymbols)

Returns true if the stockSymbols list is empty else it returns false.

isList

Function checks if the object is type of a list.

Syntax

<BOOL> list:isList(<OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> arg)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
argThe argument the need to be determined whether it's a list or not.OBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes

Examples EXAMPLE 1

list:isList(stockSymbols)

Returns true if the stockSymbols is and an instance of java.util.List else it returns false.

lastIndexOf

Function returns the index of the given value.

Syntax

<INT> list:lastIndexOf(<OBJECT> list, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list to be checked to get index of an element.OBJECTNoYes
valueValue for which last index needs to be identified.OBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes

Examples EXAMPLE 1

list:lastIndexOf(stockSymbols. `IBM`)

Returns the last index of the element IBM if present else it returns -1.

remove

Function returns the updated list after removing the element with the specified value.

Syntax

<OBJECT> list:remove(<OBJECT> list, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list that needs to be updated.OBJECTNoYes
valueThe value of the element that needs to removed.OBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes

Examples EXAMPLE 1

list:remove(stockSymbols, 'IBM')

This returns the updated list, stockSymbols after stockSymbols the value IBM.

removeAll

Function returns the updated list after removing all the element with the specified list.

Syntax

<OBJECT> list:removeAll(<OBJECT> list, <OBJECT> given.list)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list that needs to be updated.OBJECTNoYes
given.listThe list with all the elements that needs to removed.OBJECTNoYes

Examples EXAMPLE 1

list:removeAll(stockSymbols, latestStockSymbols)

This returns the updated list, stockSymbols after removing all the values in latestStockSymbols.

removeByIndex

Function returns the updated list after removing the element with the specified index.

Syntax

<OBJECT> list:removeByIndex(<OBJECT> list, <INT> index)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list that needs to be updated.OBJECTNoYes
indexThe index of the element that needs to removed.INTNoYes

Examples EXAMPLE 1

list:removeByIndex(stockSymbols, 0)

This returns the updated list, stockSymbols after removing value at 0 th index.

retainAll

Function returns the updated list after retaining all the elements in the specified list.

Syntax

<OBJECT> list:retainAll(<OBJECT> list, <OBJECT> given.list)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list that needs to be updated.OBJECTNoYes
given.listThe list with all the elements that needs to reatined.OBJECTNoYes

Examples EXAMPLE 1

list:retainAll(stockSymbols, latestStockSymbols)

This returns the updated list, stockSymbols after retaining all the values in latestStockSymbols.

setValue

Function returns the updated list after replacing the element in the given index by the given value.

Syntax

<OBJECT> list:setValue(<OBJECT> list, <INT> index, <OBJECT|INT|LONG|FLOAT|DOUBLE|BOOL|STRING> value)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list to which the value should be updated.OBJECTNoYes
indexThe index in which the value should to be updated.INTNoYes
valueThe value to be updated with.OBJECT INT LONG FLOAT DOUBLE BOOL STRINGNoYes

Examples EXAMPLE 1

list:set(stockSymbols, 0, 'IBM')

Function returns the updated list after replacing the value at 0th index with the value IBM

size

Function to return the size of the list.

Syntax

<INT> list:size(<OBJECT> list)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list for which size should be returned.OBJECTNoYes

Examples EXAMPLE 1

list:size(stockSymbols)

Returns size of the stockSymbols list.

sort

Function returns lists sorted in ascending or descending order.

Syntax

<OBJECT> list:sort(<OBJECT> list)
<OBJECT> list:sort(<OBJECT> list, <STRING> order)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listThe list which should be sorted.OBJECTNoYes
orderOrder in which the list needs to be sorted (ASC/DESC/REV).REVSTRINGYesNo

Examples EXAMPLE 1

list:sort(stockSymbols)

Function returns the sorted list in ascending order.

EXAMPLE 2

list:sort(stockSymbols, 'DESC')

Function returns the sorted list in descending order.

tokenize

Tokenize the list and return each key, value as new attributes in events

Syntax

list:tokenize(<OBJECT> list)
list:tokenize(<OBJECT> list, <OBJECT> ...)

QUERY PARAMETERS

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
listArray list which needs to be tokenizedOBJECTNoYes

Extra Return Attributes

NameDescriptionPossible Types
indexIndex of an entry consisted in the listINT
valueValue of an entry consisted in the listOBJECT

Examples EXAMPLE 1

list:tokenize(customList)

If custom list contains ('GDN', 'IBM', 'XYZ') elements, then tokenize function will return 3 events with value attributes GDN, IBM and XYZ respectively.