Questions tagged [groupingby]

77 questions
0
votes
0 answers

Grouping model field names in Django

I have a complex detail view where a lot of varied data is rendered dynamically. My model has hundreds of fields, many of which are related to one another. I would like to be able to group a number of these fields in order to do queries. Is there…
Danhr
  • 1
  • 3
0
votes
1 answer

java stream pipeline to create map of lists

Its not real code, but an analogy to my exact scenario. Main concern here is the util stream pipeline. Lets assume, I've following object model @Data class ItemRequest { String action; List itemIds; } @Data …
ThrowableException
  • 1,168
  • 1
  • 8
  • 29
0
votes
1 answer

Java 8 Map group by orderid and sort by itemLeastDate

I want the DB records list to be groupby orderId and sort by itemDate. I am getting records from db like this in any order. Same OrderId's record will come in different order. OrderId Item Number Item Date 1 12345 3/10/21 2 67890 …
Abhikhya
  • 121
  • 1
  • 11
0
votes
3 answers

How to group fields of different type lists using JAVA 8?

Here the PHD student who is also a School teacher. The common thing between these two objects is their name. So I am filtering the data using their name. Upto the code I wrote below in the MyMain class, I am able to filter the common records and get…
Vedant
  • 58
  • 6
0
votes
4 answers

Grouping elements that each group contains only one object with specified field

I have a problem with grouping java objects. Let's look at example object: public class MyObject { private String field1; public MyObject(String field1) { this.field1 = field1; } } What i want to achieve is grouping MyObject's…
Paoloeno
  • 11
  • 1
0
votes
1 answer

Java8 Stream: groupingBy and create Map

I want to get the following Data structure: Map> Given is a class either containing the fields als primitives (position, destination, distance) or as a key (position) plus map (target). From each unique position one can…
Slevin
  • 617
  • 1
  • 7
  • 17
0
votes
0 answers

java stream for grouping by multiple keys

I'm trying to group a list of objects which contains nested list of keys in, and the data structure looks like: class BookInformation { String accountId; String bookName; String bookId; List infos; } class Info { …
Qingshan Zhang
  • 245
  • 1
  • 3
  • 12
0
votes
1 answer

java collectors with grouping by

I have a list of MyClass bellow public class MyClass { private String level; private String grade; private String value; // constructor, getters, setters } List myList = new ArrayList<>(); myList.add(new MyClass("Lv1", "A",…
hsseol
  • 21
  • 4
0
votes
0 answers

Collectors.groupingBy throwing NullPointerException

Why is Collectors.groupingBy throwing NullPointerException? Caused by: java.lang.NullPointerException at java.util.stream.Collectors.lambda$groupingBy$45(Collectors.java:907) at…
fatherazrael
  • 5,511
  • 16
  • 71
  • 155
0
votes
2 answers

Group and Aggregate List of Map

I have a List> input like below: [{ CURRENCY = USD, STATUS = NEW, PUBLISH_REGION = DEL, SOURCE = ALADDIN, RECON_STATUS = null, JOB_ID_COUNT = 783 }, { CURRENCY = USD, STATUS = IN_PROGRESS, …
Pravat Panda
  • 1,060
  • 2
  • 13
  • 27
0
votes
1 answer

Using groupingby with java streams

I have a list of students, refer to the DTO. I am trying to derive the result of the section and session. For example: We have a collection of students with varying section & sessions: Students: [Student [id=1, section=section-a, result=pass,…
mayank bisht
  • 618
  • 3
  • 14
  • 43
0
votes
1 answer

grouping by with function and custom object collector as parameters

I have the below requirement which might be simple but as a beginner I would like to take help here. class Employee{ String department; int age; int salary; } class Foo{ double averagingAge; double averagingSalary; } I want to have a…
avr
  • 1
  • 1
  • 4
0
votes
2 answers

Java. groupingBy throw to classes

I cant write a collector that calculates the total sum of transactions (long type, not integer) by each account (i.e. by account number). The collector will be applied to a stream of transactions. How to use groupingBy for this chain Transaction ->…
stereouho
  • 45
  • 1
  • 7
0
votes
2 answers

How to convert Map> to Map> using Java8 stream

How to convert Map> to Map> using Java8 stream. Input: {A : {B : C, D : E}} // Here B and D are the Key of inner map for A key {F : {B : G, D : H}} // Here B and D are the Key of inner map for F key Output: {B : {A : C, F :…
-1
votes
3 answers

Java Streams - Sort element in each List while using Collector groupingBy

I have the following code, which makes use of the collector groupingBy() Stream stream = Stream.of("lions", "tigers", "bears", "toads", "tarantullas"); Map map7 = stream.collect( Collectors.groupingBy( …
march_in
  • 19
  • 1