Mercurial > hg > Database > Alice
changeset 243:c70cd1b2caca
remove word_count bug
author | sugi |
---|---|
date | Wed, 08 May 2013 15:43:49 +0900 |
parents | 3bcaf12cf877 |
children | a560b92bfd72 |
files | src/alice/test/codesegment/local/bitonicsort/Sort.java src/alice/test/codesegment/local/bitonicsort/SortTest.java src/alice/test/codesegment/local/wordcount/CorrectResult.java src/alice/test/codesegment/local/wordcount/Range.java src/alice/test/codesegment/local/wordcount/SetTask.java src/alice/test/codesegment/local/wordcount/WordCount.java |
diffstat | 6 files changed, 24 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/test/codesegment/local/bitonicsort/Sort.java Tue Apr 16 18:26:07 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/Sort.java Wed May 08 15:43:49 2013 +0900 @@ -11,7 +11,7 @@ int end = data.table.length-1; // index is up to length-1 while(true){ while(begin < end){ - if (end-begin< 150){ + if (end-begin< 40){ bubbleSort(data,begin,end); break; } else {
--- a/src/alice/test/codesegment/local/bitonicsort/SortTest.java Tue Apr 16 18:26:07 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/SortTest.java Wed May 08 15:43:49 2013 +0900 @@ -5,9 +5,9 @@ public class SortTest { public static void main(String args[]){ - int size1 = 10000; + int size1 = 1000000; int size2 = 1000; - int MAX = 100000; + int MAX = 1000000; long t; DataList list1 = new DataList(size1); DataList list2 = new DataList(size1);
--- a/src/alice/test/codesegment/local/wordcount/CorrectResult.java Tue Apr 16 18:26:07 2013 +0900 +++ b/src/alice/test/codesegment/local/wordcount/CorrectResult.java Wed May 08 15:43:49 2013 +0900 @@ -10,8 +10,9 @@ public CorrectResult(int size) { array = new Receiver[size]; - for (int i=0;i<size;i++) + for (int i=0;i<size;i++){ array[i] = ids.create(CommandType.TAKE); + } for (int i=0;i<size;i++) array[i].setKey("result"); }
--- a/src/alice/test/codesegment/local/wordcount/Range.java Tue Apr 16 18:26:07 2013 +0900 +++ b/src/alice/test/codesegment/local/wordcount/Range.java Wed May 08 15:43:49 2013 +0900 @@ -7,9 +7,11 @@ public int start; public int end; - public Range(int _start, int _end) { + public boolean flag; + public Range(int _start, int _end, boolean _flag) { start = _start; end = _end; + flag = _flag; } }
--- a/src/alice/test/codesegment/local/wordcount/SetTask.java Tue Apr 16 18:26:07 2013 +0900 +++ b/src/alice/test/codesegment/local/wordcount/SetTask.java Wed May 08 15:43:49 2013 +0900 @@ -24,63 +24,28 @@ ods.put("array", buffer); int start=0,end=0,i=0; int size = conf.division * 1024; - + + System.out.println(length); for (;start+size<length;i++){ end = start+size; - ods.put("range", new Range(start,end)); + ods.put("range", new Range(start, end, false)); new WordCount(); start = end; } - if (start+size-1!=length){ + if (end!=length){ end =length; - ods.put("range", new Range(start,end)); + ods.put("range", new Range(start, end, true)); new WordCount(); i++; } - new CorrectResult(i); - //System.out.println((char)buffer.get(i)); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } - - - /* - BufferedReader br = null; - int i = 0; - try { - br= new BufferedReader( - new InputStreamReader( - new FileInputStream( - new File(conf.filename) - ))); - int size = conf.division * 1024 ; // 16Kbyte - char[] buf; - for (;;i++){ - buf = new char[size]; - int check = br.read(buf); - ods.put("array", buf); - new WordCount(); - if (check==-1) break; - - } - System.out.println(i); - new CorrectResult(i); - } catch (FileNotFoundException e) { - System.out.println("file not found"); - System.exit(0); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - br.close(); - } catch (IOException e) { - e.printStackTrace(); - }*/ + } }
--- a/src/alice/test/codesegment/local/wordcount/WordCount.java Tue Apr 16 18:26:07 2013 +0900 +++ b/src/alice/test/codesegment/local/wordcount/WordCount.java Wed May 08 15:43:49 2013 +0900 @@ -25,9 +25,9 @@ int line_num = 0; for (int i = r.start; i < r.end; i++) { - if ((char)buf.get(i) == 0x20) { // 空白 + if ((char)buf.get(i) == 0x20) { // 空白 word_flag = 1; - } else if ((char)buf.get(i) == 0x0A) { // 改行 + } else if ((char)buf.get(i) == 0x0A) { // 改行 line_num += 1; word_flag = 1; } else { @@ -35,7 +35,14 @@ word_flag = 0; } } - + word_num += word_flag; + if (!r.flag){ + if (((char)buf.get(r.end-1) == 0x0A||(char)buf.get(r.end-1) == 0x20) && + ((char)buf.get(r.end) == 0x0A||(char)buf.get(r.end) == 0x20)){ + word_num--; + } + } + Result result = new Result(line_num,word_num); ods.put("result", result); }