SlideShare a Scribd company logo
1 of 57
Download to read offline
Scala Functional Message
Processing: LambdaFlow
John Nestor 47 Degrees
www.47deg.com
https://github.com/47deg/LambdaFlow
May 9, 2017
147deg.com
47deg.com © Copyright 2017 47 Degrees
Outline
• Introduction
• Examples
• Simple
• Windowing
• Indexing and Query
• Graph
• Temperature
• Page Rank
• Questions
2
Introduction
3
47deg.com © Copyright 2017 47 Degrees
Inspiration
• Wanted to build a reactive system using Akka clustering
• Don’t like Spark micro-batching, want message at a time
• Want a Scala functional DSL, like the Spark Scala DSL
4
47deg.com © Copyright 2017 47 Degrees
LambdaFlow
• Near-real-time message processing
• Message at a time
• Both set (create or update) and delete
• Written in Scala and Akka
• Two parts:
• Functional DSL
• Akka Cluster reactive implementation
5
47deg.com © Copyright 2017 47 Degrees
LambdaFlow Use Cases
• * Near real time streaming with infinite stream
• Finite streams
• Batch processing
• Input and outputs via
• files
• API
• Kafka
• …
6
47deg.com © Copyright 2017 47 Degrees
Possible Use Case
7
LambdaFlow
...
Kafka In 1
Kafka In 2
Kafka In M Kafka Out N
Kafka Out 2
Kafka Out 1
...
47deg.com © Copyright 2017 47 Degrees
Functional DSL
• Directed graph
• Strongly typed
• Graph nodes are actions
• Graph arcs are paths for message passing
• Graph can contain cycles
8
47deg.com © Copyright 2017 47 Degrees
Key-Value Model
• (most) Actions contain an in-memory Key-Value
HashMap[K,V]
• Two messages
• Set/Update Key:k1 to Value:v1
• Delete Key-Value pair for Key:k1
9
47deg.com © Copyright 2017 47 Degrees
Combining Actions
• Most actions have
• Input: used to set or delete keys in KV store
• Output: used to set or delete keys on next action
• Operation: maps KV of this action to KV of next action
10
47deg.com © Copyright 2017 47 Degrees
Functional Eventual Consistency
• Two Actions A1[K1,V1] and A2[K2,V2]
• Each have a KV store: A1.kv[K1,V1] and A2.kv[K2,V2]
• the output of A1 is the input to A2
• A1 has an operation A1.f that maps 

[K1,V1] => Set([K2,V2])
• If all changes to A1 are stopped, eventually
• A2.kv = A1.kv.flatMap(A1.f)
11
47deg.com © Copyright 2017 47 Degrees
Incremental Operation
• Suppose an action has k1->v1 and we now set k1->v2
• To update the next action
• Undo the effect of k1->v1
• Do the effect of k1->v2
12
47deg.com © Copyright 2017 47 Degrees
Incremental Operation Example
• Suppose action KV type is String=>String
• If we change “A”->”B” to “A”->”C”
• Operation example 1 (map): (k,v)=>(k+v,v+v)
• Delete “AB”->”BB”
• Set “AC”=> “CC”
• Operation example 2(mapvalue): (k,v) => (k,v+v)
• Delete “A” -> “BB” (not needed here)
• Set “A” -> “CC”
13
47deg.com © Copyright 2017 47 Degrees
Implementations
• Class based
• Uses method calls rather than actor messages
• Local Akka Actor based
• Akka Cluster Based
• Multinode
• Reactive: scalable, responsive, fault-tolerant
14
Simple Example
15
47deg.com © Copyright 2017 47 Degrees
Simple Example
• Input data:
• 8328 Tweets
• Look at input data (capture.json)
• Count number of tweets in each language
• Use method calls between actions
16
47deg.com © Copyright 2017 47 Degrees
Simple Example
17
(Lang,UID) => ()
Src
Sink
Reduce Sum Per Lang
Lang => Count
Map
UID => Lang
47deg.com © Copyright 2017 47 Degrees
Simple Example Code
val src = Source[String, String]("src")

val counts = Sink[String, Long]("counts")



val f1 = src

.map("map",(uid,lang)=>((uid,lang),()))

.reduce("red", _._2, (k, v) => 1L, LongSum)

.sink(counts)



