Mercurial > hg > Database > Alice
view 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 |
line wrap: on
line source
package alice.test.codesegment.local.wordcount; import alice.codesegment.CodeSegment; import java.io.*; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; public class SetTask extends CodeSegment { private WordConfig conf; public SetTask(WordConfig conf) { this.conf = conf; } @Override public void run() { FileInputStream input; try { input = new FileInputStream(new File(conf.filename)); FileChannel channel = input.getChannel(); int length = (int)channel.size(); MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, length); 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, false)); new WordCount(); start = end; } if (end!=length){ end =length; ods.put("range", new Range(start, end, true)); new WordCount(); i++; } new CorrectResult(i); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }