These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
Lambda and Stream Master class - part 1José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This first part covers Lambda Expressions and API design with functional interfaces.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
The features released between Java 11 and Java 17 have brought a greater opportunity for developers to improve application development productivity as well and code expressiveness and readability. In this deep-dive session, you will discover all the recent Project Amber features added to the Java language such as Records (including Records serialization), Pattern Matching for `instanceof`, switch expression, sealed classes, and hidden classes. The main goal of the Amber Project is to bring Pattern Matching to the Java platform, which will impact both the language and the JDK APsI. You will discover record patterns, array patterns, as well as deconstruction patterns, through constructors, factory methods, and deconstructors.
You can find the code shown here: https://github.com/JosePaumard/devoxx-uk-2021
Les slides de ma présentation à Devoxx France 2017.
Introduite en Java 8, l'API Collector vit dans l'ombre de l'API Stream, ce qui est logique puisqu'un collecteur doit se connecter à un stream pour fonctionner. Le JDK est organisé de sorte que l'on utilise surtout les collectors sur étagère : groupingBy, counting et quelques autres. Ces deux éléments masquent non seulement le modèle de traitement de données des collectors, mais aussi sa puissance et ses performances.
Ces présentation parle des collectors qui existent et qu'il faut connaître, ceux que l'on peut créer, ceux dont on se doute que l'on peut les créer une fois que l'on comprend un peu les choses, et les autres, tant les possibilités offertes par cette API sont illimitées.
The slides of my talk at Devoxx BE 2017. This in depth talk is all about collectors: those available, because we need to know them, those that we can create, those we had no idea they could be created, and the others, as there is in fact no limit to what can be done with this API. The concept of downstream collector will be used to show how we can write entire data processing pipelines using collectors only, and pass them as parameters to other pipelines.
Lambda and Stream Master class - part 1José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This first part covers Lambda Expressions and API design with functional interfaces.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
The features released between Java 11 and Java 17 have brought a greater opportunity for developers to improve application development productivity as well and code expressiveness and readability. In this deep-dive session, you will discover all the recent Project Amber features added to the Java language such as Records (including Records serialization), Pattern Matching for `instanceof`, switch expression, sealed classes, and hidden classes. The main goal of the Amber Project is to bring Pattern Matching to the Java platform, which will impact both the language and the JDK APsI. You will discover record patterns, array patterns, as well as deconstruction patterns, through constructors, factory methods, and deconstructors.
You can find the code shown here: https://github.com/JosePaumard/devoxx-uk-2021
Les slides de ma présentation à Devoxx France 2017.
Introduite en Java 8, l'API Collector vit dans l'ombre de l'API Stream, ce qui est logique puisqu'un collecteur doit se connecter à un stream pour fonctionner. Le JDK est organisé de sorte que l'on utilise surtout les collectors sur étagère : groupingBy, counting et quelques autres. Ces deux éléments masquent non seulement le modèle de traitement de données des collectors, mais aussi sa puissance et ses performances.
Ces présentation parle des collectors qui existent et qu'il faut connaître, ceux que l'on peut créer, ceux dont on se doute que l'on peut les créer une fois que l'on comprend un peu les choses, et les autres, tant les possibilités offertes par cette API sont illimitées.
The slides of my talk at Devoxx BE 2017. This in depth talk is all about collectors: those available, because we need to know them, those that we can create, those we had no idea they could be created, and the others, as there is in fact no limit to what can be done with this API. The concept of downstream collector will be used to show how we can write entire data processing pipelines using collectors only, and pass them as parameters to other pipelines.
Most of us use Design Patterns on a daily basis without noticing. Design patterns are commonly defined as solutions to recurring design problems. Frameworks like Laravel use Design Patterns throughout the codebase to keep structure and maintainability. In this talk we will explore the Design Patterns used in Laravel.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
The features released between Java 11 and Java 17 have brought a greater opportunity for developers to improve application development productivity as well and code expressiveness and readability. In this deep-dive session, you will discover all the recent Project Amber features added to the Java language such as Text blocks, Records (including Records serialization), Pattern Matching for instanceof, switch expression, sealed classes, and pattern matching for switch. The main goal of the Amber Project is to bring Pattern Matching to the Java platform, which will impact both the language and the JDK APIs. You will discover record patterns, array patterns, as well as deconstruction patterns, through constructors, factory methods, and deconstructors.
In this Meetup Victor Perepelitsky - R&D Technical Leader at LivePerson leading the 'Real Time Event Processing Platform' team , will talk about Java 8', 'Stream API', 'Lambda', and 'Method reference'.
Victor will clarify what functional programming is and how can you use java 8 in order to create better software.
Victor will also cover some pain points that Java 8 did not solve regarding functionality and see how you can work around it.
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Java Collections” will talk about the complete hierarchy of Collections Frameworks in Java. It will walk you through the various fundamentals of collections like Lists, Queue, Sets, Interfaces etc. Through this tutorial you will learn the following topics:
Java Collection Framework
Collection Framework Hierarchy
Interfaces
List
Queue
Set
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
Java 8 is coming soon. In this presentation I have outlined the major Java 8 features. You get information about interface improvements, functional interfaces, method references, lambdas, java.util.function, java.util.stream
HashMap is a part of Java's collection.. It provides the basic implementation of Map interface of Java. It stores the data in (Key, Value) pairs. To access a value key should be known. This ppt dives deep into the internal working of Hashmaps.
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafThymeleaf
Introduction to the Thymeleaf java XML/XHTML/HTML5 template engine by José Miguel Samper and Daniel Fernández at Spring I/O 2012 Madrid, Feb 17th 2012.
This talk introduces Spring's REST stack - Spring MVC, Spring HATEOAS, Spring Data REST, Spring Security OAuth and Spring Social - while refining an API to move higher up the Richardson maturity model
Most of us use Design Patterns on a daily basis without noticing. Design patterns are commonly defined as solutions to recurring design problems. Frameworks like Laravel use Design Patterns throughout the codebase to keep structure and maintainability. In this talk we will explore the Design Patterns used in Laravel.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
The features released between Java 11 and Java 17 have brought a greater opportunity for developers to improve application development productivity as well and code expressiveness and readability. In this deep-dive session, you will discover all the recent Project Amber features added to the Java language such as Text blocks, Records (including Records serialization), Pattern Matching for instanceof, switch expression, sealed classes, and pattern matching for switch. The main goal of the Amber Project is to bring Pattern Matching to the Java platform, which will impact both the language and the JDK APIs. You will discover record patterns, array patterns, as well as deconstruction patterns, through constructors, factory methods, and deconstructors.
In this Meetup Victor Perepelitsky - R&D Technical Leader at LivePerson leading the 'Real Time Event Processing Platform' team , will talk about Java 8', 'Stream API', 'Lambda', and 'Method reference'.
Victor will clarify what functional programming is and how can you use java 8 in order to create better software.
Victor will also cover some pain points that Java 8 did not solve regarding functionality and see how you can work around it.
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Java Collections” will talk about the complete hierarchy of Collections Frameworks in Java. It will walk you through the various fundamentals of collections like Lists, Queue, Sets, Interfaces etc. Through this tutorial you will learn the following topics:
Java Collection Framework
Collection Framework Hierarchy
Interfaces
List
Queue
Set
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
Java 8 is coming soon. In this presentation I have outlined the major Java 8 features. You get information about interface improvements, functional interfaces, method references, lambdas, java.util.function, java.util.stream
HashMap is a part of Java's collection.. It provides the basic implementation of Map interface of Java. It stores the data in (Key, Value) pairs. To access a value key should be known. This ppt dives deep into the internal working of Hashmaps.
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafThymeleaf
Introduction to the Thymeleaf java XML/XHTML/HTML5 template engine by José Miguel Samper and Daniel Fernández at Spring I/O 2012 Madrid, Feb 17th 2012.
This talk introduces Spring's REST stack - Spring MVC, Spring HATEOAS, Spring Data REST, Spring Security OAuth and Spring Social - while refining an API to move higher up the Richardson maturity model
Presentation on the new features introduced in JDK 8, presented on the 26.02.2013 in Sofia University in front of students and members of the Bulgarian java user group.
Stata cheat sheet: programming. Co-authored with Tim Essam (linkedin.com/in/timessam). See all cheat sheets at http://bit.ly/statacheatsheets. Updated 2016/06/04
This presentaion provides and overview of the new features of Java 8, namely default methods, functional interfaces, lambdas, method references, streams and Optional vs NullPointerException.
This presentation by Arkadii Tetelman (Lead Software Engineer, GlobalLogic) was delivered at Java.io 3.0 conference in Kharkiv on March 22, 2016.
This presentation will give you Information about :
1. Map/Reduce Overview and Architecture Installation
2. Developing Map/Red Jobs Input and Output Formats
3. Job Configuration Job Submission
4. Practicing Map Reduce Programs (atleast 10 Map Reduce
5. Algorithms )Data Flow Sources and Destinations
6. Data Flow Transformations Data Flow Paths
7. Custom Data Types
8. Input Formats
9. Output Formats
10. Partitioning Data
11. Reporting Custom Metrics
12. Distributing Auxiliary Job Data
Hadoop became the most common systm to store big data.
With Hadoop, many supporting systems emerged to complete the aspects that are missing in Hadoop itself.
Together they form a big ecosystem.
This presentation covers some of those systems.
While not capable to cover too many in one presentation, I tried to focus on the most famous/popular ones and on the most interesting ones.
Similar to Lambdas and Streams Master Class Part 2 (20)
The Loom project has been under work for many years, and just delivered Virtual Threads as a preview feature in the JDK 19. We now have a very precise idea of what they are and what you can do with them. Our good old Threads, created more than 25 years ago, will see a new kind of lightweight threads. This presentation shows you that creating a thread is easier and much cheaper, allowing the creation of millions of them in a single JVM. These virtual threads can be block at almost no cost. These new virtual threads bring with them new notions that will be covered in this talk. Loom threads are coming, and they will change the landscape of concurrent programming in Java.
The Future of Java: Records, Sealed Classes and Pattern MatchingJosé Paumard
The release of the JDK 17 brings interesting features in the Java language: sealed types and pattern matching for switch. Along with the introduction of records, the implementation of pattern matching in the Java language begins to take shape. This presentation shows you how records, sealed types, and pattern matching can change the way we write Java code, on real patterns. It also shows you what we can expect to see on this topic in the future. It is mostly a live coding presentation, with some slides when the code is shown cannot be executed.
Designing functional and fluent API: application to some GoF patternsJosé Paumard
These are the slides of my Devnexus 2020 talk. The code is avaiblable on my GitHub account: https://github.com/JosePaumard/devnexus-2020-visitor-lambda. You can see a replay of this talk (in a slightly different version) here: https://youtu.be/gq23w9nycBs
Those are the slides of the presentation we made with Maurice Naftalin à Goto: Copenhagen 2019.
Functional programmers have been saying for decades that they know the way to the future. Clearly they've been wrong, since imperative languages are still far more popular. Clearly they've also been right, as the advantages of functional programming have become increasingly obvious. Is it possible to combine the two models? Scala is one language that does this, and Java too has been on a journey, which still continues, of learning from functional languages and carefully adding features from them. In this talk, we'll review what Java has learned from functional languages, what it can still learn, and how its added features compare to Scala's original ones.
Slides from the talk we did with Maurice Naftalin for Devoxx Belgium 2019.
Functional programmers have been saying for decades that they know the way to the future.
Clearly they have been wrong, since imperative languages are still far more popular.
Clearly they have also been right, as the advantages of functional programming have become increasingly obvious. Is it possible to face both ways, and combine the two models?
Scala is one language that does this, and Java too has been on a journey, which still continues, of learning from functional languages and carefully adding features from them.
In this talk, we will review what Java has learned from functional languages, what it can still learn, and how its added features compare to Scala's original ones.
Designing functional and fluent API: example of the Visitor PatternJosé Paumard
This is the slide deck of my talk from Devoxx Belgium 2019. You can watch the video here https://www.youtube.com/watch?v=gq23w9nycBs and get the code here: https://github.com/JosePaumard/devoxx-belgium-2019-visitor-lambda.
Among the patterns from the GoF, the Visitor is probably the more complex to implement. One of the difficulties is that you need to implement it in your object model, leading to complex refactoring for legacy applications. Based on the use of all the nifty tools brought by functional programming: chaining, composition, and partial application, you can implement Visitors without having to change your object model, using a functional and fluent API. This approach can be used to implement other patterns: Builder and Validator. Using this way of designing API leads to readable and robust code, designed following the GoF patterns.
Les slides du Tools in Action que j'ai donné à Devoxx France 2019.
Le JDK est open source et son développement aussi. L'ensemble des nouveautés vit sur des branches Mercurial qui peuvent être téléchargées et compilées à la demande. Cela permet de jouer avec des fonctionnalités encore en chantier, de regarder comment les nouvelles syntaxes fonctionneront, bref, de jouer avec un JDK du futur, qui n'existera peut-être jamais. L'objet de ce tools in action est simple : montrer comment tout ceci fonctionne, de l'installation d'une machine Ubuntu à l'exécution d'un JDK recompilé maison.
Le slide deck de l'Université que nous avons donnée avec Rémi Forax à Devoxx France 2019.
Comme promis, Java sort sa version majeure tous les 6 mois. Le train passe et amène son lot de nouveautés. Parmi elles, certaines sont sorties : une nouvelle syntaxe pour les clauses switch et l'instruction de byte code CONSTANT_DYNAMIC. D'autres sont en chantier, plus ou moins avancé : une nouvelle façon d'écrire des méthodes de façon condensée, un instanceof 'intelligent', des constantes évaluées au moment où elles sont utilisées. Les projets progressent. Loom, et son nouveau modèle de programmation concurrente que l'ont peut tester avec Jetty. Amber, qui introduit les data types et des nouvelles syntaxes. Valhalla, dont les value types donnent leurs premiers résultats. S'il est difficile de prévoir une date de sortie pour ces nouveautés, on sait en revanche qu'une fois prêtes elles sortiront en moins de 6 mois. De tout ceci nous parlerons donc au futur et en public, avec des démonstrations de code, des slides, du code, de la joie et de la bonne humeur !
Slides of the talk we gave with David Delabassee at Oracle Code One 2018.
The FnProject was released about a year ago, proposing new ways to design asynchronous systems in a very flexible way. This tutorial shows you how to set up a Fn Server on a local development machine running Windows with a first simple function. Then we cover the design of multi-functions systems, connected together in an asynchronous way, leveraging the Fn Flow API. This API is first presented, including how it compares to the the Java 8 CompletableFuture API. We then set up a real example made of several functions, producing multiple results and see how we can leverage their asynchronous nature to make a non-blocking system, handling errors in a simple and intuitive way. Most of the examples are shown both on slides and live coding parts.
Avec la version 9 sortie en septembre 2017, Java appuie sur la pédale ! Le rythme des livraisons passe à une version majeure tous les 6 mois. Java 10 est sorti en mars, prochaine version en septembre. Java 10 apporte le 'var' et l'inférence de type pour les variables locales. D'autres nouveautés sont en préparation : les constantes dynamiques, les classes de données, un nouveau switch à base de lambda, des interfaces fermées, de nouvelles choses du coté des génériques et bien plus encore.
Cela viendra-t-il en 11, 12, 15 ? Ne spéculons pas, mais quand ces nouveautés seront prêtes, elles sortiront en quelques mois. On se propose de présenter ces nouveautés, celles qui sont presque prêtes, celles qui seront prêtes bientôt, et celles qui ne seront pas prêtes avant un moment. Quels seront les impacts sur le langage, sur la JVM et donc sur les performances ? Que cela va-t-il nous apporter au quotidien, en tant que développeurs ? Quels seront les nouveaux patterns ? Voici le programme de cette présentation, avec des slides, du code, de la joie et de la bonne humeur !
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
This session explains how JAX-RS and CDI became reactive capable in Java EE 8. We put some new features of JAX-RS 2.1 and CDI 2.0 into perspective and show some reactive patterns to improve your application. Add Java 8 CompletionStage to the mix and this API trio becomes your best bet to easily go reactive without leaving the Java EE train.
The slides of my Java One 2017 talk about the Spliterator Patterns, or, how to extend the Stream API using the Spliterator API.
The video is available on YouTube: https://www.youtube.com/watch?v=xgHGpsubL5M
The slides of my JavaOne 2017 talk. It describes how you can create API using functional interfaces, default and static methods starting with Java 8. You can watch the video here: https://www.youtube.com/watch?v=64UO1YjVcZ0
The slides of my university talk, Devoxx Belgium 2016.
The goal of this talk is to compare the two most popular implementations of List: LinkedList and ArrayList, and provide hints on which one to use in what case.
The slides of my JavaOne 2016 talk. This talk is a tutorial on how to write lambda expressions, how to compose them using default methods in functional interfaces, and how to create factory methods in those interfaces. Many examples and patterns are provided.
ArrayList et LinkedList sont dans un bateauJosé Paumard
Slides de mon université à Devoxx France 2016. Le sujet est la performance des algorithmes d'implémentation de List et leur adéquation avec la structure des CPU actuels.
Slides of the talk we made with David Delabasee (@delabassee) at Devoxx 2015. A list of Java SE 8 patterns that you can use in Java EE 7 applications, thanks to the support of the major app servers.
Asynchronous API in Java8, how to use CompletableFutureJosé Paumard
Slides of my talk as Devoxx 2015. How to set up asynchronous data processing pipelines using the CompletionStage / CompletableFuture API, including how to control threads and how to handle exceptions.
The slides of my university talk at Devoxx BE 2015. Presentation of the Java 8 Stream API and RxJava, pattern and performance comparisons. Presentation of the upcoming reactive API in Java 9: the Flow API.
The spliterators patterns can be found here: https://github.com/JosePaumard/jdk8-spliterators.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
5. #LambdaHOL#Devoxx
Lambda/Streams Master Class 2
Setup
Map, Filter, FlatMap
Reduction, Function combination
Collectors.toMap()
Collectors.groupingBy()
Cascading Collectors
Streaming a Map
Streaming over Indexes
6. #LambdaHOL#Devoxx
Back to the Comparator
How to deal with null names?
Comparator<Person> cmp = Comparator.comparing(Person::getLastName)
.thenComparing(Person::getFirstName)
.thenComparing(Person::getAge);
7. #LambdaHOL#Devoxx
Back to the Comparator
In fact, this comparator:
Is equivalent to this one:
Comparator.comparing(Person::getLastName)
Comparator.comparing(Person::getLastName, Comparator.naturalOrder())
8. #LambdaHOL#Devoxx
Back to the Comparator
This allows this pattern:
So, to deal with null values:
Comparator.comparing(Person::getLastName,
Comparator.nullsLast(Comparator.naturalOrder()))
Comparator.comparing(Person::getLastName,
Comparator.comparing(String::length))
9. #LambdaHOL#Devoxx
Back to the Comparator
If we need to deal with null Person objects and
null names:
Comparator.nullsLast(
Comparator.comparing(Person::getLastName,
Comparator.nullsLast(Comparator.naturalOrder())
)
)
11. #LambdaHOL#Devoxx
The LambdaHOL
You can find it here
https://github.com/stuart-marks/LambdaHOLv2
https://github.com/JosePaumard/lambda-master-class-part2
https://github.com/JosePaumard/lambda-master-class-part1
13. #LambdaHOL#Devoxx
Input Data — Sonnet
List<String> sonnet = List.of(
"From fairest creatures we desire increase,",
"That thereby beauty's rose might never die,",
"But as the riper should by time decease,",
"His tender heir might bear his memory:",
"But thou contracted to thine own bright eyes,",
"Feed'st thy light's flame with self-substantial fuel,",
"Making a famine where abundance lies,",
"Thy self thy foe, to thy sweet self too cruel:",
"Thou that art now the world's fresh ornament,",
"And only herald to the gaudy spring,",
"Within thine own bud buriest thy content,",
"And, tender churl, mak'st waste in niggarding:",
"Pity the world, or else this glutton be,",
"To eat the world's due, by the grave and thee.");
19. #LambdaHOL#Devoxx
FlatMap
• Intermediate stream operation
• Consumes one element
• May produce zero or more elements
• Compare to map: consumes one, produces
one
• How is zero-or-more represented? A stream!
• T ⇒ Stream<R>
20. #LambdaHOL#Devoxx
FlatMap
Given a list of strings...
[alfa, bravo, charlie, ...]
expand each string to a list of one-letter strings
[ [a, l, f, a], [b, r, a, v, o], [c, h, ...] ... ]
but «flatten» the nesting structure
[a, l, f, a, b, r, a, v, o, c, h, ...]
22. #LambdaHOL#Devoxx
FlatMap
[a, l, f, a, b, r, a, v, o, c, h, a, r, l, i, e, d, e, l, ...]
List<String> flatMap2() {
return alphabet.stream()
.flatMap(word -> expand(word).stream())
.collect(toList());
}
23. #LambdaHOL#Devoxx
FlatMap — Exercise
Split each line of the sonnet into words, and
then collect all the words into a single list.
To split a line into words, use
line.split(" +")
note: this returns an array, not a list or stream
24. #LambdaHOL#Devoxx
FlatMap — Solution
Split each line of the sonnet into words, and then
collect all the words into a single list.
[From, fairest, creatures, we, desire, increase, ...]
total 106 words
List<String> flatMapSolution() {
return sonnet.stream()
.flatMap(line -> Arrays.stream(line.split(" +")))
.collect(toList());
}
27. #LambdaHOL#Devoxx
Computing Factorials
Compute the factorial as a BigInteger using
streams and reduction
long number = 21;
BigInteger result = LongStream.rangeClosed(1, 21)
.mapToObj(BigInteger::valueOf)
.reduce(BigInteger.ONE, BigInteger::multiply);
// result is 51_090_942_171_709_440_000
29. #LambdaHOL#Devoxx
Function Combination
Suppose you have a shopping website where
the customer can apply a filter to limit the
products shown.
List<Product> show(Predicate<Product> predicate) {
return getAllProducts().stream()
.filter(predicate)
.collect(toList());
}
30. #LambdaHOL#Devoxx
Function Combination
Suppose you want the customer to be able to
apply two filters to the product list.
Now, how about three filters?
List<Product> show(Predicate<Product> p1, Predicate<Product> p2) {
return getAllProducts().stream()
.filter(p1.and(p2))
.collect(toList());
}
31. #LambdaHOL#Devoxx
Function Combination
Two predicates can be combined using the
Predicate.and() method.
This is all we need to write a method that
combines an arbitrary number of predicates.
Predicate<Product> p1 = ... ;
Predicate<Product> p2 = ... ;
Predicate<Product> combined = p1.and(p2);
32. #LambdaHOL#Devoxx
Function Combination
Reduction of a list over an operator applies that
operator between each element.
Predicate<Product> combine(List<Predicate<Product>> predicates) {
Predicate<Product> temp = product -> true;
for (Predicate<Product> cur : predicates) {
temp = temp.and(cur);
}
return temp;
}
33. #LambdaHOL#Devoxx
Function Combination
Reduction of a list over an operator applies that
operator between each element.
Predicate<Product> combine(List<Predicate<Product>> predicates) {
return predicates.stream()
.reduce(product -> true, Predicate::and);
}
34. #LambdaHOL#Devoxx
Function Combination
Now apply this to the original problem:
List<Product> show(List<Predicate<Product>> predicates) {
Predicate<Product> combinedPredicate = combine(predicates);
return getAllProducts().stream()
.filter(combinedPredicate)
.collect(toList());
}
35. #LambdaHOL#Devoxx
Function Combination — Exercise
An IntUnaryOperator is a functional interface that
takes an int and returns an int.
Write a method that combines an arbitrary sized
list of IntUnaryOperators into a single one.
Use streams and the IntUnaryOperator.andThen()
method.
Use your method to combine functions that add
one, multiply by two, and three.
36. #LambdaHOL#Devoxx
Function Combination — Exercise
IntUnaryOperator combine(List<IntUnaryOperator> operators) {
// TODO
}
IntUnaryOperator operator =
combine(List.of(i -> i + 1, i -> i * 2, i -> i + 3));
System.out.println(operator.applyAsInt(5));
15
37. #LambdaHOL#Devoxx
Function Combination — Solution
IntUnaryOperator combine(List<IntUnaryOperator> operators) {
return operators.stream()
.reduce(i -> i, IntUnaryOperator::andThen);
}
IntUnaryOperator operator =
combine(List.of(i -> i + 1, i -> i * 2, i -> i + 3));
System.out.println(operator.applyAsInt(5));
15
40. #LambdaHOL#Devoxx
Collectors.toMap()
Given the alphabet words, create a map whose
keys are the first letter and whose values are
the words.
Map<String, String> toMap1() {
return alphabet.stream()
.collect(toMap(word -> word.substring(0, 1),
word -> word));
}
41. #LambdaHOL#Devoxx
Collectors.toMap()
a => alfa
b => bravo
c => charlie
d => delta
e => echo
f => foxtrot
g => golf
h => hotel
i => india
j => juliet
k => kilo
l => lima
m => mike
n => november
o => oscar
42. #LambdaHOL#Devoxx
Collectors.toMap()
Now create the first-letter map using the
sonnet instead of the alphabet words.
Map<String, String> toMap1() {
return sonnet.stream()
.collect(toMap(word -> word.substring(0, 1),
word -> word));
}
43. #LambdaHOL#Devoxx
Collectors.toMap()
Exception in thread "main" java.lang.IllegalStateException: Duplicate key B (attempted merging values
But as the riper should by time decease, and But thou contracted to thine own bright eyes,)
at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:133)
at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)
44. #LambdaHOL#Devoxx
Collectors.toMap()
The simple (two-arg) toMap() requires that all
keys be unique. Throws exception if duplicate
keys are encountered.
To handle this, a third arg mergeFunction can be
provided. It takes the values of the duplicate
keys and returns a merged value.
45. #LambdaHOL#Devoxx
Collectors.toMap()
Use a merge function that simply returns its
first argument. “First wins.”
Map<String, String> toMap3() {
return sonnet.stream()
.collect(toMap(line -> line.substring(0, 1),
line -> line,
(line1, line2) -> line1 // merge
));
}
46. #LambdaHOL#Devoxx
Collectors.toMap()
Eight of fourteen lines remain, so some
duplicates were lost.
P => Pity the world, or else this glutton be,
A => And only herald to the gaudy spring,
B => But as the riper should by time decease,
T => That thereby beauty's rose might never die,
F => From fairest creatures we desire increase,
W => Within thine own bud buriest thy content,
H => His tender heir might bear his memory:
M => Making a famine where abundance lies,
47. #LambdaHOL#Devoxx
Collectors.toMap()
Use a “last wins” merge function.
Map<String, String> toMap4() {
return sonnet.stream()
.collect(toMap(line -> line.substring(0, 1),
line -> line,
(line1, line2) -> line2 // merge
));
}
48. #LambdaHOL#Devoxx
Collectors.toMap()
Eight entries, but some are different.
P => Pity the world, or else this glutton be,
A => And, tender churl, mak'st waste in niggarding:
B => But thou contracted to thine own bright eyes,
T => To eat the world's due, by the grave and thee.
F => Feed'st thy light's flame with self-substantial fuel,
W => Within thine own bud buriest thy content,
H => His tender heir might bear his memory:
M => Making a famine where abundance lies,
49. #LambdaHOL#Devoxx
Collectors.toMap() — Exercise
Create a map from the lines of the sonnet, with
map keys being the first letter of the line, and
values being the line. For duplicate keys,
concatenate the lines with a newline in
between.
51. #LambdaHOL#Devoxx
Collectors.toMap() — Solution
P => Pity the world, or else this glutton be,
A => And only herald to the gaudy spring,
And, tender churl, mak'st waste in niggarding:
B => But as the riper should by time decease,
But thou contracted to thine own bright eyes,
T => That thereby beauty's rose might never die,
Thy self thy foe, to thy sweet self too cruel:
Thou that art now the world's fresh ornament,
To eat the world's due, by the grave and thee.
F => From fairest creatures we desire increase,
Feed'st thy light's flame with self-substantial fuel,
W => Within thine own bud buriest thy content,
H => His tender heir might bear his memory:
M => Making a famine where abundance lies,
53. #LambdaHOL#Devoxx
Collectors.groupingBy()
The groupingBy() collector is a fancy way of
collecting a map from a stream.
In its simplest form, it takes a classifier function
to transform each stream element into a key.
Map values are a list of stream elements
classified into the same key.
Stream<T> ⇒ Map<K, List<V>>
54. #LambdaHOL#Devoxx
Collectors.groupingBy()
From the alphabet words, create a map whose
keys are the word length, and whose values are
a list of those words. First start off with toMap().
Map<Integer, List<String>> groupingBy1() {
return alphabet.stream()
.collect(
toMap(
word -> word.length(),
word -> new ArrayList<>(Arrays.asList(word)),
(list1, list2) -> { list1.addAll(list2);
return list1; }));
}
59. #LambdaHOL#Devoxx
Collectors.groupingBy() — Solution
P => [Pity the world, or else this glutton be,]
A => [And only herald to the gaudy spring,,
And, tender churl, mak'st waste in niggarding:]
B => [But as the riper should by time decease,,
But thou contracted to thine own bright eyes,]
T => [That thereby beauty's rose might never die,,
Thy self thy foe, to thy sweet self too cruel:,
Thou that art now the world's fresh ornament,,
To eat the world's due, by the grave and thee.]
F => [From fairest creatures we desire increase,,
Feed'st thy light's flame with self-substantial fuel,]
W => [Within thine own bud buriest thy content,]
H => [His tender heir might bear his memory:]
M => [Making a famine where abundance lies,]
61. #LambdaHOL#Devoxx
Cascading Collectors
The groupingBy() collector seems restrictive: it
collects stream elements into a list.
This behavior can be modified by providing a
“downstream” collector as another argument.
groupingBy(classifier, downstream)
65. #LambdaHOL#Devoxx
Collectors.mapping()
Another useful downstream collector is
mapping():
mapping(mapperFunction, downstream2)
The mapping() collector is analogous to
Stream.map(). It applies a mapper function to
an element and passes the result downstream
— to a second downstream collector.
69. #LambdaHOL#Devoxx
Cascading Collectors — Exercise
Group the lines of the sonnet by first letter, and
collect the first word of grouped lines into a set.
To extract the first word of a line, use
string.split(" +")[0]
70. #LambdaHOL#Devoxx
Cascading Collectors — Solution
Map<String, Set<Integer>> cascading3() {
return sonnet.stream()
.collect(
groupingBy(
line -> line.substring(0, 1),
mapping(line -> line.split(" +")[0], toSet())
));
} P => [Pity]
A => [And, And,]
B => [But]
T => [That, Thy, To, Thou]
F => [Feed'st, From]
W => [Within]
H => [His]
M => [Making]
71. #LambdaHOL#Devoxx
Cascading Collectors
A first set of collectors that need downstream
collectors to work:
- mapping()
- filtering()
- flatMapping()
Analogous to intermediate stream operations
72. #LambdaHOL#Devoxx
Cascading Collectors
A second set of collectors:
▪ joining()
▪ counting()
▪ groupingBy(), toMap(), toUnmodifiableMap()
▪ toList(), toSet(), toUnmodifiableList() (and set)
▪ reducing()
Analogous to terminal stream operations
73. #LambdaHOL#Devoxx
Cascading Collectors
Group lines of the sonnet by first letter, and
collect the grouped lines into a single string
separated by newlines.
Map<String, String> cascading4() {
return sonnet.stream()
.collect(groupingBy(line -> line.substring(0, 1),
joining("n")
)
);
}
74. #LambdaHOL#Devoxx
Cascading Collectors
P => Pity the world, or else this glutton be,
A => And only herald to the gaudy spring,
And, tender churl, mak'st waste in niggarding:
B => But as the riper should by time decease,
But thou contracted to thine own bright eyes,
T => That thereby beauty's rose might never die,
Thy self thy foe, to thy sweet self too cruel:
Thou that art now the world's fresh ornament,
To eat the world's due, by the grave and thee.
F => From fairest creatures we desire increase,
Feed'st thy light's flame with self-substantial fuel,
W => Within thine own bud buriest thy content,
H => His tender heir might bear his memory:
M => Making a famine where abundance lies,
75. #LambdaHOL#Devoxx
Cascading Collectors — Exercise
Generate a frequency table of letters in the
sonnet. Remember the expand() helper
method.
Hints: use flatMap(), groupingBy(), and
counting().
76. #LambdaHOL#Devoxx
Cascading Collectors — Solution
Map<String, Long> cascadingSolution2() {
return sonnet.stream()
.flatMap(line -> expand(line).stream())
.collect(groupingBy(ch -> ch, counting()));
}
A => 2
B => 2
F => 2
H => 1
M => 1
P => 1
T => 4
W => 1
=> 92
a => 28
b => 11
c => 9
d => 20
e => 68
f => 9
g => 12
' => 6
h => 33
i => 29
k => 2
l => 18
, => 15
- => 1
m => 10
. => 1
n => 29
o => 25
p => 2
r => 33
s => 30
t => 54
u => 17
v => 2
w => 11
y => 14
: => 3
78. #LambdaHOL#Devoxx
Streaming a Map
Find the most frequently occurring word from
the Sonnet
- 1st step: find one of those words
- 2nd step: find all those words in a list
79. #LambdaHOL#Devoxx
Streaming a Map
Two hints:
1) You cannot stream a map. To stream a map,
you need to get a stream of entries from its
entrySet().
Stream<Map.Entry<K, V>> stream =
map.entrySet().stream();
80. #LambdaHOL#Devoxx
Streaming a Map
Two hints:
2) There is a Stream.max() method
And Map.Entry provides comparators
stream.max(comparator)
.orElseThrow(); // max returns an Optional
stream.max(Map.Entry.comparingByValue())
.orElseThrow(); // max returns an Optional
81. #LambdaHOL#Devoxx
Inverting a Map
Suppose there are multiple maximum values
Max finds one of them
Finding all of them can be done by
converting a Map<word, count>
to a Map<count, List<word>>
83. #LambdaHOL#Devoxx
Streaming Over Indexes
Sometimes you need to process groups of
adjacent elements or a “sliding window” of
elements from a stream. The usual way of
streaming elements doesn’t handle this well.
If you have the elements in an array or random-
access list, you can work around this limitation
by streaming indexes instead of elements.
87. #LambdaHOL#Devoxx
Streaming Over Indexes — Exercise
From the alphabet list, produce a list of
overlapping sublists of length N (sliding
window)
[[alfa, bravo, charlie], [bravo, charlie, delta], [charlie, delta,
echo], [delta, echo, foxtrot], [echo, foxtrot, golf], ...
90. #LambdaHOL#Devoxx
Streaming Over Indexes — Exercise 2
Split the alphabet list into runs (sublists) of
strings of non-decreasing length, preserving
order.
That is, within each sublist, the next string
should always be the same length or longer.
[[alfa, bravo, charlie], [delta], [echo, foxtrot], [golf, ...] ...]
91. #LambdaHOL#Devoxx
Streaming Over Indexes — Solution 2
Insight: a new sublist starts when this string is
shorter than the previous string. Find the
indexes where this occurs.
[3, 4, 6, 10, 14, 15, 17, 19, 21, 23, 25]
List<Integer> breaks =
IntStream.range(1, alphabet.size())
.filter(i -> alphabet.get(i).length() <
alphabet.get(i-1).length())
.boxed()
.collect(toList());
92. #LambdaHOL#Devoxx
Streaming Over Indexes — Solution 2
We want sublists between these breaks. Run a
stream over the breaks to generate sublists.
[[delta], [echo, foxtrot], [golf, hotel, india, juliet], [kilo, lima,
mike, november], [oscar], [papa, quebec], [romeo, sierra], [tango,
uniform], [victor, whiskey], [x-ray, yankee]]
List<List<String>> sublists =
IntStream.range(0, breaks.size()-1)
.mapToObj(i -> alphabet.subList(breaks.get(i),
breaks.get(i+1)))
.collect(toList());
93. #LambdaHOL#Devoxx
Streaming Over Indexes — Solution 2
Add starting and ending indexes to break list to
pick up leading and trailing sublists.
[[alfa, bravo, charlie], [delta], [echo, foxtrot], [golf, hotel, india,
juliet], [kilo, lima, mike, november], [oscar], [papa, quebec], [romeo,
sierra], [tango, uniform], [victor, whiskey], [x-ray, yankee], [zulu]]
breaks.add(0, 0);
breaks.add(alphabet.size());
List<List<String>> sublists =
IntStream.range(0, breaks.size()-1)
.mapToObj(i -> alphabet.subList(breaks.get(i),
breaks.get(i+1)))
.collect(toList());