run(f1)
18
47deg.com © Copyright 2017 47 Degrees
Source and Sink Actions
• Source[K,V]
• gets input from outside the graph (e.g. Kafka)
• outputs to other actions
• Sink[K,V]
• gets it input from other actions
• outputs to outside the graph (e.g. Kafka)
19
47deg.com © Copyright 2017 47 Degrees
Map Operation
• Action input type K,V
• Action output type KOUT,VOUT
• Action function type: (K,V)=>(KOUT,VOUT)
20
47deg.com © Copyright 2017 47 Degrees
Reduce Operation
• Action input type K,V
• Action output type KOUT,VOUT
• Grouping function type: K=>KOUT (many to one)
• Value function type: (K,V)=>VOUT
• Reduce operation type (VOUT,VOUT)=>VOUT
• commutative, associative and inverse (abelian group)
21
47deg.com © Copyright 2017 47 Degrees
Simple Example
• Run it (demo.simple)
• Look at code (Simple.scala)
22
Windowing Example
23
47deg.com © Copyright 2017 47 Degrees
Windowing Example
• Streaming Data
• 1000 Tweets
• sent in at ~20 per second
• each tweet expires after 20 seconds
• Count languages and find 20 most common words
• Uses local actor implementation
• Uses Vaadin based visualization tool
24
47deg.com © Copyright 2017 47 Degrees
Windowing Example
25
Lang
Count
Reduce Txt
Total Percent Words
Join
Map
FlatMap
MapReduce
Reduce
First
Map
47deg.com © Copyright 2017 47 Degrees
Windowing Example Code
val f1 = src

.reduce("red", _._1, (k, v) => 1L, LongSum)

.to(counts1, counts2)

.sink(counts)



val f2 = counts1

.reduce("red1", _ => List.empty[String], (k, v) => v, LongSum)

.map[String, Long]("map1", (k, v) => ("total", v))

.to(total1)

.sink(total)



val f3 = counts2

.join[String, Long, Unit, String, String]("product", total1, (s:String)=>(), (s:String)=>()) {

case (lang, count, t, total) => Set((lang, f"${count * 100 / total}%02d$PERCENT"))

}

.sink(percent)



val f4 = text

.flatMap("GetWords", (k, v) => {

val (text, uuid) = k

getWords(text)

.zipWithIndex

.map {

case (word, i) => ((word, uuid, i), ())

}

.toSet

})

.map("CountOrder", (word, count) => ((-count, word), ()))

.first("first", 20)

.map("CountOrder1", (k, v) => (k._2, f"${-k._1}%4d"))

.sink(words)
run(f1, f2, f3, f4)
26
47deg.com © Copyright 2017 47 Degrees
Labels,To and From
• Label[K,V]: used to connect an action output to another
action input
• .to[K,V]: send one input to multiple outputs (broadcast)
• .from[K,V]: combine multiple inputs to a single output
(union)
27
47deg.com © Copyright 2017 47 Degrees
FlatMap Action
• Action input type K,V
• Action output type KOUT,VOUT
• Action function type: (K,V)=>Set[(KOUT,VOUT)]
28
47deg.com © Copyright 2017 47 Degrees
First Action
• Action input type K,V
• Action output type K,V
• Count: a small integer
• Output at most count key-values
• those with the lowest keys
• requires type K be ordered
29
47deg.com © Copyright 2017 47 Degrees
Join Action
• Two inputs: K1,V1 and K2,V2
• Two key value stores
• Output types KOUT and VOUT
• Two mapping functions: K1=>K K2=>K (many to one)
• An operation
• Applied to each member of the product of KV pairs
from the two key stores with the same K value
• (K1,V1,K2,V2) => Set[(KOUT,VOUT)]
30
47deg.com © Copyright 2017 47 Degrees
Viewer
31
LambdaFlow
Remote Actor
FlowView
Vaadin
Web BrowserTweets
47deg.com © Copyright 2017 47 Degrees
Windowing Example
• Start up Vaadin viewer and web browser
• Run it (demo.TwitterFlow)
• Look at code (TwitterFlow.scala)
32
Index and Query
Example
33
47deg.com © Copyright 2017 47 Degrees
Index and Query Example
• Input data: Breweries
• look at breweries.data
• Build indexes
• set of breweries at a location (State/Country)
• set of breweries with a key word (in its description)
• use jline3 command hander
34
47deg.com © Copyright 2017 47 Degrees
Index Example
35
Breweries
Reduce
Names Places Words
Map FlatMap
Reduce
47deg.com © Copyright 2017 47 Degrees
Query
• words:Sink[String,Set[Int]]
• words.get(word) => Future[Option[Set[Id]]]
• breweries:Source[Int,String] : id->JsonString
• def name(json:String)=>name (extracts the brewery
name)
• breweries.get(id,name) => Future[Option[String]]
36
Graph Example
37
47deg.com © Copyright 2017 47 Degrees
Input Data:A Directed Graph
38
A
B
C
D
E
F
47deg.com © Copyright 2017 47 Degrees
Graph Example
• Note: there are two graphs
• The input data
• The graph of actions
• Output
• Number of distinct paths between two nodes
• Set of all cycles
• Loop in action graph for transitive closure
• Like recursive function
• Functional semantics is fixed point of loop
39
47deg.com © Copyright 2017 47 Degrees
Graph Transitive Closure
• Given
• route C -> E -> F
• link A -> C
• Form product (Common key = C)
• route C -> E -> F (routes starting at C)
• flipped link C -> A (links ending at C)
• Result
• route A -> C -> E -> F (goes back around loop!)
40
47deg.com © Copyright 2017 47 Degrees
Graph Example
41
Edges
Map
toPath
CyclesRoutes
Join
Link
Map
Route
Map
Invert
Filter
Cyles
Reduce
Count
47deg.com © Copyright 2017 47 Degrees
Graph Example
• Start Vaadin viewer and browser window
• Run example (demo.GraphCycle)
• showCycles
• Look at code
42
47deg.com © Copyright 2017 47 Degrees
Modified Graph
43
A
B
C
D
E
F
47deg.com © Copyright 2017 47 Degrees
Modify Graph
• set F A
• look at browser
• showCycles
• delete F A
• look at browser
• showCycles
44
Temperatures
45
47deg.com © Copyright 2017 47 Degrees
Temperature Grid
46
T1 T2 T3
T4 0,0 1,0 2,0 T7
T5 0,1 1,1 2,1 T8
T6 0,2 1,2 2,2 T9
T10 T11 T12
47deg.com © Copyright 2017 47 Degrees
Computation
47
U
L (U+D+L+R) / 4 R
D
47deg.com © Copyright 2017 47 Degrees
Temp Example
48
Edges
Temps
Map
FlatMap
1 => 4
Map
Reduce
4 => 1
Map
47deg.com © Copyright 2017 47 Degrees
Temperature Result
49
30 20 10
50 35 27 27 50
40 34 27 21 10
30 33 27 20 10
40 30 20
47deg.com © Copyright 2017 47 Degrees
Temperature Change
50
30 20 10
50/10 35/24 27/25 27/28 50
40 34/32 27/29 21/27 10
30 33/34 27/33 20/40 10/80
40 30 20
Page Rank
51
47deg.com © Copyright 2017 47 Degrees
Page Rank Data
52
A B
C
D
E
F
47deg.com © Copyright 2017 47 Degrees
Page Rank Example
53
Edges
Reduce
Rank
Join
Invert
Map
Initial Val
FlatMap
Map
Bias
Reduce
Join
Div by Cnt
Reduce
Sum
Map
Reduce
Select
47deg.com © Copyright 2017 47 Degrees
Page Rank Result
54
1.4 .60
.88
.28
.75
.47
Questions
55
47deg.com © Copyright 2017 47 Degrees
LambdaFlow and Kafka Common Properties
• JVM based
• Integrate with Kafka topics
• Key-value based
• One message at a time
• Operations: map, reduce, …
• Scalable and fault tolerant
• Open source
56
47deg.com © Copyright 2017 47 Degrees
LambdaFlow versus Kafka
57
LambdaFlow Kafka
Akka Cluster Zookeeper
Scala Java
Set/Delete Set
Functional Imperative

More Related Content

What's hot

Geant4 physics validation on the GRID
Geant4 physics validation on the GRIDGeant4 physics validation on the GRID
Geant4 physics validation on the GRIDGeorge Lestaris
 
Building Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreBuilding Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreLevi Fuller
 
Soap UI - Lesson45
Soap UI - Lesson45Soap UI - Lesson45
Soap UI - Lesson45Qualitest
 
Testing in Scala. Adform Research
Testing in Scala. Adform ResearchTesting in Scala. Adform Research
Testing in Scala. Adform ResearchVasil Remeniuk
 
The essential tools for test code quality improvement latest
The essential tools for test code quality improvement   latestThe essential tools for test code quality improvement   latest
The essential tools for test code quality improvement latestSergey Korol
 
Whats new in .NET for 2019
Whats new in .NET for 2019Whats new in .NET for 2019
Whats new in .NET for 2019Rory Preddy
 
