LINQ PLINQ Parallel Language Integrated Query AGENDA Introduction
- Slides: 18
LINQ & PLINQ (Parallel) Language Integrated Query
AGENDA Introduction to LINQ basics Overview of advanced capabilities Demo the Basics PLINQ intro Demo of PLINQ
INTRODUCTION LINQ IS. . . A programming model that � Introduces � More � Is leg room! an abstraction level for data � Don’t � Is queries as a “first class” concept into. NET you just love abstraction, it’s great! another tool for embedding SQL queries into code � “This � Allows code was written by a tool” – not that kind of tool! for uniform manipulation of any data type � Consistently producing consistent consistency!
LINQ BREAKDOWN
LINQ BREAKDOWN - COMPILER
LINQ IMPLEMENTATIONS LINQ to Objects � Code (Reflection), Files in File. System LINQ to ADO. NET � LINQ to SQL � LINQ to Data. Set � LINQ to Entities LINQ to XML � XDocument, XElement, XAttribute, XNode, etc � In System. Xml. Linq. Document
MAKING USE OF LINQ
EXCEPTION HANDLING Calling methods where failure is possible Make use of a ‘let’
BUILT IN OPERATORS � Query � � � Order. By. Descending Then. By. Descending Reverse Count, Long. Count Sum, Average Aggregate Min, Max Set Distinct Union, Intersect, Except � Take, Take. While Skip, Skip. While Element Operators Group. By Any, All, Contains Partitioning � Range, Repeat, Empty Quantifiers � Join, Group. Join Generation Aggregate � � Grouping � Select. Many Join Ordering � Where Projection � First, First. Or. Default Last, Last. Or. Default Single, Single. Or. Default Elemenent. At, Element. At. Or. Defatult Default. If. Empty Other Concat Sequence. Equal
EXTENSION METHODS Custom Operators � New Name � Or Override Existing Operators (potentially bad practice) Specialise Existing – For a given type
LINQ DEMO Basics in VS 2010
ADVANCED LINQ Recursive Lambda Expressions � Through the use of Fix fixed-point generator Expression Trees � MSDN Blogs: Mads Torgersen - Recursive Lambda Expressions Visitor Pattern using LINQ � MSDN Blogs: Jomo Fisher – Dealing with LINQs immutable expression trees
PLINQ BACKGROUND Part of managed concurrency library in the. NET Framework Simplify concurrent processing Makes use of the Task Parallel Library (TPL) � TPL in turn uses Parallel. For. Each Parallel. Invoke
OPERATING IN PARALLEL Partitioning � Based on computation and data type Range (Arrays, Lists) – Index into structure, equal split Not the most ideal for load balancing Striped Chunks of input Chunk level load balancing Hash Execution � On available cores Merge Results Initial thread picks up results (consumer thread) � For. All, Async (pipelining), Sync (stop-and-go) � PLINQ takes care of threading events, signalling, concurrency, locking, etc.
PLINQ DEMO Speed up of processing using multiple cores
DEMO Projections Extension Methods Parallel Performance LINQ to XML LINQ to SQL Entities
PLINQ IDEAL SPEEDUP
THANK YOU Questions? More info on my blog; links, “refined wording”: http: //Nick. Josevski. com
- Plinq
- Linq2sql
- Language
- Linqtoxsd
- Iterative query vs recursive query
- Query tree and query graph
- Query tree and query graph
- Language
- Introduction to structured query language (sql)
- Agenda sistemica y agenda institucional
- Vb.net linq
- Reveal linq app
- Linq rank
- Visual basic linq
- Linq vs ado.net
- Linq for c++
- C# linq median
- Vba linq
- Reveal linq