Re: [Jagg-users] AggregationValues as tree structure
jAgg - Java Aggregation Operations
Status: Beta
Brought to you by:
rgettman
|
From: Jan P. W. <in...@je...> - 2015-09-02 08:42:23
|
Hey Randy,
thanks for your answer.
The result what you described is what i'm looking for. When i'm using rollups my result looks different:
With your example it looks like the following:
Prop1 Prop2 Prop3 Sum(value)
----- ----- ----- ----------
A 1 X 10
A 1 Y 20
A 2 X 15
A 2 Y 25
B 3 X 100
B 3 Y 200
A 1 30
A 2 40
B 3 300
A 70
B 300
Means the aggregations are at the end.
Here's what i have:
grp1 grp2 grp3 Sum(val1)
----- ----- ----- ----------
1 A 123 1.0
2 A 6 14.0
3 A 123 2.0
123 A 6 0.0
12345 *B*** 9 1.0
12345 A 7 1.0
12345 A 8 23.0
List<String> properties = new ArrayList<String>();
properties.add("val1");
PropertiesDiscriminator pd = new PropertiesDiscriminator();
properties = Arrays.asList("grp1", "grp2", "grp3");
List<AggregateFunction> aggs = Arrays.asList(Aggregator.getAggregator("Sum(val1)"));
Aggregation agg = new Aggregation.Builder().setProperties(properties).setAggregators(aggs).setRollup(Arrays.asList( 1, 2)).build();
for (AggregateValue<Object> artikelValue : aggValues) {
System.out.println(artikelValue.getPropertyValue(0) + " "
+ artikelValue.getPropertyValue(1) + "\t\t\t"
+ artikelValue.getPropertyValue(2) + "\t\t\t"
+ artikelValue.getAggregateValue(0) + "\t\t" + " "
+ artikelValue.isGrouping(0) + "\t\t"
+ artikelValue.isGrouping(1) + "\t\t"
+ artikelValue.isGrouping(2) + "\t\t");
}
1 A 123 1.0 false false false
2 A 6 14.0 false false false
3 A 123 2.0 false false false
123 A 6 0.0 false false false
12345 B 9 1.0 false false false
12345 A 7 1.0 false false false
12345 A 8 23.0 false false false
1 A null 1.0 false false true
2 A null 14.0 false false true
3 A null 2.0 false false true
123 A null 0.0 false false true
12345 B null 1.0 false false true
12345 A null 24.0 false false true
1 null null 1.0 false true true
2 null null 14.0 false true true
3 null null 2.0 false true true
123 null null 0.0 false true true
12345 null null 25.0 false true true
null null null 42.0 true true true
Wanted output:
1 A 123 1.0 false false false
1 A null 1.0 false false true
1 null null 1.0 false true true
2 A 6 14.0 false false false
2 A null 14.0 false false true
2 null null 14.0 false true true
3 A 123 2.0 false false false
3 A null 2.0 false false true
3 null null 2.0 false true true
123 A 6 0.0 false false false
123 A null 0.0 false false true
123 null null 0.0 false true true
12345 A 7 1.0 false false false
12345 A 8 23.0 false false false
12345 A null 24.0 false false true
12345 B 9 1.0 false false false
12345 B null 1.0 false false true
12345 null null 25.0 false true true
null null null 42.0 true true true
Thanks!
Philppe
Am 02.09.2015 um 00:22 schrieb Gettman, Randy:
> Philippe,
>
> I'm not sure what the exact result you're looking for is, but jAgg wasn't designed to deliver AggregateValues in a tree structure. However, it might be that you're looking for rollups: http://jagg.sourceforge.net/super/rollups.html
>
> For example, if you have a list of AggregateValues such as this, grouping by 3 properties:
>
> Prop1 Prop2 Prop3 Sum(value)
> ----- ----- ----- ----------
> A 1 X 10
> A 1 Y 20
> A 2 X 15
> A 2 Y 25
> B 3 X 100
> B 3 Y 200
>
> Then adding a rollup on the properties when constructing your Aggregation object may be what you need. Including this method call
>
> setRollup(Arrays.asList(1, 2)) // Prop2, Prop3
>
> changes the results to add rollups. In this case, using a sum produces subtotals, starting from the last property in the rollup.
>
> Prop1 Prop2 Prop3 Sum(value)
> ----- ----- ----- ----------
> A 1 X 10
> A 1 Y 20
> A 1 30
> A 2 X 15
> A 2 Y 25
> A 2 40
> A 70
> B 3 X 100
> B 3 Y 200
> B 3 300
> B 300
>
> Please let me know if this is what you need.
>
> Thanks,
> Randy Gettman
>
> -----Original Message-----
> From: Jan Philippe Wimmer [mailto:in...@je...]
> Sent: Tuesday, September 01, 2015 9:27 AM
> To: jag...@li...
> Subject: [Jagg-users] AggregationValues as tree structure
>
> Hey,
>
> is there a way to get AggregationValues as tree structure?
>
> Property1
> -Property2
> -Property3
>
> This would make it easier to iterate and find the corresponding aggregations.
>
> I need my aggregations right after the values.
>
>
> Currently I'm working on an post sorting routine. But maybe there is a better way.
>
> Thanks in advance
> Philippe
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Jagg-users mailing list
> Jag...@li...
> https://lists.sourceforge.net/lists/listinfo/jagg-users
> ******************************************************************************************
> This message may contain confidential or proprietary information intended only for the use of the
> addressee(s) named above or may contain information that is legally privileged. If you are
> not the intended addressee, or the person responsible for delivering it to the intended addressee,
> you are hereby notified that reading, disseminating, distributing or copying this message is strictly
> prohibited. If you have received this message by mistake, please immediately notify us by
> replying to the message and delete the original message and any copies immediately thereafter.
>
> Thank you.
> ******************************************************************************************
> CLLD
>
|