Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #157 from minudika/master
Browse files Browse the repository at this point in the history
updating json-mapper sample
  • Loading branch information
gokul authored May 17, 2017
2 parents 5f20840 + 6e3a5f3 commit 80271d6
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions modules/samples/artifacts/0008/json-mapper-sample.siddhi
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
@Plan:name("SmartHomePlan")

@sink(type='tcp', context='UsageStream', port='9893',
@source(type='tcp', context='SmartHomeData', port='9892',
@map(type='passThrough'))
define stream InputStream (houseId int, maxVal float, minVal float, avgVal double);
define stream SmartHomeData (houseId int, maxVal float, minVal float, avgVal double);

@source(type='InMemory', topic='home', @map(type='json',
enclosing.element="portfolio", @attributes(symbol ="stock.company.symbol", price = "stock.price", volume = "stock.volume")))
define stream InMemorySmartHomeInputData (houseId int, maxVal float, minVal float, avgVal double);
@sink(type='inMemory', topic='home', @map(type='json', @payload("{"portfolio":{
"StockData": {
"houseId":{{houseIdl}},
@sink(type='inMemory', topic='home', @map(type='json', @payload("""{"portfolio":{
"stock": {
"houseId":{{houseId}},
"maxVal": {{maxVal}},
"minVal": {{minVal}},
"avgVal": {{avgVal}}
}
}}")))
@source(type='InMemory', topic='home', @map(type='json',
enclosing.element="portfolio", @attributes(symbol ="stock.symbol", price = "stock.price", volume = "stock.volume")))
}}""")))
define stream InMemorySmartHomeInputData (houseId int, maxVal float, minVal float, avgVal double);

@source(type='inMemory', topic='home', @map(type='json',
enclosing.element="portfolio", @attributes(houseId ="stock.houseId", maxVal = "stock.maxVal", minVal = "stock.minVal", avgVal = "stock.avgVal")))
define stream UsageStream (houseId int, maxVal float, minVal float, avgVal double);

from InputStream
from SmartHomeData
select *
insert into InMemorySmartHomeInputData;

from InMemorySmartHomeInputData#log("Event")
select houseId as houseId, max(value) as maxVal, min(value) as minVal, avg(value) as avgVal
group by houseId
insert into UsageStream;

0 comments on commit 80271d6

Please sign in to comment.