Re:Scalable Stream Processing: A Survey of Storm, Samza, Spa...
by nl on Tuesday September 20, 2016 @07:14AM
(#12538578)
Spark has sliding window operations:
windowedWordCounts = pairs.reduceByKeyAndWindow(lambda x, y: x + y, lambda x, y: x - y, 30, 10)
Search for "window operations" on http://spark.apache.org/docs/latest/streaming-programming-gu.... Unless you meant something different?You can replay streams against Spark, too. streamingContext.textFileStream will stream data from files dumped in a directory - to replay them, just dump them there again.
Re:Scalable Stream Processing: A Survey of Storm, Samza, Spa...
by justinsaccount on Tuesday September 20, 2016 @02:10PM
(#12541779)
Yeah.. that's exactly what I used in the spark version i threw together yesterday.
reduceByKeyAndWindow is what my simple non-spark proof of concept is missing. otherwise the code is basically the same.
my non spark code is essentially
while True:
data = {}
for line in input:
rec = parse(line)
data = aggregate(data, rec)
data = filter(is_bad, data)
pprint(data)
the spark version is 99% the same code: lines.map(parse).reduceByKeyAndWindow(add, sub, 3600, 60).
filter(is_bad).pprint()
Figuring out how to do stateful processing is a little tricky, but updateStateByKey seems to do what i need.. I need to dedup the output per key for time period t. Though, some recommendations are just to use something like redis or memcached which would work.
The ability to run the data pipeline in realtime but also replay older data against new code using something like kafka would be a huge plus.
Really the main thing my code is missing is the sliding window implementation, so I can either port to spark streaming which has all that stuff built in, or just implement my own window code.