SlideShare ist ein Scribd-Unternehmen logo
1 von 17
What LINQ is aboutor, Playingwith LINQ, MongoDB, and someold new patterns for developers.or, How to injectfunctionalparadigms in imperativelanguagesor, parallelism made easy. WebWorkersCamp, 03/07/2010 Pierre Couzy – Microsoft France
Who are you ? Worked in the Microsoft space for 20 years Speaker, trainer, developer, architect, … Primarilyinterested in Web topics Identity, architecture, WS-*, interop, cloud, … Recentinterop/OSS activity Worked on drupal for Sql server project Works on automateddrupaltesting on Windows Speaker at major PHP events DrupalCon, PHP Forum, Symfony live blog.couzy.com / pierre.couzy@microsoft.com
Agenda LINQ More LINQ LINQ for MongoDB GoingParallel GoingDistributed Q&A Disclosure: This session is heavily Microsoft-Biased (which is to be expected, I work there)
LINQ : Why ? C# is an imperativelanguage Whichisnice Except for a few things Splitting data manipulation betweenyour code and your data store Coding data manipulation Applying new manipulation patterns to existing data
Clumsyc#example
Whatwe’dlikeis Express more intent, lessimplementation Easy composition Strongtyping This issubject to hot debate Be as declarative as possible within the limitsimposed by C#
From C# to LINQ
Things to notice Lazyevaluation If westepintothis code, wesee LINQ triggers itsmagic on demand Easy composition If weadd new clauses after the LINQ expression isbuilt but beforeit’sconsumed, wesimplymerge the additions to the existing expression So far, we’veworked on objects Whichis how manynaive LINQ implementationswork : synchronously pipelining methods calls on collections LINQ has an interesting twist Expression trees
Expression Trees and IQueryable Let’stake the sameexample and introduceAsQueryable() Uponexecution, wecan notice the compiler didn’teatour LINQ expression It’sstill in there, using a tree format (an AbstractSymbolTree) That treewillberesolvedatruntime In the Linq to Objects case, wegetexactly the samebehaviour.  The iteration pattern maystillbeyield-based, but thisisleft to IQueryable’simplementationdetails.
Playingwith expression trees Let’stackleLinq To SQL My expression treeisnowpushed to the database layer If I want to block the flow to SQL, I just have to insert a new node in the tree. Whichallows me to balance things Using C# patterns and methodswhen I wantthem Pushing to the databasewhatitdoes best
IQueryable goodies So, if I wantmythings to be LINQ aware, I caneither Buildsomemethods and let the IEnumerable<T> do its pure objectmagic (I stillgetlazyeval) Or, playwithIQueryable And do myowninterpretation of the tree Let’sseeMongoDB in LINQ
Strongly-typed interaction when querying and updating collections. Improved interface to send common Mongo commands (creating indices, getting all the existing dbs and collections, etc.). Ultra-fast de/serialization of BSON to .Net CLR types and back. LINQ-to-Mongo Support for Mono
LINQ Patterns Having a LINQ Expression isnice: youbasicallydelegate the execution to someoneelse’s code Plus, your LINQ Expressions have every good aspect youusuallyexpectfromfunctionalprogramming (ie, they are closures). So, they are perfectlysuited to parallelisation All you have to do isaddanothernode to the expression tree Demo : AsParallel()
WritingMapReduce in LINQ  public static IQueryable<R>  MapReduce<S,M,K,R>(this IQueryable<S> source,                                 Expression<Func<S,IEnumerable<M>>> mapper,                                 Expression<Func<M,K>> keySelector,                                 Expression<Func<K,IEnumerable<M>,R>> reducer){    return source.SelectMany(mapper).GroupBy(keySelector, reducer);} Notice that the callingsyntax : Source.MapReduce(lMapper, lKeySelector, lReducer)issimply a new nodethatcanbeinserted in a larger expression tree. This MapReducemethodcanrun on N coresusing PLINQ, or on X machines (and N cores per machine) usingDryadLINQ
Collection<T> collection; boolIsLegal(Key k);	 string Hash(Key); var results = from c in collection 	where IsLegal(c.key) 	select new { Hash(c.key), c.value}; DryadLINQ = LINQ + Dryad Vertexcode Queryplan (Dryad job) Data collection C# C# C# C# results
Parallel execution var logentries =         from line in logs where !line.StartsWith("#") select new LogEntry(line); var user =          from access in logentries where access.user.EndsWith(@"lfar") select access; var accesses = from access in user group access by access.page into pages select new UserPageCount("ulfar", pages.Key, pages.Count()); var htmAccesses = from access in accesses where access.page.EndsWith(".htm") orderby access.count descending select access;
Thanks.

Weitere ähnliche Inhalte

Andere mochten auch

