question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: add partition method to Sets utility class

See original GitHub issue

The utility class Sets could use a new method <T> Set<Set<T>> partition(Set<T> set, int size), similar to the one in Lists class. Such a method would be useful for various applications, e.g. for batch processing elements for which order is unspecified/unimportant, and I don’t think there is a straightforward way of achieving the same effect with Java 8 streams API.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cpovirkcommented, Jul 24, 2019

Another complication: Iterables.partition can be done in a “mostly streaming” fashion, but Sets.partition would need to be done eagerly (or else inefficiently). That means that switching from Iterables.partition to Sets.partition has performance implications – different (IIRC) from comparable switches like from Iterables.filter to Sets.filter.

1reaction
lowassercommented, Jun 30, 2016

I’m not sure why you wouldn’t write

Iterables.partition(elements, batchSize)
    .forEach(batch -> processElements(new HashSet<>(batch)))

I’m also a bit concerned about issues like Sets.partition(myTreeSet, batchSize) not being able to identify which set implementation to use. It’s not even clear what set implementation we’d want – immutable? LinkedHashSet? – where there’s no real ambiguity for lists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rules for Using the ADD Option for the Partitioning Levels of a ...
You can specify an ADD option for a partitioning level. The BIGINT number following the ADD keyword plus the number of partitions defined ......
Read more >
Managing partitioned tables | BigQuery - Google Cloud
This document describes how to manage partitioned tables in BigQuery. Note: The information in Managing tables also applies to partitioned tables.
Read more >
Database table partitioning - GitLab Docs
Table partitioning is a powerful database feature that allows a table's data to be split into smaller physical tables that act as a...
Read more >
Data partitioning guidance - Azure Architecture Center
In this article, the term partitioning means the process of physically dividing data into separate data stores. It is not the same as...
Read more >
VLDB and Partitioning Guide - Oracle Help Center
The following are operations supported on hybrid partitioned tables. Creating single level RANGE and LIST partitioning methods. Using ALTER TABLE .. DDLs such ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found