DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Curious about the future of data-driven systems? Join our Data Engineering roundtable and learn how to build scalable data platforms.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Threat Detection: Learn core practices for managing security risks and vulnerabilities in your organization — don't regret those threats!

Managing API integrations: Assess your use case and needs — plus learn patterns for the design, build, and maintenance of your integrations.

Avatar

Grzegorz Piwowarek

Lead Engineer at 4Comprehension @pivovarit

Warsaw, PL

Joined Aug 2017

http://4comprehension.com

About

A passionate software engineer, trainer, and international conference speaker who cares about quality, craftsmanship, clean code and getting things done.

Stats

Reputation: 1485
Pageviews: 641.8K
Articles: 12
Comments: 16
  • Articles
  • Comments

Articles

article thumbnail
Streaming Java CompletableFutures in Completion Order
Want to see what happens when you combine Stream and CompletableFutures in Java?
Updated June 3, 2019
· 28,115 Views · 12 Likes
article thumbnail
A Case Study of Implementing an Efficient Shuffling Stream/Spliterator in Java
Shuffling a stream in Java isn't the easiest thing to do — but it is often useful.
March 14, 2019
· 11,027 Views · 8 Likes
article thumbnail
The Ultimate Guide to the Java Stream API groupingBy() Collector
Still a bit puzzled by what the groupingBy() collector can do in the Java Stream API? Check out this guide on using the groupingBy() collector to its fullest potential.
September 19, 2018
· 121,997 Views · 37 Likes
article thumbnail
Stack-Walking in Java With StackWalker and the Stream API
Want to learn more about using the Stack-Walking API in Java? Check out this tutorial on how to use the StackWalker and Stream APIs.
September 11, 2018
· 8,405 Views · 4 Likes
article thumbnail
Implementing a Sliding Window Stream/Spliterator in Java
Let's go through this tutorial on creating a sliding window in Java using streams and spliterators! Trust me — you'll be happy you did.
September 6, 2018
· 26,740 Views · 17 Likes
article thumbnail
CompletableFuture Timeouts in Java
Futures and timeouts — seems like the start of a weird sci-fi movie. Let's take a look at how JDK 9 improves on JDK 8's CompletableFuture. Click here for more!
August 23, 2018
· 42,793 Views · 25 Likes
article thumbnail
Effectively Sealed Classes in Java
Sealed classes are extremely helpful in class implementation in Java. Check out this post on using sealed classes and the Option class in Java.
August 16, 2018
· 27,431 Views · 20 Likes
article thumbnail
Leveraging Lambda Expressions for Lazy Evaluation in Java
Want to learn more about the lazy evaluation in Java? Check out this tutorial on how to use lambda expressions for the purpose of lazy loading data and lazy evaluation.
July 28, 2018
· 26,041 Views · 13 Likes
article thumbnail
JDK9's ForkJoinPool Upgrades
Java 9 snuck in some small but important changes to the ForkJoinPool. Let's take a closer look.
July 17, 2018
· 13,489 Views · 9 Likes
article thumbnail
Java 8: The Bad Parts
With Java 9 here, let's take a look at what its predecessor, Java 8, did well and, more importantly, where it left room for improvement.
December 14, 2017
· 33,198 Views · 47 Likes
article thumbnail
Sneakily Throwing Exceptions in Lambda Expressions
Java 8's type inference rules leave an exploitable hole you can use to handle checked exceptions when using lambda expressions.
Updated October 3, 2017
· 50,199 Views · 13 Likes
article thumbnail
Maintaining PriorityQueue Order With Java Streams
The priority order of a PriorityQueue is not preserved when iterating or traversing, but fortunately, there are clean solutions for achieving this.
September 18, 2017
· 9,236 Views · 5 Likes

Comments

Streaming Java CompletableFutures in Completion Order

May 04, 2019 · Lindsay Burk

Sure, I will gladly add clarification to remove the ambiguity, thanks!

Streaming Java CompletableFutures in Completion Order

May 03, 2019 · Lindsay Burk