EventMachine
EventMachineEventMachine
EventMachineLeTesteur
 
RxJs - Reactive Extensions for JavaScript
RxJs - Reactive Extensions for JavaScriptRxJs - Reactive Extensions for JavaScript
RxJs - Reactive Extensions for JavaScriptLeTesteur
 
MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)Karthik .P.R
 
Using Netezza Query Plan to Improve Performace
Using Netezza Query Plan to Improve PerformaceUsing Netezza Query Plan to Improve Performace
Using Netezza Query Plan to Improve PerformaceBiju Nair
 
Apache Hive Hook
Apache Hive HookApache Hive Hook
Apache Hive HookMinwoo Kim
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Beat Signer
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Sadayuki Furuhashi
 

Andere mochten auch (9)

EventMachine
EventMachineEventMachine
EventMachine
 
1 query processing
1 query processing1 query processing
1 query processing
 
Query execution
Query executionQuery execution
Query execution
 
RxJs - Reactive Extensions for JavaScript
RxJs - Reactive Extensions for JavaScriptRxJs - Reactive Extensions for JavaScript
RxJs - Reactive Extensions for JavaScript
 
MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)
 
Using Netezza Query Plan to Improve Performace
Using Netezza Query Plan to Improve PerformaceUsing Netezza Query Plan to Improve Performace
Using Netezza Query Plan to Improve Performace
 
Apache Hive Hook
Apache Hive HookApache Hive Hook
Apache Hive Hook
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
 
Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014Presto - Hadoop Conference Japan 2014
Presto - Hadoop Conference Japan 2014
 

Ähnlich wie What linq is about

CNCF, State of Serverless & Project Nuclio
CNCF, State of Serverless & Project NuclioCNCF, State of Serverless & Project Nuclio
CNCF, State of Serverless & Project NuclioLee Calcote
 
Metaflow: The ML Infrastructure at Netflix
Metaflow: The ML Infrastructure at NetflixMetaflow: The ML Infrastructure at Netflix
Metaflow: The ML Infrastructure at NetflixBill Liu
 
.NET per la Data Science e oltre
.NET per la Data Science e oltre.NET per la Data Science e oltre
.NET per la Data Science e oltreMarco Parenzan
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?Colin Riley
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
A Linux Enthusiast's Perspective on Microsoft OSS & Azure
A Linux Enthusiast's Perspective on Microsoft OSS & AzureA Linux Enthusiast's Perspective on Microsoft OSS & Azure
A Linux Enthusiast's Perspective on Microsoft OSS & AzureMicheal Colhoun
 
From hello world to goodbye code
From hello world to goodbye codeFrom hello world to goodbye code
From hello world to goodbye codeKim Moir
 
LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) Sascha Sambale
 
Going open source with small teams
Going open source with small teamsGoing open source with small teams
Going open source with small teamsJamie Thomas
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java ProgrammingKaty Allen
 
Engineering muscle training interface
Engineering muscle training interfaceEngineering muscle training interface
Engineering muscle training interfacerina0521
 
WannaEat: A computer vision-based, multi-platform restaurant lookup app
WannaEat: A computer vision-based, multi-platform restaurant lookup appWannaEat: A computer vision-based, multi-platform restaurant lookup app
WannaEat: A computer vision-based, multi-platform restaurant lookup appRakuten Group, Inc.
 
React Conf 17 Recap
React Conf 17 RecapReact Conf 17 Recap
React Conf 17 RecapAlex Babkov
 

Ähnlich wie What linq is about (20)

TechDayConf Edition 1 - 2020
TechDayConf Edition 1 -  2020TechDayConf Edition 1 -  2020
TechDayConf Edition 1 - 2020
 
Open source Technology
Open source TechnologyOpen source Technology
Open source Technology
 
CNCF, State of Serverless & Project Nuclio
CNCF, State of Serverless & Project NuclioCNCF, State of Serverless & Project Nuclio
CNCF, State of Serverless & Project Nuclio
 
Metaflow: The ML Infrastructure at Netflix
Metaflow: The ML Infrastructure at NetflixMetaflow: The ML Infrastructure at Netflix
Metaflow: The ML Infrastructure at Netflix
 
.NET per la Data Science e oltre
.NET per la Data Science e oltre.NET per la Data Science e oltre
.NET per la Data Science e oltre
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
A Linux Enthusiast's Perspective on Microsoft OSS & Azure
A Linux Enthusiast's Perspective on Microsoft OSS & AzureA Linux Enthusiast's Perspective on Microsoft OSS & Azure
A Linux Enthusiast's Perspective on Microsoft OSS & Azure
 
From hello world to goodbye code
From hello world to goodbye codeFrom hello world to goodbye code
From hello world to goodbye code
 
CI back to basis
CI back to basisCI back to basis
CI back to basis
 
LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :)
 
Build 2019 Recap
Build 2019 RecapBuild 2019 Recap
Build 2019 Recap
 
Mini .net conf 2020
Mini .net conf 2020Mini .net conf 2020
Mini .net conf 2020
 
Going open source with small teams
Going open source with small teamsGoing open source with small teams
Going open source with small teams
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
Developer Efficiency
Developer EfficiencyDeveloper Efficiency
Developer Efficiency
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
 
Engineering muscle training interface
Engineering muscle training interfaceEngineering muscle training interface
Engineering muscle training interface
 
WannaEat: A computer vision-based, multi-platform restaurant lookup app
WannaEat: A computer vision-based, multi-platform restaurant lookup appWannaEat: A computer vision-based, multi-platform restaurant lookup app
WannaEat: A computer vision-based, multi-platform restaurant lookup app
 
React Conf 17 Recap
React Conf 17 RecapReact Conf 17 Recap
React Conf 17 Recap
 

Mehr von LeTesteur

Drupal en environnement microsoft
Drupal en environnement microsoftDrupal en environnement microsoft
Drupal en environnement microsoftLeTesteur
 
Développer et déployer WordPress en environnement microsoft
Développer et déployer WordPress en environnement microsoftDévelopper et déployer WordPress en environnement microsoft
Développer et déployer WordPress en environnement microsoftLeTesteur
 
Développer et déployer une application php maintenable
Développer et déployer une application php maintenableDévelopper et déployer une application php maintenable
Développer et déployer une application php maintenableLeTesteur
 
Web dev open door
Web dev   open doorWeb dev   open door
Web dev open doorLeTesteur
 
Joomla Days 2011 Lyon
Joomla Days 2011 LyonJoomla Days 2011 Lyon
Joomla Days 2011 LyonLeTesteur
 
Drupal in the cloud with Windows Azure
Drupal in the cloud with Windows AzureDrupal in the cloud with Windows Azure
Drupal in the cloud with Windows AzureLeTesteur
 
Php sous Windows - webcamps Paris
Php sous Windows - webcamps ParisPhp sous Windows - webcamps Paris
Php sous Windows - webcamps ParisLeTesteur
 
Web Matrix (Microsoft WebCamps Paris)
Web Matrix (Microsoft WebCamps Paris)Web Matrix (Microsoft WebCamps Paris)
Web Matrix (Microsoft WebCamps Paris)LeTesteur
 
PHP Forum 2010 : Php et microsoft
PHP Forum 2010 : Php et microsoftPHP Forum 2010 : Php et microsoft
PHP Forum 2010 : Php et microsoftLeTesteur
 
Eclipse day paris
Eclipse day parisEclipse day paris
Eclipse day parisLeTesteur
 
Comment approcherlecloud
Comment approcherlecloudComment approcherlecloud
Comment approcherlecloudLeTesteur
 

Mehr von LeTesteur (11)

Drupal en environnement microsoft
Drupal en environnement microsoftDrupal en environnement microsoft
Drupal en environnement microsoft
 
Développer et déployer WordPress en environnement microsoft
Développer et déployer WordPress en environnement microsoftDévelopper et déployer WordPress en environnement microsoft
Développer et déployer WordPress en environnement microsoft
 
Développer et déployer une application php maintenable
Développer et déployer une application php maintenableDévelopper et déployer une application php maintenable
Développer et déployer une application php maintenable
 
Web dev open door
Web dev   open doorWeb dev   open door
Web dev open door
 
Joomla Days 2011 Lyon
Joomla Days 2011 LyonJoomla Days 2011 Lyon
Joomla Days 2011 Lyon
 
Drupal in the cloud with Windows Azure
Drupal in the cloud with Windows AzureDrupal in the cloud with Windows Azure
Drupal in the cloud with Windows Azure
 
Php sous Windows - webcamps Paris
Php sous Windows - webcamps ParisPhp sous Windows - webcamps Paris
Php sous Windows - webcamps Paris
 
Web Matrix (Microsoft WebCamps Paris)
Web Matrix (Microsoft WebCamps Paris)Web Matrix (Microsoft WebCamps Paris)
Web Matrix (Microsoft WebCamps Paris)
 
PHP Forum 2010 : Php et microsoft
PHP Forum 2010 : Php et microsoftPHP Forum 2010 : Php et microsoft
PHP Forum 2010 : Php et microsoft
 
Eclipse day paris
Eclipse day parisEclipse day paris
Eclipse day paris
 
Comment approcherlecloud
Comment approcherlecloudComment approcherlecloud
Comment approcherlecloud
 

