SlideShare una empresa de Scribd logo
1 de 48
January 23rd, 2019
Warsaw Group
All contents © MuleSoft Inc.
Our Partners
2
All contents © MuleSoft Inc.
Share
3
• Share the Meetup
• Use Hashtags
– #MuleMeetup
– #WarsawMuleMeetup
Agenda
All contents © MuleSoft Inc.
Agenda
5
6:00 PM Introductions
6:15 PM Intro into DataWeave 2.0
6:35 PM Map/Filter/Reduce
7:15 PM Break
7:30 PM Map/Filter/Reduce/Q&A
7:45 PM DataWeave 2.0 cases
8:05 PM Q&A
8:35 PM Closing the Meetup
Introduction
All contents © MuleSoft Inc.
Speaker
7
• Joshua Erney
• Mountain State Software Solutions
• @mulemadeeasy
• www.jerney.io / @jerney_io
• Brief work history...
All contents © MuleSoft Inc.
Organiser & Speaker
8
• Senior Integration Developer at PwC Poland
• MuleSoft Meetup Leader for Warsaw, Poland
• Recognized by MuleSoft as one of the top
contributors in the MuleSoft Community
• Mule blogger https://profit-online.pl/blog
• Doing Mule for over 7 years now
November + December 2018
Community Success Months:
Get trained and become MuleSoft-Certified
Data Weave 2.0
Mule 4
All contents © MuleSoft Inc.
Introduction
DataWeave
11
• Entirely replaces everything that MEL does
• Default language
• Syntax changes
• Modularization
• And many more …
MEL
MEL stands for Mule
Expression Language
What's new
By example
A Deep Dive
DataWeave 2.0:
map/filter/reduce
All contents © MuleSoft Inc.
Agenda
20
• About me
• What are map/filter/reduce?
• Filter (overview, graphic, examples)
• Map (overview, graphic, examples)
• Reduce (overview, graphic, examples)
• Reusable functions with map/filter/reduce
All contents © MuleSoft Inc.
What are map, filter, and reduce?
21
• Functions that transform arrays
• As input: an array, and a function
– Higher order functions (a function taking another function as an argument, OR a
function that returns another function)
– The input function for map/filter/reduce define the implementation details of the
transformation
• Output: array (map/filter), any (reduce)
• Declarative - implementation of iteration is hidden from the client
• Transformations are non-destructive (they do not modify any input)
All contents © MuleSoft Inc.
Why do a talk on them?
22
• They form the core functionality that you’ll need for data
transformations (removing records, modifying records, general-
purpose transformation tool)
• A mastery of map/filter/reduce is essential to writing clear and
efficient transformations.
• A lot of other functions that work on transforming arrays are just
flavors of map/filter/reduce.
• Gives you a great base to build off of because you need to
understand two key concepts: immutability, and higher-order
functions
filter
Removing elements from arrays
23
All contents © MuleSoft Inc.
filter
24
• Input: An array and a predicate function (function that returns true
or false)
– Predicate function example: (n) -> (n == 2)
• Output: a new array
• Creates new output array, applying the predicate function to every
element in the input array
• If the predicate returns true, add the value to the output, if the
predicate returns false, ignore it
• The only thing filter can do is create new arrays that contain the
same or less elements than the previous array. It cannot change the
elements.
All contents © MuleSoft Inc.
filter (cont.)
25
All contents © MuleSoft Inc.
filter (examples)
26
// Filter by content
[1,2,3,4,5] filter (mod($, 2) == 0)
// -> [2, 4]
// Filter by index
[2,4,6,8,10] filter ($$ == 4)
// -> [10]
// Filter by nested content (popular use case)
var arr = [{“name”:”Josh”}, {“name”:”Patryk”}, {“name”:”Max The Mule”}]
---
arr filter $.name == “Patryk”
// -> [{”name”:”Patryk”}]
map
Transforming elements in an array
27
All contents © MuleSoft Inc.
map
28
• Input: an array and a mapping function
• Output: a new array
• The mapping function describes how each element in the array will
be modified before it is added to the output array
• map can create a new array that is the result of a modification of
each element in the input array. map cannot modify the number of
elements returned in the resulting array
All contents © MuleSoft Inc.
map (cont.)
29
All contents © MuleSoft Inc.
map (examples)
30
// Map using each element
[1,2,3] map ($ + 1)
// -> [2,3,4]
// Map using index
[1,2,3] map ({loc: $$, n: $})
// -> [{loc: 0, n: 1},{loc: 1, n: 2}, {loc: 2, n: 3}]
// Map nested values down to single-item array (great for list of IDs)
[{id: 123}, {id: 456}, {id: 789}] map $.id
// -> [123, 456, 789]
reduce
... pretty much anything else you’d want to do with an array
All contents © MuleSoft Inc.
reduce
32
• Takes in an array and an accumulator function
• returns a new Any (object, string, Boolean, null, array, etc.) we will
call this the result
• The accumulator function defines how each element in the input
array will be folded into the result
– The value returned from the accumulator function will be passed to the next
iteration
• Reduce is the most general-purpose of the three core functions
• Can implement both map and filter in terms of reduce, so map and
filter are just specialized reduce functions
– Keep this in mind as you write your transformations. Don’t use reduce when a
map or filter would work instead
All contents © MuleSoft Inc.
reduce (cont.)
33
All contents © MuleSoft Inc.
reduce (examples)
34
// Classic example: Adding numbers
[1,2,3] reduce ((n, acc) -> acc + n)
// -> 6
// A simple joinBy functionality
[“1”,”2”,”3”] reduce ((str, out) -> out ++ “, ” ++ str
// “1, 2, 3”
// The same thing wrapped in a helpful function (I wrap most non-trivial reduce
// code in a simple function so that the client does not need to pass a lambda)
fun myJoinBy(arr, delim) =
arr reduce ((str, out) -> out ++ delim ++ str
All contents © MuleSoft Inc.
reduce (examples cont.)
35
// Flattening an array into a object (common use case)
var arr = [
{dev: "c6824476-b7e2-4e8a-9281-bdc40663bb93"},
{prod: "7f44b450-18ff-45fa-85f3-8ef5c82b4989"}
]
---
arr reduce ((env, obj) -> obj ++ env)
// -> { ”dev”: “c6824476-b7e2-4e8a-9281-bdc40663bb93”,
// “prod”: “7f44b450-18ff-45fa-85f3-8ef5c82b4989” }
// You could also do this ($$ defaults to the first value in the array):
arr reduce ($$ ++ $)
All contents © MuleSoft Inc.
reduce (examples cont.)
36
// Make map/filter code more efficient. This loops twice:
[1,2,3,4,5] filter (mod($, 2) == 0) map ($ + 2)
// -> [4,6]
// This loops once and accomplishes the same job
[1,2,3,4,5] reduce ((n, acc=[]) ->
if (mod(n, 2) == 0) // Filter replacement
acc + (n + 2) // Map replacement
else
acc)
All contents © MuleSoft Inc.
reduce (examples cont.)
37
// Implement map:
fun myMap(arr, transformFn) =
arr reduce ((e, acc=[]) ->
acc + transformFn(e)
// Implement filter:
fun myFilter(arr, predicateFn) =
arr reduce ((e, acc=[]) ->
if (predicateFn(e))
acc + e
else
acc
Reusable functions w/
map/filter/reduce
All contents © MuleSoft Inc.
Wrapping map/filter/reduce
• Passing functions to functions is nice because of the flexibility, but
it’s not always an ideal API because of that flexibility
– Reader needs to understand map/filter/reduce, and then understand the
workings of passed function
• To make functions less flexible, but far more readable, you can do
the following
1. Name the functionality that the passed-in function is providing
2. Wrap the map/filter/reduce code in a function
3. Name that function according to the name you came up w/ in step 1
4. Make sure parameters passed to your new function do not take in a lambda
All contents © MuleSoft Inc.
Example
40
• Let’s take a reduce example from earlier. We start with this:
var arr = [{dev: ”123"}, {prod: ”456"}]
---
arr reduce ((env, obj={}) -> obj ++ env)
// -> {dev: “123”, prod: “456}
All contents © MuleSoft Inc.
Example (cont.)
41
We will name the function based off of that functionality, and save the
client from having to pass in that functionality:
fun flattenToObj(arr) =
arr reduce (kvPair, obj={}) -> obj ++ kvPair)
All contents © MuleSoft Inc.
Moving Forward
42
• You can do this with most functions that use map/filter/reduce
– e.g. fun removeOdds(arr) = arr filter ($ mod 2 == 0)
• This is especially helpful if the functions are going to be reused (put
them in a module!)
• Might not be as helpful if not reused, but you will get a nice
readability boost that comes from effective naming of your functions
Closing Thoughts
All contents © MuleSoft Inc.
Conclusion
44
• map/filter/reduce are a trio of higher-order functions that form the
core of array transformations
– Filter is used to remove elements from an array
– Map is used to modify elements from an array
– Reduce is used to do all the of the above, as well as transform arrays to any
other type. Very general-purpose. Reach for this last.
• Map and filter tend to be pretty easy to learn, reduce typically
requires more practice to master
• Master these functions first, then learn mapObject, filterObject,
groupBy, pluck
All contents © MuleSoft Inc.
More Info
45
• MuleSoft documentation:
– Map: https://docs.mulesoft.com/mule-runtime/4.1/dw-core-functions-map
– Filter: https://docs.mulesoft.com/mule-runtime/4.1/dw-core-functions-filter
– Reduce: https://docs.mulesoft.com/mule-runtime/4.1/dw-core-functions-reduce
• You can find more detailed information on my blog:
– Map post: www.jerney.io/dataweave-the-map-function/
– Filter post: On It’s Way 
– Reduce post 1: www.jerney.io/dataweave-when-to-use-reduce/
– Reduce post 2: www.jerney.io/dataweave-mapping-an-array-to-an-object/
– Practice exercises (map/filter/reduce and others):
www.jerney.io/dataweave-practice-exercises/
Questions?
46
All contents © MuleSoft Inc.
DataWeave question
47
Which one is not a valid condition in Choice component
1. #[payload.type == 'Mule Meetup']
2. ${file:complexCondition.dwl}
3. payload.type == 'Mule Meetup'
4. All options are valid :)
All contents © MuleSoft Inc.
DataWeave question
48
Which one is not a valid condition in Choice component
1. #[payload.type == 'Mule Meetup']
2. ${file:complexCondition.dwl}
3. payload.type == 'Mule Meetup'
4. All options are valid :)
Correct syntax is:
${file::complexCondition.dwl}
DataWeave 2.0 DEMO
Sample cases
What’s next
All contents © MuleSoft Inc.
What’s next
51
• Feedback:
– Contact your organizer Patryk Bandurski to suggest topics
– Contact MuleSoft at meetup@mulesoft.com for ways to improve the program
• Our next meetup:
– Date: March/April 2019
– Location: PwC Poland
– Topic: …
All contents © MuleSoft Inc.
What’s next
52
Invite your network to join
– https://meetups.mulesoft.com/warsaw/
See you next time
Please send topic suggestions to the organizer
The correct answer is 2. ${file:complexCondition.dwl} is not a valid condition in Choice component.The Choice component allows conditions using DataWeave expressions only, it does not support calling external DataWeave files.So options 1 and 3 using DataWeave equality check on payload fields are valid, but option 2 trying to call an external DWL file is invalid

Más contenido relacionado

La actualidad más candente

MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...
MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...
MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...Manish Kumar Yadav
 
Pune Mule Meetups July 2019
Pune Mule Meetups July 2019Pune Mule Meetups July 2019
Pune Mule Meetups July 2019Santosh Ojha
 
Warsaw MuleSoft Meetup #6 - CI/CD
Warsaw MuleSoft Meetup  #6 - CI/CDWarsaw MuleSoft Meetup  #6 - CI/CD
Warsaw MuleSoft Meetup #6 - CI/CDPatryk Bandurski
 
Mumbai MuleSoft Meetup #15
Mumbai MuleSoft Meetup #15Mumbai MuleSoft Meetup #15
Mumbai MuleSoft Meetup #15Akshata Sawant
 
Meetup bangalore june29th2019
Meetup bangalore june29th2019Meetup bangalore june29th2019
Meetup bangalore june29th2019D.Rajesh Kumar
 
Ahmedabad MuleSoft Meetup #1
Ahmedabad MuleSoft Meetup #1Ahmedabad MuleSoft Meetup #1
Ahmedabad MuleSoft Meetup #1Tejas Purohit
 
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...Jitendra Bafna
 
DataWeave and Error Handling Meetup at SF Tower Sept 24th
DataWeave and Error Handling Meetup at SF Tower Sept 24thDataWeave and Error Handling Meetup at SF Tower Sept 24th
DataWeave and Error Handling Meetup at SF Tower Sept 24thJordan Schuetz
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminarGal Marder
 
Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11Akshata Sawant
 
Mulesoft with ELK (Elastic Search, Log stash, Kibana)
Mulesoft with ELK (Elastic Search, Log stash, Kibana)Mulesoft with ELK (Elastic Search, Log stash, Kibana)
Mulesoft with ELK (Elastic Search, Log stash, Kibana)Gaurav Sethi
 
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...Jitendra Bafna
 
Meet up slides_mumbai_05022020_final
Meet up slides_mumbai_05022020_finalMeet up slides_mumbai_05022020_final
Meet up slides_mumbai_05022020_finalAkshata Sawant
 
Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...
Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...
Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...Manish Kumar Yadav
 
Warsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policyWarsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policyPatryk Bandurski
 
9th Manila MuleSoft Meetup July 2021
9th Manila MuleSoft Meetup July 20219th Manila MuleSoft Meetup July 2021
9th Manila MuleSoft Meetup July 2021Ryan Anthony Andal
 
MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...
MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...
MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...Jitendra Bafna
 
Deep Dive into Salesforce APIs
Deep Dive into Salesforce APIsDeep Dive into Salesforce APIs
Deep Dive into Salesforce APIsNeerajKumar1965
 
MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...
MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...
MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...Jitendra Bafna
 
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...Jitendra Bafna
 

La actualidad más candente (20)

MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...
MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...
MuleSoft Integration with AWS Cognito Client Credentials and Mule JWT Validat...
 
Pune Mule Meetups July 2019
Pune Mule Meetups July 2019Pune Mule Meetups July 2019
Pune Mule Meetups July 2019
 
Warsaw MuleSoft Meetup #6 - CI/CD
Warsaw MuleSoft Meetup  #6 - CI/CDWarsaw MuleSoft Meetup  #6 - CI/CD
Warsaw MuleSoft Meetup #6 - CI/CD
 
Mumbai MuleSoft Meetup #15
Mumbai MuleSoft Meetup #15Mumbai MuleSoft Meetup #15
Mumbai MuleSoft Meetup #15
 
Meetup bangalore june29th2019
Meetup bangalore june29th2019Meetup bangalore june29th2019
Meetup bangalore june29th2019
 
Ahmedabad MuleSoft Meetup #1
Ahmedabad MuleSoft Meetup #1Ahmedabad MuleSoft Meetup #1
Ahmedabad MuleSoft Meetup #1
 
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
MuleSoft Surat Virtual Meetup#27 - MuleSoft Runtime 4.4, Transit Gateway and ...
 
DataWeave and Error Handling Meetup at SF Tower Sept 24th
DataWeave and Error Handling Meetup at SF Tower Sept 24thDataWeave and Error Handling Meetup at SF Tower Sept 24th
DataWeave and Error Handling Meetup at SF Tower Sept 24th
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11Mumbai MuleSoft Meetup 11
Mumbai MuleSoft Meetup 11
 
Mulesoft with ELK (Elastic Search, Log stash, Kibana)
Mulesoft with ELK (Elastic Search, Log stash, Kibana)Mulesoft with ELK (Elastic Search, Log stash, Kibana)
Mulesoft with ELK (Elastic Search, Log stash, Kibana)
 
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
 
Meet up slides_mumbai_05022020_final
Meet up slides_mumbai_05022020_finalMeet up slides_mumbai_05022020_final
Meet up slides_mumbai_05022020_final
 
Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...
Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...
Clustering, Server setup and Hybrid deployment setup using Anypoint Runtime M...
 
Warsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policyWarsaw MuleSoft Meetup #7 - custom policy
Warsaw MuleSoft Meetup #7 - custom policy
 
9th Manila MuleSoft Meetup July 2021
9th Manila MuleSoft Meetup July 20219th Manila MuleSoft Meetup July 2021
9th Manila MuleSoft Meetup July 2021
 
MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...
MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...
MuleSoft Surat Virtual Meetup#18 - Persistent Queue, Object Store and Persist...
 
Deep Dive into Salesforce APIs
Deep Dive into Salesforce APIsDeep Dive into Salesforce APIs
Deep Dive into Salesforce APIs
 
MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...
MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...
MuleSoft Surat Virtual Meetup#7 - JSON Logger and Common Error Handling With ...
 
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
 

Similar a The correct answer is 2. ${file:complexCondition.dwl} is not a valid condition in Choice component.The Choice component allows conditions using DataWeave expressions only, it does not support calling external DataWeave files.So options 1 and 3 using DataWeave equality check on payload fields are valid, but option 2 trying to call an external DWL file is invalid

Mapfilterreducepresentation
MapfilterreducepresentationMapfilterreducepresentation
MapfilterreducepresentationManjuKumara GH
 
R Programming Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfd
R Programming  Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfdR Programming  Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfd
R Programming Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfdvaibhavkandalkar2
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ICarlos Oliveira
 
Verilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONSVerilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONSDr.YNM
 
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニックUnity Technologies Japan K.K.
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native CompilationPGConf APAC
 
Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Rajeev Rastogi (KRR)
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshopVinay Kumar
 
20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptxDianeKesler1
 
TAU Performance tool using OpenPOWER
TAU Performance tool using OpenPOWERTAU Performance tool using OpenPOWER
TAU Performance tool using OpenPOWERGanesan Narayanasamy
 
MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020Ieva Navickaite
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptxmiki304759
 
Introduction to Mahout
Introduction to MahoutIntroduction to Mahout
Introduction to MahoutTed Dunning
 
Introduction to Mahout given at Twin Cities HUG
Introduction to Mahout given at Twin Cities HUGIntroduction to Mahout given at Twin Cities HUG
Introduction to Mahout given at Twin Cities HUGMapR Technologies
 

Similar a The correct answer is 2. ${file:complexCondition.dwl} is not a valid condition in Choice component.The Choice component allows conditions using DataWeave expressions only, it does not support calling external DataWeave files.So options 1 and 3 using DataWeave equality check on payload fields are valid, but option 2 trying to call an external DWL file is invalid (20)

Mapfilterreducepresentation
MapfilterreducepresentationMapfilterreducepresentation
Mapfilterreducepresentation
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
 
R Programming Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfd
R Programming  Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfdR Programming  Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfd
R Programming Magrittrdfgdfsgfdgfdgfdgfdsg fsd gdfsgdf gdf gdfsgfd
 
14 operator overloading
14 operator overloading14 operator overloading
14 operator overloading
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices I
 
Verilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONSVerilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONS
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
 
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
 
Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
 
20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
TAU Performance tool using OpenPOWER
TAU Performance tool using OpenPOWERTAU Performance tool using OpenPOWER
TAU Performance tool using OpenPOWER
 
MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
Introduction to Mahout
Introduction to MahoutIntroduction to Mahout
Introduction to Mahout
 
Introduction to Mahout given at Twin Cities HUG
Introduction to Mahout given at Twin Cities HUGIntroduction to Mahout given at Twin Cities HUG
Introduction to Mahout given at Twin Cities HUG
 
Functions
FunctionsFunctions
Functions
 
The google MapReduce
The google MapReduceThe google MapReduce
The google MapReduce
 

Más de Patryk Bandurski

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Warsaw MuleSoft Meetup #16 DF Tour.pptx
Warsaw MuleSoft Meetup #16 DF Tour.pptxWarsaw MuleSoft Meetup #16 DF Tour.pptx
Warsaw MuleSoft Meetup #16 DF Tour.pptxPatryk Bandurski
 
Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101
Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101
Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101Patryk Bandurski
 
Marketing Cloud integration with MuleSoft
Marketing Cloud integration with MuleSoftMarketing Cloud integration with MuleSoft
Marketing Cloud integration with MuleSoftPatryk Bandurski
 
Warsaw MuleSoft Meetup #13.pptx
Warsaw MuleSoft Meetup #13.pptxWarsaw MuleSoft Meetup #13.pptx
Warsaw MuleSoft Meetup #13.pptxPatryk Bandurski
 
Warsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective StreamingWarsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective StreamingPatryk Bandurski
 
Warsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft ODataWarsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft ODataPatryk Bandurski
 
MuleSoft CloudHub API Versioning
MuleSoft CloudHub API VersioningMuleSoft CloudHub API Versioning
MuleSoft CloudHub API VersioningPatryk Bandurski
 
Warsaw mulesoft meetup #9 mastering integration with salesforce
Warsaw mulesoft meetup #9 mastering integration with salesforceWarsaw mulesoft meetup #9 mastering integration with salesforce
Warsaw mulesoft meetup #9 mastering integration with salesforcePatryk Bandurski
 
Mule soft meetup warsaw november 13th, 2019
Mule soft meetup   warsaw november 13th, 2019Mule soft meetup   warsaw november 13th, 2019
Mule soft meetup warsaw november 13th, 2019Patryk Bandurski
 
MuleSoft approach to the integration - Warsaw MuleSoft Meetup
MuleSoft approach to the integration - Warsaw MuleSoft MeetupMuleSoft approach to the integration - Warsaw MuleSoft Meetup
MuleSoft approach to the integration - Warsaw MuleSoft MeetupPatryk Bandurski
 

Más de Patryk Bandurski (12)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Warsaw MuleSoft Meetup #16 DF Tour.pptx
Warsaw MuleSoft Meetup #16 DF Tour.pptxWarsaw MuleSoft Meetup #16 DF Tour.pptx
Warsaw MuleSoft Meetup #16 DF Tour.pptx
 
Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101
Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101
Warsaw MuleSoft Meetup #15 - Hyperautomation with MuleSoft - Composer 101
 
Marketing Cloud integration with MuleSoft
Marketing Cloud integration with MuleSoftMarketing Cloud integration with MuleSoft
Marketing Cloud integration with MuleSoft
 
Warsaw MuleSoft Meetup #13.pptx
Warsaw MuleSoft Meetup #13.pptxWarsaw MuleSoft Meetup #13.pptx
Warsaw MuleSoft Meetup #13.pptx
 
Warsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective StreamingWarsaw MuleSoft Meetup #12 Effective Streaming
Warsaw MuleSoft Meetup #12 Effective Streaming
 
Warsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft ODataWarsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft OData
 
MuleSoft CloudHub API Versioning
MuleSoft CloudHub API VersioningMuleSoft CloudHub API Versioning
MuleSoft CloudHub API Versioning
 
Warsaw mulesoft meetup #9 mastering integration with salesforce
Warsaw mulesoft meetup #9 mastering integration with salesforceWarsaw mulesoft meetup #9 mastering integration with salesforce
Warsaw mulesoft meetup #9 mastering integration with salesforce
 
MuleSoft JWT Demystified
MuleSoft JWT DemystifiedMuleSoft JWT Demystified
MuleSoft JWT Demystified
 
Mule soft meetup warsaw november 13th, 2019
Mule soft meetup   warsaw november 13th, 2019Mule soft meetup   warsaw november 13th, 2019
Mule soft meetup warsaw november 13th, 2019
 
MuleSoft approach to the integration - Warsaw MuleSoft Meetup
MuleSoft approach to the integration - Warsaw MuleSoft MeetupMuleSoft approach to the integration - Warsaw MuleSoft Meetup
MuleSoft approach to the integration - Warsaw MuleSoft Meetup
 

Último

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Último (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

The correct answer is 2. ${file:complexCondition.dwl} is not a valid condition in Choice component.The Choice component allows conditions using DataWeave expressions only, it does not support calling external DataWeave files.So options 1 and 3 using DataWeave equality check on payload fields are valid, but option 2 trying to call an external DWL file is invalid

  • 2. All contents © MuleSoft Inc. Our Partners 2
  • 3. All contents © MuleSoft Inc. Share 3 • Share the Meetup • Use Hashtags – #MuleMeetup – #WarsawMuleMeetup
  • 5. All contents © MuleSoft Inc. Agenda 5 6:00 PM Introductions 6:15 PM Intro into DataWeave 2.0 6:35 PM Map/Filter/Reduce 7:15 PM Break 7:30 PM Map/Filter/Reduce/Q&A 7:45 PM DataWeave 2.0 cases 8:05 PM Q&A 8:35 PM Closing the Meetup
  • 7. All contents © MuleSoft Inc. Speaker 7 • Joshua Erney • Mountain State Software Solutions • @mulemadeeasy • www.jerney.io / @jerney_io • Brief work history...
  • 8. All contents © MuleSoft Inc. Organiser & Speaker 8 • Senior Integration Developer at PwC Poland • MuleSoft Meetup Leader for Warsaw, Poland • Recognized by MuleSoft as one of the top contributors in the MuleSoft Community • Mule blogger https://profit-online.pl/blog • Doing Mule for over 7 years now
  • 9. November + December 2018 Community Success Months: Get trained and become MuleSoft-Certified
  • 11. All contents © MuleSoft Inc. Introduction DataWeave 11 • Entirely replaces everything that MEL does • Default language • Syntax changes • Modularization • And many more … MEL MEL stands for Mule Expression Language
  • 13. A Deep Dive DataWeave 2.0: map/filter/reduce
  • 14. All contents © MuleSoft Inc. Agenda 20 • About me • What are map/filter/reduce? • Filter (overview, graphic, examples) • Map (overview, graphic, examples) • Reduce (overview, graphic, examples) • Reusable functions with map/filter/reduce
  • 15. All contents © MuleSoft Inc. What are map, filter, and reduce? 21 • Functions that transform arrays • As input: an array, and a function – Higher order functions (a function taking another function as an argument, OR a function that returns another function) – The input function for map/filter/reduce define the implementation details of the transformation • Output: array (map/filter), any (reduce) • Declarative - implementation of iteration is hidden from the client • Transformations are non-destructive (they do not modify any input)
  • 16. All contents © MuleSoft Inc. Why do a talk on them? 22 • They form the core functionality that you’ll need for data transformations (removing records, modifying records, general- purpose transformation tool) • A mastery of map/filter/reduce is essential to writing clear and efficient transformations. • A lot of other functions that work on transforming arrays are just flavors of map/filter/reduce. • Gives you a great base to build off of because you need to understand two key concepts: immutability, and higher-order functions
  • 18. All contents © MuleSoft Inc. filter 24 • Input: An array and a predicate function (function that returns true or false) – Predicate function example: (n) -> (n == 2) • Output: a new array • Creates new output array, applying the predicate function to every element in the input array • If the predicate returns true, add the value to the output, if the predicate returns false, ignore it • The only thing filter can do is create new arrays that contain the same or less elements than the previous array. It cannot change the elements.
  • 19. All contents © MuleSoft Inc. filter (cont.) 25
  • 20. All contents © MuleSoft Inc. filter (examples) 26 // Filter by content [1,2,3,4,5] filter (mod($, 2) == 0) // -> [2, 4] // Filter by index [2,4,6,8,10] filter ($$ == 4) // -> [10] // Filter by nested content (popular use case) var arr = [{“name”:”Josh”}, {“name”:”Patryk”}, {“name”:”Max The Mule”}] --- arr filter $.name == “Patryk” // -> [{”name”:”Patryk”}]
  • 22. All contents © MuleSoft Inc. map 28 • Input: an array and a mapping function • Output: a new array • The mapping function describes how each element in the array will be modified before it is added to the output array • map can create a new array that is the result of a modification of each element in the input array. map cannot modify the number of elements returned in the resulting array
  • 23. All contents © MuleSoft Inc. map (cont.) 29
  • 24. All contents © MuleSoft Inc. map (examples) 30 // Map using each element [1,2,3] map ($ + 1) // -> [2,3,4] // Map using index [1,2,3] map ({loc: $$, n: $}) // -> [{loc: 0, n: 1},{loc: 1, n: 2}, {loc: 2, n: 3}] // Map nested values down to single-item array (great for list of IDs) [{id: 123}, {id: 456}, {id: 789}] map $.id // -> [123, 456, 789]
  • 25. reduce ... pretty much anything else you’d want to do with an array
  • 26. All contents © MuleSoft Inc. reduce 32 • Takes in an array and an accumulator function • returns a new Any (object, string, Boolean, null, array, etc.) we will call this the result • The accumulator function defines how each element in the input array will be folded into the result – The value returned from the accumulator function will be passed to the next iteration • Reduce is the most general-purpose of the three core functions • Can implement both map and filter in terms of reduce, so map and filter are just specialized reduce functions – Keep this in mind as you write your transformations. Don’t use reduce when a map or filter would work instead
  • 27. All contents © MuleSoft Inc. reduce (cont.) 33
  • 28. All contents © MuleSoft Inc. reduce (examples) 34 // Classic example: Adding numbers [1,2,3] reduce ((n, acc) -> acc + n) // -> 6 // A simple joinBy functionality [“1”,”2”,”3”] reduce ((str, out) -> out ++ “, ” ++ str // “1, 2, 3” // The same thing wrapped in a helpful function (I wrap most non-trivial reduce // code in a simple function so that the client does not need to pass a lambda) fun myJoinBy(arr, delim) = arr reduce ((str, out) -> out ++ delim ++ str
  • 29. All contents © MuleSoft Inc. reduce (examples cont.) 35 // Flattening an array into a object (common use case) var arr = [ {dev: "c6824476-b7e2-4e8a-9281-bdc40663bb93"}, {prod: "7f44b450-18ff-45fa-85f3-8ef5c82b4989"} ] --- arr reduce ((env, obj) -> obj ++ env) // -> { ”dev”: “c6824476-b7e2-4e8a-9281-bdc40663bb93”, // “prod”: “7f44b450-18ff-45fa-85f3-8ef5c82b4989” } // You could also do this ($$ defaults to the first value in the array): arr reduce ($$ ++ $)
  • 30. All contents © MuleSoft Inc. reduce (examples cont.) 36 // Make map/filter code more efficient. This loops twice: [1,2,3,4,5] filter (mod($, 2) == 0) map ($ + 2) // -> [4,6] // This loops once and accomplishes the same job [1,2,3,4,5] reduce ((n, acc=[]) -> if (mod(n, 2) == 0) // Filter replacement acc + (n + 2) // Map replacement else acc)
  • 31. All contents © MuleSoft Inc. reduce (examples cont.) 37 // Implement map: fun myMap(arr, transformFn) = arr reduce ((e, acc=[]) -> acc + transformFn(e) // Implement filter: fun myFilter(arr, predicateFn) = arr reduce ((e, acc=[]) -> if (predicateFn(e)) acc + e else acc
  • 33. All contents © MuleSoft Inc. Wrapping map/filter/reduce • Passing functions to functions is nice because of the flexibility, but it’s not always an ideal API because of that flexibility – Reader needs to understand map/filter/reduce, and then understand the workings of passed function • To make functions less flexible, but far more readable, you can do the following 1. Name the functionality that the passed-in function is providing 2. Wrap the map/filter/reduce code in a function 3. Name that function according to the name you came up w/ in step 1 4. Make sure parameters passed to your new function do not take in a lambda
  • 34. All contents © MuleSoft Inc. Example 40 • Let’s take a reduce example from earlier. We start with this: var arr = [{dev: ”123"}, {prod: ”456"}] --- arr reduce ((env, obj={}) -> obj ++ env) // -> {dev: “123”, prod: “456}
  • 35. All contents © MuleSoft Inc. Example (cont.) 41 We will name the function based off of that functionality, and save the client from having to pass in that functionality: fun flattenToObj(arr) = arr reduce (kvPair, obj={}) -> obj ++ kvPair)
  • 36. All contents © MuleSoft Inc. Moving Forward 42 • You can do this with most functions that use map/filter/reduce – e.g. fun removeOdds(arr) = arr filter ($ mod 2 == 0) • This is especially helpful if the functions are going to be reused (put them in a module!) • Might not be as helpful if not reused, but you will get a nice readability boost that comes from effective naming of your functions
  • 38. All contents © MuleSoft Inc. Conclusion 44 • map/filter/reduce are a trio of higher-order functions that form the core of array transformations – Filter is used to remove elements from an array – Map is used to modify elements from an array – Reduce is used to do all the of the above, as well as transform arrays to any other type. Very general-purpose. Reach for this last. • Map and filter tend to be pretty easy to learn, reduce typically requires more practice to master • Master these functions first, then learn mapObject, filterObject, groupBy, pluck
  • 39. All contents © MuleSoft Inc. More Info 45 • MuleSoft documentation: – Map: https://docs.mulesoft.com/mule-runtime/4.1/dw-core-functions-map – Filter: https://docs.mulesoft.com/mule-runtime/4.1/dw-core-functions-filter – Reduce: https://docs.mulesoft.com/mule-runtime/4.1/dw-core-functions-reduce • You can find more detailed information on my blog: – Map post: www.jerney.io/dataweave-the-map-function/ – Filter post: On It’s Way  – Reduce post 1: www.jerney.io/dataweave-when-to-use-reduce/ – Reduce post 2: www.jerney.io/dataweave-mapping-an-array-to-an-object/ – Practice exercises (map/filter/reduce and others): www.jerney.io/dataweave-practice-exercises/
  • 41. All contents © MuleSoft Inc. DataWeave question 47 Which one is not a valid condition in Choice component 1. #[payload.type == 'Mule Meetup'] 2. ${file:complexCondition.dwl} 3. payload.type == 'Mule Meetup' 4. All options are valid :)
  • 42. All contents © MuleSoft Inc. DataWeave question 48 Which one is not a valid condition in Choice component 1. #[payload.type == 'Mule Meetup'] 2. ${file:complexCondition.dwl} 3. payload.type == 'Mule Meetup' 4. All options are valid :) Correct syntax is: ${file::complexCondition.dwl}
  • 45. All contents © MuleSoft Inc. What’s next 51 • Feedback: – Contact your organizer Patryk Bandurski to suggest topics – Contact MuleSoft at meetup@mulesoft.com for ways to improve the program • Our next meetup: – Date: March/April 2019 – Location: PwC Poland – Topic: …
  • 46. All contents © MuleSoft Inc. What’s next 52 Invite your network to join – https://meetups.mulesoft.com/warsaw/
  • 47. See you next time Please send topic suggestions to the organizer

Notas del editor

  1. Hi everyone, thanks for being here today. Today we are going to have talks about XXX, XXX and a special presentation about the various ways to learn about MuleSoft, grow your skills and become certified. Being MuleSoft-certified is clearly a huge asset in the marketplace today, and the Community team at MuleSoft wants to make it easier for all of us to pass a certification exam. Until the end of the year, all Meetup attendees (meaning all of you here today) will receive a free exam for the certification of your choice. Make sure to get your name checked with myself or my co-leader(s), and you’ll receive your voucher via email within 10 days. Without further ado, let’s get started.