Thanks, that's a nice idea! It's short and nice but it won't propagate exceptions properly and will cause the thread to get blocked forever waiting for LinkedBlockingQueue::take to return a result

Also, not all CompletableFutures are waiting for a thread, that's only if you create it with one of the async() factory methods. It is perfectly possible to create 100.000s of CompletableFutures without a single thread.

Yes, I used this approach myself in the library mentioned in the article - it's perfectly possible, but still most cases will involve them getting completed by some background threads. Waiting for the Project Loom to change it

JDBC ResultSet and Generic Class List Using Java Reflection Annotations

Apr 19, 2019 · Naveen Yalla

JdbcTemplate serves the purpose really well, though

A Case Study of Implementing an Efficient Shuffling Stream/Spliterator in Java

Mar 14, 2019 · Duncan Brown

Oh, that's a very good point - will fix :)

A Case Study of Implementing an Efficient Shuffling Stream/Spliterator in Java

Mar 14, 2019 · Duncan Brown

It's deliberate - the empty case is not supported and rejected before even gets to the spliterator. There's no need to create the object if we don't need it at all. If we don't use it to handle empty cases, then no need to check this as well in tryAdvance

The Ultimate Guide to the Java Stream API groupingBy() Collector

Sep 21, 2018 · Duncan Brown

groupingBy is way more expensive - if your use case can be solved using filter() only, definitely go for it

The Ultimate Guide to the Java Stream API groupingBy() Collector

Sep 21, 2018 · Duncan Brown

Thanks for the suggestion, David. One question, though - are you familiar with how the reduce operation works on sequences? the article was supposed to be a high-level overview of groupingBy capabilities, that would be probably an overkill to explain the semantics of each operation not in the context of groupingBy usages

The Ultimate Guide to the Java Stream API groupingBy() Collector

Sep 19, 2018 · Duncan Brown

If I got you right, you don't need groupingBy() for this, you can simply use partitioningBy():


Map<Boolean, List<String>> result = Stream.of("abc", "def")
.collect(Collectors.partitioningBy(s -> s.startsWith("a")));

System.out.println(result); // {false=[def], true=[abc]}

CompletableFuture Timeouts in Java

Aug 23, 2018 · Duncan Brown

I've been wondering the same, even dedicated a section to it here:

https://4comprehension.com/java-8-the-bad-parts/

Leveraging Lambda Expressions for Lazy Evaluation in Java

Jul 28, 2018 · Duncan Brown

In such case, I'd advise being explicit about the optionality of the result by returning an Optional instance, but it's a good point and I will it to the article, thanks :) I like the idea with freeing the supplier as well!

Sneakily Throwing Exceptions in Lambda Expressions

Oct 04, 2017 · Grzegorz Piwowarek

Martin, I'm not sure if I fully understand - can you elaborate, please?

It does not matter to what it compiles at this point. Provided functional interfaces miss the "throws Something" which simply does not compile if a checked exception is thrown inside

Lambdas and Clean Code

Sep 29, 2017 · Mike Gates

I just tried it - there are no shortcuts for .collect(Collectors.toXXX), unfortunately

Maintaining PriorityQueue Order With Java Streams

Sep 21, 2017 · Grzegorz Piwowarek

The pragmatic reason for including the second solution is the fact that if that was omitted it'd immediately spark questions "Why not just sort the Stream instance?"

As long as API provides an iterator, it's fine to use Streams there - can't discuss with personal preference, though

Maintaining PriorityQueue Order With Java Streams

Sep 20, 2017 · Grzegorz Piwowarek

Well, obviously we do not need to consume all elements at once. With Stream API, we can easily reach, let's say, first N elements + apply some processing on top of them - that's much handier than polling elements in a loop.

Maintaining PriorityQueue Order With Java Streams

Sep 18, 2017 · Grzegorz Piwowarek

At the end of the day, you need to reach all accumulated elements to do something with them, right?

This is where it'd be nice to have something better than a for-loop

Maintaining PriorityQueue Order With Java Streams

Sep 18, 2017 · Grzegorz Piwowarek

Good point - I will add some additional clarification there.

I will add also a Java 9 section in there.

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: