comparison src/alice/test/codesegment/local/wordcount/SetTask.java @ 243:c70cd1b2caca

remove word_count bug
author sugi
date Wed, 08 May 2013 15:43:49 +0900
parents 3bcaf12cf877
children
comparison
equal deleted inserted replaced
242:3bcaf12cf877 243:c70cd1b2caca
22 int length = (int)channel.size(); 22 int length = (int)channel.size();
23 MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, length); 23 MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, length);
24 ods.put("array", buffer); 24 ods.put("array", buffer);
25 int start=0,end=0,i=0; 25 int start=0,end=0,i=0;
26 int size = conf.division * 1024; 26 int size = conf.division * 1024;
27 27
28 System.out.println(length);
28 for (;start+size<length;i++){ 29 for (;start+size<length;i++){
29 end = start+size; 30 end = start+size;
30 ods.put("range", new Range(start,end)); 31 ods.put("range", new Range(start, end, false));
31 new WordCount(); 32 new WordCount();
32 start = end; 33 start = end;
33 } 34 }
34 35
35 if (start+size-1!=length){ 36 if (end!=length){
36 end =length; 37 end =length;
37 ods.put("range", new Range(start,end)); 38 ods.put("range", new Range(start, end, true));
38 new WordCount(); 39 new WordCount();
39 i++; 40 i++;
40 } 41 }
41
42 new CorrectResult(i); 42 new CorrectResult(i);
43 //System.out.println((char)buffer.get(i));
44 } catch (FileNotFoundException e) { 43 } catch (FileNotFoundException e) {
45 e.printStackTrace(); 44 e.printStackTrace();
46 } catch (IOException e) { 45 } catch (IOException e) {
47 e.printStackTrace(); 46 e.printStackTrace();
48 } 47 }
49 48
50
51 /*
52 BufferedReader br = null;
53 int i = 0;
54 try {
55 br= new BufferedReader(
56 new InputStreamReader(
57 new FileInputStream(
58 new File(conf.filename)
59 )));
60 int size = conf.division * 1024 ; // 16Kbyte
61 char[] buf;
62 for (;;i++){
63 buf = new char[size];
64 int check = br.read(buf);
65 ods.put("array", buf);
66 new WordCount();
67 if (check==-1) break;
68
69 }
70 System.out.println(i);
71 new CorrectResult(i);
72 } catch (FileNotFoundException e) {
73 System.out.println("file not found");
74 System.exit(0);
75 } catch (IOException e) {
76 e.printStackTrace();
77 }
78
79 try {
80 br.close();
81 } catch (IOException e) {
82 e.printStackTrace();
83 }*/
84 } 49 }
85 50
86 } 51 }