Basic Types
Provides introduction to basic Siddhi attribute types which are int
, long
, float
, double
, string
, and object
, and some key functions such as convert()
, instanceOf...()
, and cast()
.
In Siddhi, other types such as list, map, etc, should be passed as object
into streams. For more information on other types refer other examples under Values and Types section.
For information values, and other useful functions, refer the Siddhi query guide.
define stream PatientRegistrationInputStream (
seqNo long, name string, age int,
height float, weight double, photo object,
isEmployee bool, wardNo object);
define stream PatientRegistrationStream (
seqNo long, name string, age int,
height double, weight double, photo object,
isPhotoString bool, isEmployee bool,
wardNo int);
@info(name = 'Type-processor')
from PatientRegistrationInputStream
select seqNo, name, age,
convert(height, 'double') as height,
weight, photo,
instanceOfString(photo) as isPhotoString,
isEmployee,
cast(wardNo, 'int') as wardNo
insert into PatientRegistrationStream;
|
Defines |
|
Defines the resulting |
|
|
|
|
|
|
|
|
|
|
|
|
|
Input
Below event is sent to PatientRegistrationInputStream
,
[1200098
, 'Peter Johnson'
, 34
, 194.3f
, 69.6
, #Fjoiu59%3hkjnknk$#nFT
, true
, 34
]
Here, assume that the content of the photo (#Fjoiu59%3hkjnknk$#nFT
) is binary.
Output
After processing, the event arriving at PatientRegistrationStream
will be as follows:
[1200098
, 'Peter Johnson'
, 34
, 194.3
, 69.6
, #Fjoiu59%3hkjnknk$#nFT
, false
, true
, 34
]