Setting Up CircleCI Workflows for Your Salesforce Apps
Setting Up CircleCI Workflows for Your Salesforce AppsSetting Up CircleCI Workflows for Your Salesforce Apps
Setting Up CircleCI Workflows for Your Salesforce AppsDaniel Stange
 
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORSOPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORSMonica Beckwith
 
Functional Reactive Programming (CocoaHeads Bratislava)
Functional Reactive Programming (CocoaHeads Bratislava)Functional Reactive Programming (CocoaHeads Bratislava)
Functional Reactive Programming (CocoaHeads Bratislava)Michal Grman
 
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...COMAQA.BY
 
Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineAdding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineEduardo Piairo
 
Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014dubmun
 
Learn Git form Beginners to Master
Learn Git form Beginners to MasterLearn Git form Beginners to Master
Learn Git form Beginners to MasterC. M. Abdullah Khan
 
Coordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractCoordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractOmri Spector
 
Arquillian & Citrus
Arquillian & CitrusArquillian & Citrus
Arquillian & Citruschristophd
 
Coscup 2013 : Continuous Integration on top of hadoop
Coscup 2013 : Continuous Integration on top of hadoopCoscup 2013 : Continuous Integration on top of hadoop
Coscup 2013 : Continuous Integration on top of hadoopWisely chen
 

What's hot (20)

Load test REST APIs using gatling
Load test REST APIs using gatlingLoad test REST APIs using gatling
Load test REST APIs using gatling
 
Geant4 physics validation on the GRID
Geant4 physics validation on the GRIDGeant4 physics validation on the GRID
Geant4 physics validation on the GRID
 
Building Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET CoreBuilding Blocks of Angular 2 and ASP.NET Core
Building Blocks of Angular 2 and ASP.NET Core
 
Asynchronous apex
Asynchronous apexAsynchronous apex
Asynchronous apex
 
Soap UI - Lesson45
Soap UI - Lesson45Soap UI - Lesson45
Soap UI - Lesson45
 
Testing in Scala. Adform Research
Testing in Scala. Adform ResearchTesting in Scala. Adform Research
Testing in Scala. Adform Research
 
The essential tools for test code quality improvement latest
The essential tools for test code quality improvement   latestThe essential tools for test code quality improvement   latest
The essential tools for test code quality improvement latest
 
Whats new in .NET for 2019
Whats new in .NET for 2019Whats new in .NET for 2019
Whats new in .NET for 2019
 
Setting Up CircleCI Workflows for Your Salesforce Apps
Setting Up CircleCI Workflows for Your Salesforce AppsSetting Up CircleCI Workflows for Your Salesforce Apps
Setting Up CircleCI Workflows for Your Salesforce Apps
 
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORSOPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
OPENJDK: IN THE NEW AGE OF CONCURRENT GARBAGE COLLECTORS
 
Testing your code
Testing your codeTesting your code
Testing your code
 
Functional Reactive Programming (CocoaHeads Bratislava)
Functional Reactive Programming (CocoaHeads Bratislava)Functional Reactive Programming (CocoaHeads Bratislava)
Functional Reactive Programming (CocoaHeads Bratislava)
 
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
 
Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipelineAdding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipeline
 
Gatling
Gatling Gatling
Gatling
 
Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014Legacy Dependency Killer - Utah Code Camp 2014
Legacy Dependency Killer - Utah Code Camp 2014
 
Learn Git form Beginners to Master
Learn Git form Beginners to MasterLearn Git form Beginners to Master
Learn Git form Beginners to Master
 
Coordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud ContractCoordinating Micro-Services with Spring Cloud Contract
Coordinating Micro-Services with Spring Cloud Contract
 
Arquillian & Citrus
Arquillian & CitrusArquillian & Citrus
Arquillian & Citrus
 
Coscup 2013 : Continuous Integration on top of hadoop
Coscup 2013 : Continuous Integration on top of hadoopCoscup 2013 : Continuous Integration on top of hadoop
Coscup 2013 : Continuous Integration on top of hadoop
 

Similar to LambdaFlow: Scala Functional Message Processing

Forge - DevCon 2016: Drawings! Drawings! Everywhere!
Forge - DevCon 2016: Drawings! Drawings! Everywhere!Forge - DevCon 2016: Drawings! Drawings! Everywhere!
Forge - DevCon 2016: Drawings! Drawings! Everywhere!Autodesk
 
Introduction no sql solutions with couchbase and .net core
Introduction no sql solutions with couchbase and .net coreIntroduction no sql solutions with couchbase and .net core
Introduction no sql solutions with couchbase and .net coreBaris Ceviz
 
