Join - Example 3
Temperature and Pressure STREAMS Joining in Active-Passive Mode [ 2 and 4 mode ]
Example
Same as previous problem, let's see the output.
Let's define the schema first.
{
"schema":"myschema",
"streams":[
{
"name":"temp_stream",
"type":1,
"swsz":81600,
"inpt":[
],
"attr":[
{
"name":"temp",
"type":11
},
{
"name":"point",
"type":9
}
],
"join":[
{
"name":"temp_pressure_join",
"type":2,
"tloc":300,
"iatr":[
"temp",
"point"
],
"rstm":"pressure_stream",
"ratr":[
"pressure"
],
"jqry":{
"cond":[
"point"
],
"opid":11,
"args":[
"point"
]
},
"ostm":"temp_pressure_stream"
}
]
},
{
"name":"pressure_stream",
"type":1,
"inpt":[
],
"attr":[
{
"name":"pressure",
"type":11
},
{
"name":"point",
"type":9
}
],
"join":[
{
"name":"temp_pressure_join",
"type":4,
"tloc":300,
"ratr":[
"temp",
"point"
],
"rstm":"temp_stream",
"iatr":[
"pressure"
],
"jqry":{
"cond":[
"point"
],
"opid":11,
"args":[
"point"
]
},
"ostm":"temp_pressure_stream"
}
]
},
{
"name":"temp_pressure_stream",
"type":3,
"inpt":[
"temp_stream",
"pressure_stream"
],
"attr":[
{
"name":"point",
"type":9
},
{
"name":"temp",
"type":11
},
{
"name":"pressure",
"type":11
}
]
}
]
}
Here is the output:
put [ temp_stream ] : {"temp":70.1, "point":1}
put [ pressure_stream ] : {"pressure":10.2, "point":2}
put [ pressure_stream ] : {"pressure":11.1, "point":1}
put [ pressure_stream ] : {"pressure":11.5, "point":1}
put [ pressure_stream ] : {"pressure":11.8, "point":1}
put [ temp_stream ] : {"temp":71.1, "point":2}
put [ pressure_stream ] : {"pressure":11.9, "point":1}
put [ pressure_stream ] : {"pressure":12.1, "point":2}
put [ temp_stream ] : {"temp":71.2, "point":1}
put [ pressure_stream ] : {"pressure":12.5, "point":1}
Here is the data in the temp stream:
{
"temp":70.10000000000001,
"point":1,
"_pk":1584946101515817,
"_v":1
}
{
"temp":71.10000000000001,
"point":2,
"_pk":1584946101611668,
"_v":1
}
{
"temp":71.2,
"point":1,
"_pk":1584946101674582,
"_v":1
}
Here is the data in the pressure stream:
{
"pressure":10.2,
"point":2,
"_pk":1584946101526004,
"_v":1
}
{
"pressure":11.1,
"point":1,
"_pk":1584946101540463,
"_v":1
}
{
"pressure":11.5,
"point":1,
"_pk":1584946101562172,
"_v":1
}
{
"pressure":11.8,
"point":1,
"_pk":1584946101579064,
"_v":1
}
{
"pressure":11.9,
"point":1,
"_pk":1584946101632106,
"_v":1
}
{
"pressure":12.1,
"point":2,
"_pk":1584946101643448,
"_v":1
}
{
"pressure":12.5,
"point":1,
"_pk":1584946101705836,
"_v":1
}
----------scan for stream [ pressure_stream : 836447675855282773 ]
fetched = 7;
{
"pressure":11.1,
"_pk":1584946101540463,
"temp":70.10000000000001,
"point":1,
"_jpk1":1584946101515817,
"_v":1
}
{
"pressure":11.5,
"_pk":1584946101562172,
"temp":70.10000000000001,
"point":1,
"_jpk1":1584946101515817,
"_v":1
}
{
"pressure":11.8,
"_pk":1584946101579064,
"temp":70.10000000000001,
"point":1,
"_jpk1":1584946101515817,
"_v":1
}
{
"pressure":12.1,
"_pk":1584946101643448,
"temp":71.10000000000001,
"point":2,
"_jpk1":1584946101611668,
"_v":1
}
{
"pressure":12.5,
"_pk":1584946101705836,
"temp":71.2,
"point":1,
"_jpk1":1584946101674582,
"_v":1
}