Kürzlich hochgeladen

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
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
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Kürzlich hochgeladen (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

What linq is about

  • 1. What LINQ is aboutor, Playingwith LINQ, MongoDB, and someold new patterns for developers.or, How to injectfunctionalparadigms in imperativelanguagesor, parallelism made easy. WebWorkersCamp, 03/07/2010 Pierre Couzy – Microsoft France
  • 2. Who are you ? Worked in the Microsoft space for 20 years Speaker, trainer, developer, architect, … Primarilyinterested in Web topics Identity, architecture, WS-*, interop, cloud, … Recentinterop/OSS activity Worked on drupal for Sql server project Works on automateddrupaltesting on Windows Speaker at major PHP events DrupalCon, PHP Forum, Symfony live blog.couzy.com / pierre.couzy@microsoft.com
  • 3. Agenda LINQ More LINQ LINQ for MongoDB GoingParallel GoingDistributed Q&A Disclosure: This session is heavily Microsoft-Biased (which is to be expected, I work there)
  • 4. LINQ : Why ? C# is an imperativelanguage Whichisnice Except for a few things Splitting data manipulation betweenyour code and your data store Coding data manipulation Applying new manipulation patterns to existing data
  • 6. Whatwe’dlikeis Express more intent, lessimplementation Easy composition Strongtyping This issubject to hot debate Be as declarative as possible within the limitsimposed by C#
  • 7. From C# to LINQ
  • 8. Things to notice Lazyevaluation If westepintothis code, wesee LINQ triggers itsmagic on demand Easy composition If weadd new clauses after the LINQ expression isbuilt but beforeit’sconsumed, wesimplymerge the additions to the existing expression So far, we’veworked on objects Whichis how manynaive LINQ implementationswork : synchronously pipelining methods calls on collections LINQ has an interesting twist Expression trees
  • 9. Expression Trees and IQueryable Let’stake the sameexample and introduceAsQueryable() Uponexecution, wecan notice the compiler didn’teatour LINQ expression It’sstill in there, using a tree format (an AbstractSymbolTree) That treewillberesolvedatruntime In the Linq to Objects case, wegetexactly the samebehaviour. The iteration pattern maystillbeyield-based, but thisisleft to IQueryable’simplementationdetails.
  • 10. Playingwith expression trees Let’stackleLinq To SQL My expression treeisnowpushed to the database layer If I want to block the flow to SQL, I just have to insert a new node in the tree. Whichallows me to balance things Using C# patterns and methodswhen I wantthem Pushing to the databasewhatitdoes best
  • 11. IQueryable goodies So, if I wantmythings to be LINQ aware, I caneither Buildsomemethods and let the IEnumerable<T> do its pure objectmagic (I stillgetlazyeval) Or, playwithIQueryable And do myowninterpretation of the tree Let’sseeMongoDB in LINQ
  • 12. Strongly-typed interaction when querying and updating collections. Improved interface to send common Mongo commands (creating indices, getting all the existing dbs and collections, etc.). Ultra-fast de/serialization of BSON to .Net CLR types and back. LINQ-to-Mongo Support for Mono
  • 13. LINQ Patterns Having a LINQ Expression isnice: youbasicallydelegate the execution to someoneelse’s code Plus, your LINQ Expressions have every good aspect youusuallyexpectfromfunctionalprogramming (ie, they are closures). So, they are perfectlysuited to parallelisation All you have to do isaddanothernode to the expression tree Demo : AsParallel()
  • 14. WritingMapReduce in LINQ public static IQueryable<R>  MapReduce<S,M,K,R>(this IQueryable<S> source,                                 Expression<Func<S,IEnumerable<M>>> mapper,                                 Expression<Func<M,K>> keySelector,                                 Expression<Func<K,IEnumerable<M>,R>> reducer){    return source.SelectMany(mapper).GroupBy(keySelector, reducer);} Notice that the callingsyntax : Source.MapReduce(lMapper, lKeySelector, lReducer)issimply a new nodethatcanbeinserted in a larger expression tree. This MapReducemethodcanrun on N coresusing PLINQ, or on X machines (and N cores per machine) usingDryadLINQ
  • 15. Collection<T> collection; boolIsLegal(Key k); string Hash(Key); var results = from c in collection where IsLegal(c.key) select new { Hash(c.key), c.value}; DryadLINQ = LINQ + Dryad Vertexcode Queryplan (Dryad job) Data collection C# C# C# C# results
  • 16. Parallel execution var logentries = from line in logs where !line.StartsWith("#") select new LogEntry(line); var user = from access in logentries where access.user.EndsWith(@"lfar") select access; var accesses = from access in user group access by access.page into pages select new UserPageCount("ulfar", pages.Key, pages.Count()); var htmAccesses = from access in accesses where access.page.EndsWith(".htm") orderby access.count descending select access;