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

Commit

Permalink
adding sample for json-mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
minudika committed May 16, 2017
1 parent b3bf31e commit 70118cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/samples/artifacts/0008/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1. Copy {WSO2DASHome}/samples/0008/json-mapper-sample.siddhi file to {WSO2DASHome}/deployment/siddhi-files

2. Start the worker using ./{WSO2DASHome}/bin/worker.sh

3. Navigate to {WSO2DASHome}/samples/sample-clients/tcp-client and run ant command without arguments
29 changes: 29 additions & 0 deletions modules/samples/artifacts/0008/json-mapper-sample.siddhi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@Plan:name("SmartHomePlan")

@sink(type='tcp', context='UsageStream', port='9893',
@map(type='passThrough'))
define stream InputStream (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}},
"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 UsageStream (houseId int, maxVal float, minVal float, avgVal double);

from InputStream
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 70118cf

Please sign in to comment.