Technical Debt - SOTR14 - Clarkie
Technical Debt -  SOTR14 - ClarkieTechnical Debt -  SOTR14 - Clarkie
Technical Debt - SOTR14 - ClarkieAndrew Clarke
 
Cincom Roadmap ESUG2014
Cincom Roadmap ESUG2014Cincom Roadmap ESUG2014
Cincom Roadmap ESUG2014ESUG
 
LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017Matthew Beale
 
Introducing Neo4j 3.0
Introducing Neo4j 3.0Introducing Neo4j 3.0
Introducing Neo4j 3.0Neo4j
 
Reaching State Zero Without Losing Your Versions
Reaching State Zero Without Losing Your VersionsReaching State Zero Without Losing Your Versions
Reaching State Zero Without Losing Your VersionsSSP Innovations
 
SBS5411_1819_02_basics.pdf
SBS5411_1819_02_basics.pdfSBS5411_1819_02_basics.pdf
SBS5411_1819_02_basics.pdfssuser91d50e
 
Spring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloudSpring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloudOrkhan Gasimov
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Derek Jacoby
 
Revit 2017 Whats New Webcast 5-26-2016
Revit 2017 Whats New Webcast 5-26-2016Revit 2017 Whats New Webcast 5-26-2016
Revit 2017 Whats New Webcast 5-26-2016Wendy Finch
 
Configuration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL PluginConfiguration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL PluginDaniel Spilker
 
JUC Europe 2015: Configuration as Code: The Job DSL Plugin
JUC Europe 2015: Configuration as Code: The Job DSL PluginJUC Europe 2015: Configuration as Code: The Job DSL Plugin
JUC Europe 2015: Configuration as Code: The Job DSL PluginCloudBees
 
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...Dan Halperin
 
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022HostedbyConfluent
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...HostedbyConfluent
 

Similar to LambdaFlow: Scala Functional Message Processing (20)

Forge - DevCon 2016: Drawings! Drawings! Everywhere!
Forge - DevCon 2016: Drawings! Drawings! Everywhere!Forge - DevCon 2016: Drawings! Drawings! Everywhere!
Forge - DevCon 2016: Drawings! Drawings! Everywhere!
 
Introduction no sql solutions with couchbase and .net core
Introduction no sql solutions with couchbase and .net coreIntroduction no sql solutions with couchbase and .net core
Introduction no sql solutions with couchbase and .net core
 
Blockchain and UDFs
Blockchain and UDFsBlockchain and UDFs
Blockchain and UDFs
 
Sitecore MVC Advanced
Sitecore MVC AdvancedSitecore MVC Advanced
Sitecore MVC Advanced
 
Technical Debt - SOTR14 - Clarkie
Technical Debt -  SOTR14 - ClarkieTechnical Debt -  SOTR14 - Clarkie
Technical Debt - SOTR14 - Clarkie
 
ch11_031102.ppt
ch11_031102.pptch11_031102.ppt
ch11_031102.ppt
 
Cincom Roadmap ESUG2014
Cincom Roadmap ESUG2014Cincom Roadmap ESUG2014
Cincom Roadmap ESUG2014
 
LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017
 
Introducing Neo4j 3.0
Introducing Neo4j 3.0Introducing Neo4j 3.0
Introducing Neo4j 3.0
 
Reaching State Zero Without Losing Your Versions
Reaching State Zero Without Losing Your VersionsReaching State Zero Without Losing Your Versions
Reaching State Zero Without Losing Your Versions
 
SBS5411_1819_02_basics.pdf
SBS5411_1819_02_basics.pdfSBS5411_1819_02_basics.pdf
SBS5411_1819_02_basics.pdf
 
Leveraging ArcGIS Online for Public Utility Data
Leveraging ArcGIS Online for Public Utility DataLeveraging ArcGIS Online for Public Utility Data
Leveraging ArcGIS Online for Public Utility Data
 
Spring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloudSpring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloud
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 
Revit 2017 Whats New Webcast 5-26-2016
Revit 2017 Whats New Webcast 5-26-2016Revit 2017 Whats New Webcast 5-26-2016
Revit 2017 Whats New Webcast 5-26-2016
 
Configuration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL PluginConfiguration as Code: The Job DSL Plugin
Configuration as Code: The Job DSL Plugin
 
JUC Europe 2015: Configuration as Code: The Job DSL Plugin
JUC Europe 2015: Configuration as Code: The Job DSL PluginJUC Europe 2015: Configuration as Code: The Job DSL Plugin
JUC Europe 2015: Configuration as Code: The Job DSL Plugin
 
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
 
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
 

