@@ -24,6 +24,11 @@ public static void basicStatic( Key k, Frame fr ) {
24
24
doit ();
25
25
System .out .println (sumcols ._sum +"/" +sumcols ._n +" = " +(sumcols ._sum /sumcols ._n ));
26
26
System .out .println ();
27
+
28
+ SumCol sumCol = new SumCol (year_idx );
29
+ Flow .FlowPerRow <SumCol > flowPerRow = fr .with (sumCol );
30
+ SumCol result = flowPerRow .doit ();
31
+ System .out .println ("TOM: " + result ._sum + " " + result ._n );
27
32
28
33
SumCol sumcols1 = fr .
29
34
with (new Flow .Filter () { public boolean filter (double ds []) { return ds [cyl_idx ]!=5 ; } }).
@@ -47,7 +52,25 @@ public static void basicStatic( Key k, Frame fr ) {
47
52
System .out .println ("Cyl=" +gid ._val +", " +sumcol ._sum +"/" +sumcol ._n +" = " +(sumcol ._sum /sumcol ._n ));
48
53
}
49
54
System .out .println ();
50
-
55
+
56
+ {
57
+ System .out .println ("TOM ----- START" );
58
+ class MyGroupBy extends Flow .GroupBy {
59
+ public long groupId (double ds []) { return (long )ds [cyl_idx ];}
60
+ }
61
+
62
+ SumCol sumCol10 = new SumCol (year_idx );
63
+ Flow .FlowGroupBy flowGroupBy = fr .with (new MyGroupBy ());
64
+ Flow .FlowGroupPerRow flowGroupPerRow = flowGroupBy .with (sumCol10 );
65
+ IcedHashMap <IcedLong ,SumCol > hashMap = flowGroupPerRow .doit ();
66
+ for ( IcedLong gid : hashMap .keySet () ) {
67
+ SumCol sumcol = sumcols2 .get (gid );
68
+ System .out .println ("Cyl=" +gid ._val +", " +sumcol ._sum +"/" +sumcol ._n +" = " +(sumcol ._sum /sumcol ._n ));
69
+ }
70
+ System .out .println ("TOM ----- END" );
71
+ System .out .println ();
72
+ }
73
+
51
74
IcedHashMap <IcedLong ,SumCol > sumcols3 = fr .
52
75
with (new Flow .Filter () { public boolean filter (double ds []) { return ds [cyl_idx ]!=5 ; } }).
53
76
with (new Flow .GroupBy () { public long groupId ( double ds []) { return (long )ds [cyl_idx ];} }).
0 commit comments