11package DF ;
22
33import DF .Exceptions .*;
4+ import DF .Values .DateTimeValue ;
5+ import DF .Values .DoubleValue ;
6+ import DF .Values .StringValue ;
47
58import java .io .IOException ;
69import java .sql .SQLException ;
10+ import java .util .concurrent .ExecutorService ;
11+
12+ import static java .util .concurrent .Executors .newFixedThreadPool ;
713
814public class Main {
9- public static void main (String [] args ) throws IOException , ValueParseException , ZeroLengthException , NoSenseInGroupingByAllColumnsException , IncoherentTypeException , DifferentAmountOfColumns , SQLException , DivideByZeroException , DifferentSizeOfColumnsExcepiton {
15+ public static void main (String [] args ) throws IOException , ValueParseException , ZeroLengthException , NoSenseInGroupingByAllColumnsException , IncoherentTypeException , DifferentAmountOfColumns , SQLException , DivideByZeroException , DifferentSizeOfColumnsExcepiton , CloneNotSupportedException {
1016// DataFrame tmp = new DataFrame(new String[]{"z","g","r"}, new Class[] {IntegerValue.class,IntegerValue.class,IntegerValue.class} );
1117// tmp.dodajElement(new IntegerValue(9),new IntegerValue(23),new IntegerValue(33));
1218// System.out.println(tmp.get("z").getType());
@@ -32,7 +38,7 @@ public static void main (String[] args) throws IOException, ValueParseException,
3238// // System.out.println(tmp2.toString());
3339//
3440//
35- // DataFrame.Grupator group = tmp2.groupBy(new String[]{"id"});
41+ // DataFrame.Grupator group = tmp2.groupBy(new String[]{"id"});
3642// System.out.println(group.sum());
3743// System.out.println(group.max());
3844// System.out.println(group.min());
@@ -43,18 +49,17 @@ public static void main (String[] args) throws IOException, ValueParseException,
4349
4450 // TEST DLA DWÓCH KLUCZY
4551
46- // DataFrame tmp3 = new DataFrame("groubymulti.csv", new Class[]{StringValue.class,DateTimeValue.class,DoubleValue.class,DoubleValue.class});
52+ // DataFrame tmp3 = new DataFrame("groubymulti.csv", new Class[]{StringValue.class,DateTimeValue.class,DoubleValue.class,DoubleValue.class});
4753
48- // DataFrame.Grupator group1 = tmp3.groupBy(new String []{"id","date"});
54+ // DataFrame.Grupator group1 = tmp3.groupBy(new String []{"id","date"});
4955 // System.out.println(group1.min());
5056 //System.out.println(group1.max());
5157 // System.out.println(group1.sum());
5258 // System.out.println(group1.mean());
53- //System.out.println(group1.var());
59+ //System.out.println(group1.var());
5460 // System.out.println(group1.std());
5561
5662
57-
5863// DataFrame my = new DataFrame(new String[]{"double","double2","double3"},new Class[]{DoubleValue.class,DoubleValue.class,DoubleValue.class});
5964// my.addRecord(new DoubleValue(9.0),new DoubleValue(6.7),new DoubleValue(6.7));
6065// my.addRecord(new DoubleValue(10.0),new DoubleValue(45.7),new DoubleValue(6.7));
@@ -85,11 +90,10 @@ public static void main (String[] args) throws IOException, ValueParseException,
8590
8691 // System.out.println(my2.toString());
8792
88- // DataFrame.Grupator grupkaTest = my2.groupBy(new String[]{"string"});
89- // System.out.println(grupkaTest.sum());
93+ // DataFrame.Grupator grupkaTest = my2.groupBy(new String[]{"string"});
94+ // System.out.println(grupkaTest.sum());
9095 //System.out.println(grupkaTest.min());
91- // System.out.println(grupkaTest.var());
92-
96+ // System.out.println(grupkaTest.var());
9397
9498
9599// DataFrame my1 = new DataFrame(new String[]{"data","data2","data3"},new Class[]{DateTimeValue.class,DateTimeValue.class,DateTimeValue.class});
@@ -117,7 +121,6 @@ public static void main (String[] args) throws IOException, ValueParseException,
117121// System.out.println(grupkaTest.std());
118122
119123
120-
121124////
122125
123126// Kolumna test1 = new Kolumna ("nazwa",StringValue.class);
@@ -182,8 +185,7 @@ public static void main (String[] args) throws IOException, ValueParseException,
182185
183186 //---------- testy dla Data Frame DB------------
184187
185- // DataFrameDB tmp = new DataFrameDB.DataFrameBDBuilder("jdbc:mysql://mysql.agh.edu.pl/joannabi",
186- // "joannabi","87cz4zfRV047S5Wr","TABLE3").build();
188+
187189
188190// DataFrameDB tmp = new DataFrameDB.DataFrameBDBuilder("jdbc:mysql://mysql.agh.edu.pl/joannabi",
189191// "joannabi","87cz4zfRV047S5Wr","books").build();
@@ -195,37 +197,58 @@ public static void main (String[] args) throws IOException, ValueParseException,
195197// System.out.println(tmp.get("title"));
196198// DataFrame test = tmp.fromDataFrameDFtoDataFrame();
197199// System.out.println(test.toString());
198- // GroupBy grp=tmp.groupBy("id");
199- // System.out.println(grp.apply(new ApplyMax()));
200- // tmp.dodajElement(new StringValue("0101010101"),new StringValue("test tytul"),new StringValue("test autor"),new IntegerValue(2000));
201- // System.out.println(tmp.toString());
202200
201+ // System.out.println(grp.apply(new ApplyMax()));
202+ // tmp.dodajElement(new StringValue("0101010101"),new StringValue("test tytul"),new StringValue("test autor"),new IntegerValue(2000));
203+ // System.out.println(tmp.toString());
203204
204- // -----porównanie czasów dla max -------
205205
206- // System.out.println("DataFrame DB:");
207- // long start = System.currentTimeMillis();
208- // grp.apply(new ApplyMax());
209- // long stop = System.currentTimeMillis();
210- // System.out.println(stop-start);
211- //
212- // DataFrame tmp2 = new DataFrame("TABLE3.csv", new Class[]{ StringValue.class,DateTimeValue.class,DoubleValue.class,DoubleValue.class});
213- // GroupBy group = tmp2.groupBy(new String[]{"id"});
214- // long start2 = System.currentTimeMillis();
215- // group.max();
216- // long stop2 = System.currentTimeMillis();
217- //
218- // System.out.println("DataFrame :");
219- // System.out.println(stop2-start2);
206+ // -----porównanie czasów dla max -------
220207
221-
208+ DataFrameDB tmp = new DataFrameDB .DataFrameBDBuilder ("jdbc:mysql://mysql.agh.edu.pl/joannabi" ,
209+ "joannabi" ,"87cz4zfRV047S5Wr" ,"TABLE3" ).build ();
222210
211+ GroupBy grp =tmp .groupBy ("id" );
212+
213+
214+
215+ System .out .println ("DataFrame DB:" );
216+ long start = System .currentTimeMillis ();
217+ grp .apply (new ApplyMax ());
218+ long stop = System .currentTimeMillis ();
219+ System .out .println (stop -start );
223220
224- }
225221
226222
227223
224+ DataFrame tmp2 = new DataFrame ("table600k.csv" , new Class []{ StringValue .class ,DateTimeValue .class ,DoubleValue .class ,DoubleValue .class });
225+ GroupBy group = tmp2 .groupBy (new String []{"id" });
226+ long start2 = System .currentTimeMillis ();
228227
228+ group .std ();
229+ long stop2 = System .currentTimeMillis ();
229230
231+ System .out .println ("DataFrame :" );
232+ System .out .println (stop2 -start2 );
230233
234+
235+ ExecutorService threadPool = newFixedThreadPool (4 );
236+ ThreadDataFrame threadDF = new ThreadDataFrame (threadPool ,tmp2 );
237+
238+ GroupBy groupThread = threadDF .groupBy (new String []{"id" });
239+ long start3 = System .currentTimeMillis ();
240+
241+ groupThread .std ();
242+ long stop3 = System .currentTimeMillis ();
243+ threadPool .shutdown ();
244+
245+ System .out .println ("DataFrameThread :" );
246+ System .out .println (stop3 -start3 );
247+
248+
249+
250+
251+
252+
253+ }
231254}
0 commit comments