More from John Nestor

Type Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset TransformsType Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset TransformsJohn Nestor
 
Messaging patterns
Messaging patternsMessaging patterns
Messaging patternsJohn Nestor
 
Experience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaExperience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaJohn Nestor
 
Scala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big DataScala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big DataJohn Nestor
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and PerformanceJohn Nestor
 

More from John Nestor (6)

Type Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset TransformsType Checking Scala Spark Datasets: Dataset Transforms
Type Checking Scala Spark Datasets: Dataset Transforms
 
Messaging patterns
Messaging patternsMessaging patterns
Messaging patterns
 
Experience Converting from Ruby to Scala
Experience Converting from Ruby to ScalaExperience Converting from Ruby to Scala
Experience Converting from Ruby to Scala
 
Scala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big DataScala and Spark are Ideal for Big Data
Scala and Spark are Ideal for Big Data
 
Scala Json Features and Performance
Scala Json Features and PerformanceScala Json Features and Performance
Scala Json Features and Performance
 
Neutronium
NeutroniumNeutronium
Neutronium
 

Recently uploaded

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Recently uploaded (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

LambdaFlow: Scala Functional Message Processing

  • 1. Scala Functional Message Processing: LambdaFlow John Nestor 47 Degrees www.47deg.com https://github.com/47deg/LambdaFlow May 9, 2017 147deg.com
  • 2. 47deg.com © Copyright 2017 47 Degrees Outline • Introduction • Examples • Simple • Windowing • Indexing and Query • Graph • Temperature • Page Rank • Questions 2
  • 4. 47deg.com © Copyright 2017 47 Degrees Inspiration • Wanted to build a reactive system using Akka clustering • Don’t like Spark micro-batching, want message at a time • Want a Scala functional DSL, like the Spark Scala DSL 4
  • 5. 47deg.com © Copyright 2017 47 Degrees LambdaFlow • Near-real-time message processing • Message at a time • Both set (create or update) and delete • Written in Scala and Akka • Two parts: • Functional DSL • Akka Cluster reactive implementation 5
  • 6. 47deg.com © Copyright 2017 47 Degrees LambdaFlow Use Cases • * Near real time streaming with infinite stream • Finite streams • Batch processing • Input and outputs via • files • API • Kafka • … 6
  • 7. 47deg.com © Copyright 2017 47 Degrees Possible Use Case 7 LambdaFlow ... Kafka In 1 Kafka In 2 Kafka In M Kafka Out N Kafka Out 2 Kafka Out 1 ...
  • 8. 47deg.com © Copyright 2017 47 Degrees Functional DSL • Directed graph • Strongly typed • Graph nodes are actions • Graph arcs are paths for message passing • Graph can contain cycles 8
  • 9. 47deg.com © Copyright 2017 47 Degrees Key-Value Model • (most) Actions contain an in-memory Key-Value HashMap[K,V] • Two messages • Set/Update Key:k1 to Value:v1 • Delete Key-Value pair for Key:k1 9
  • 10. 47deg.com © Copyright 2017 47 Degrees Combining Actions • Most actions have • Input: used to set or delete keys in KV store • Output: used to set or delete keys on next action • Operation: maps KV of this action to KV of next action 10
  • 11. 47deg.com © Copyright 2017 47 Degrees Functional Eventual Consistency • Two Actions A1[K1,V1] and A2[K2,V2] • Each have a KV store: A1.kv[K1,V1] and A2.kv[K2,V2] • the output of A1 is the input to A2 • A1 has an operation A1.f that maps 
 [K1,V1] => Set([K2,V2]) • If all changes to A1 are stopped, eventually • A2.kv = A1.kv.flatMap(A1.f) 11
  • 12. 47deg.com © Copyright 2017 47 Degrees Incremental Operation • Suppose an action has k1->v1 and we now set k1->v2 • To update the next action • Undo the effect of k1->v1 • Do the effect of k1->v2 12
  • 13. 47deg.com © Copyright 2017 47 Degrees Incremental Operation Example • Suppose action KV type is String=>String • If we change “A”->”B” to “A”->”C” • Operation example 1 (map): (k,v)=>(k+v,v+v) • Delete “AB”->”BB” • Set “AC”=> “CC” • Operation example 2(mapvalue): (k,v) => (k,v+v) • Delete “A” -> “BB” (not needed here) • Set “A” -> “CC” 13
  • 14. 47deg.com © Copyright 2017 47 Degrees Implementations • Class based • Uses method calls rather than actor messages • Local Akka Actor based • Akka Cluster Based • Multinode • Reactive: scalable, responsive, fault-tolerant 14
  • 16. 47deg.com © Copyright 2017 47 Degrees Simple Example • Input data: • 8328 Tweets • Look at input data (capture.json) • Count number of tweets in each language • Use method calls between actions 16
  • 17. 47deg.com © Copyright 2017 47 Degrees Simple Example 17 (Lang,UID) => () Src Sink Reduce Sum Per Lang Lang => Count Map UID => Lang
  • 18. 47deg.com © Copyright 2017 47 Degrees Simple Example Code val src = Source[String, String]("src")
 val counts = Sink[String, Long]("counts")
 
 val f1 = src
 .map("map",(uid,lang)=>((uid,lang),()))
 .reduce("red", _._2, (k, v) => 1L, LongSum)
 .sink(counts)
 
 run(f1) 18
  • 19. 47deg.com © Copyright 2017 47 Degrees Source and Sink Actions • Source[K,V] • gets input from outside the graph (e.g. Kafka) • outputs to other actions • Sink[K,V] • gets it input from other actions • outputs to outside the graph (e.g. Kafka) 19
  • 20. 47deg.com © Copyright 2017 47 Degrees Map Operation • Action input type K,V • Action output type KOUT,VOUT • Action function type: (K,V)=>(KOUT,VOUT) 20
  • 21. 47deg.com © Copyright 2017 47 Degrees Reduce Operation • Action input type K,V • Action output type KOUT,VOUT • Grouping function type: K=>KOUT (many to one) • Value function type: (K,V)=>VOUT • Reduce operation type (VOUT,VOUT)=>VOUT • commutative, associative and inverse (abelian group) 21
  • 22. 47deg.com © Copyright 2017 47 Degrees Simple Example • Run it (demo.simple) • Look at code (Simple.scala) 22
  • 24. 47deg.com © Copyright 2017 47 Degrees Windowing Example • Streaming Data • 1000 Tweets • sent in at ~20 per second • each tweet expires after 20 seconds • Count languages and find 20 most common words • Uses local actor implementation • Uses Vaadin based visualization tool 24
  • 25. 47deg.com © Copyright 2017 47 Degrees Windowing Example 25 Lang Count Reduce Txt Total Percent Words Join Map FlatMap MapReduce Reduce First Map
  • 26. 47deg.com © Copyright 2017 47 Degrees Windowing Example Code val f1 = src
 .reduce("red", _._1, (k, v) => 1L, LongSum)
 .to(counts1, counts2)
 .sink(counts)
 
 val f2 = counts1
 .reduce("red1", _ => List.empty[String], (k, v) => v, LongSum)
 .map[String, Long]("map1", (k, v) => ("total", v))
 .to(total1)
 .sink(total)
 
 val f3 = counts2
 .join[String, Long, Unit, String, String]("product", total1, (s:String)=>(), (s:String)=>()) {
 case (lang, count, t, total) => Set((lang, f"${count * 100 / total}%02d$PERCENT"))
 }
 .sink(percent)
 
 val f4 = text
 .flatMap("GetWords", (k, v) => {
 val (text, uuid) = k
 getWords(text)
 .zipWithIndex
 .map {
 case (word, i) => ((word, uuid, i), ())
 }
 .toSet
 })
 .map("CountOrder", (word, count) => ((-count, word), ()))
 .first("first", 20)
 .map("CountOrder1", (k, v) => (k._2, f"${-k._1}%4d"))
 .sink(words) run(f1, f2, f3, f4) 26
  • 27. 47deg.com © Copyright 2017 47 Degrees Labels,To and From • Label[K,V]: used to connect an action output to another action input • .to[K,V]: send one input to multiple outputs (broadcast) • .from[K,V]: combine multiple inputs to a single output (union) 27
  • 28. 47deg.com © Copyright 2017 47 Degrees FlatMap Action • Action input type K,V • Action output type KOUT,VOUT • Action function type: (K,V)=>Set[(KOUT,VOUT)] 28
  • 29. 47deg.com © Copyright 2017 47 Degrees First Action • Action input type K,V • Action output type K,V • Count: a small integer • Output at most count key-values • those with the lowest keys • requires type K be ordered 29
  • 30. 47deg.com © Copyright 2017 47 Degrees Join Action • Two inputs: K1,V1 and K2,V2 • Two key value stores • Output types KOUT and VOUT • Two mapping functions: K1=>K K2=>K (many to one) • An operation • Applied to each member of the product of KV pairs from the two key stores with the same K value • (K1,V1,K2,V2) => Set[(KOUT,VOUT)] 30
  • 31. 47deg.com © Copyright 2017 47 Degrees Viewer 31 LambdaFlow Remote Actor FlowView Vaadin Web BrowserTweets
  • 32. 47deg.com © Copyright 2017 47 Degrees Windowing Example • Start up Vaadin viewer and web browser • Run it (demo.TwitterFlow) • Look at code (TwitterFlow.scala) 32
  • 34. 47deg.com © Copyright 2017 47 Degrees Index and Query Example • Input data: Breweries • look at breweries.data • Build indexes • set of breweries at a location (State/Country) • set of breweries with a key word (in its description) • use jline3 command hander 34
  • 35. 47deg.com © Copyright 2017 47 Degrees Index Example 35 Breweries Reduce Names Places Words Map FlatMap Reduce
  • 36. 47deg.com © Copyright 2017 47 Degrees Query • words:Sink[String,Set[Int]] • words.get(word) => Future[Option[Set[Id]]] • breweries:Source[Int,String] : id->JsonString • def name(json:String)=>name (extracts the brewery name) • breweries.get(id,name) => Future[Option[String]] 36
  • 38. 47deg.com © Copyright 2017 47 Degrees Input Data:A Directed Graph 38 A B C D E F
  • 39. 47deg.com © Copyright 2017 47 Degrees Graph Example • Note: there are two graphs • The input data • The graph of actions • Output • Number of distinct paths between two nodes • Set of all cycles • Loop in action graph for transitive closure • Like recursive function • Functional semantics is fixed point of loop 39
  • 40. 47deg.com © Copyright 2017 47 Degrees Graph Transitive Closure • Given • route C -> E -> F • link A -> C • Form product (Common key = C) • route C -> E -> F (routes starting at C) • flipped link C -> A (links ending at C) • Result • route A -> C -> E -> F (goes back around loop!) 40
  • 41. 47deg.com © Copyright 2017 47 Degrees Graph Example 41 Edges Map toPath CyclesRoutes Join Link Map Route Map Invert Filter Cyles Reduce Count
  • 42. 47deg.com © Copyright 2017 47 Degrees Graph Example • Start Vaadin viewer and browser window • Run example (demo.GraphCycle) • showCycles • Look at code 42
  • 43. 47deg.com © Copyright 2017 47 Degrees Modified Graph 43 A B C D E F
  • 44. 47deg.com © Copyright 2017 47 Degrees Modify Graph • set F A • look at browser • showCycles • delete F A • look at browser • showCycles 44
  • 46. 47deg.com © Copyright 2017 47 Degrees Temperature Grid 46 T1 T2 T3 T4 0,0 1,0 2,0 T7 T5 0,1 1,1 2,1 T8 T6 0,2 1,2 2,2 T9 T10 T11 T12
  • 47. 47deg.com © Copyright 2017 47 Degrees Computation 47 U L (U+D+L+R) / 4 R D
  • 48. 47deg.com © Copyright 2017 47 Degrees Temp Example 48 Edges Temps Map FlatMap 1 => 4 Map Reduce 4 => 1 Map
  • 49. 47deg.com © Copyright 2017 47 Degrees Temperature Result 49 30 20 10 50 35 27 27 50 40 34 27 21 10 30 33 27 20 10 40 30 20
  • 50. 47deg.com © Copyright 2017 47 Degrees Temperature Change 50 30 20 10 50/10 35/24 27/25 27/28 50 40 34/32 27/29 21/27 10 30 33/34 27/33 20/40 10/80 40 30 20
  • 52. 47deg.com © Copyright 2017 47 Degrees Page Rank Data 52 A B C D E F
  • 53. 47deg.com © Copyright 2017 47 Degrees Page Rank Example 53 Edges Reduce Rank Join Invert Map Initial Val FlatMap Map Bias Reduce Join Div by Cnt Reduce Sum Map Reduce Select
  • 54. 47deg.com © Copyright 2017 47 Degrees Page Rank Result 54 1.4 .60 .88 .28 .75 .47
  • 56. 47deg.com © Copyright 2017 47 Degrees LambdaFlow and Kafka Common Properties • JVM based • Integrate with Kafka topics • Key-value based • One message at a time • Operations: map, reduce, … • Scalable and fault tolerant • Open source 56
  • 57. 47deg.com © Copyright 2017 47 Degrees LambdaFlow versus Kafka 57 LambdaFlow Kafka Akka Cluster Zookeeper Scala Java Set/Delete Set Functional Imperative