Created
October 14, 2014 11:04
-
-
Save thomasdarimont/501611a4772a8bb1959f to your computer and use it in GitHub Desktop.
PoC Sketch of an DSL for XD.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event{ | |
long ts; | |
int h; | |
int hh; | |
int p; | |
int property; | |
double value; | |
} | |
class LoadEvent extends Event{ | |
//... | |
} | |
class WorkEvent extends Event{ | |
//... | |
} | |
def eventForType(Event event){ | |
switch(event.property){ | |
case 0 : return new WorkEvent(event) | |
case 1 : return new LoadEvent(event) | |
default: return event | |
} | |
} | |
Composite SmartGrid{ | |
Stream smartGridIngestion(Event event) { | |
http(port=9000) | |
transform(eventForType) | |
filter(expression=event instanceof LoadEvent) | |
hdfs() | |
} | |
Stream loadStream(LoadEvent event){ | |
aggregateCounter(name="smartgrid_{e.h}_{e.hh}_{e.p}_load_actual", timeStamp=event.ts, aggregate=event.value/60) | |
} | |
Tap loadPrediction(on=smartGridIngestion.filter){ | |
predict(model=loadPrediction.pmml, output=(event["load_predicted"]=prediction["predicted_load"]; event)) | |
aggregateCounter(name="smartgrid_{e.h}_{e.hh}_{e.p}_load_predicted", timeStamp=event.ts, aggregate=event.value/60) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment