| | |
| | | /** |
| | | * 分配每个线程处理的起止位置 |
| | | */ |
| | | public static List contSaveThreadContInfo(Map taskInfo) { |
| | | List contlist = new ArrayList(); |
| | | public static List<Map<String,Long>> contSaveThreadContInfo(Map taskInfo) { |
| | | List<Map<String,Long>> contlist = new ArrayList<Map<String,Long>>(); |
| | | try { |
| | | RandomAccessFile raf = new RandomAccessFile(taskInfo.get("localfilename").toString(), "r"); |
| | | int tnum = Integer.valueOf(taskInfo.get("TNUM").toString()); |
| | |
| | | } |
| | | for (int i = 0; i < tnum; i++) { |
| | | if (i == tnum - 1) { |
| | | Map tmp = new HashMap(); |
| | | Map<String,Long> tmp = new HashMap<String,Long>(); |
| | | tmp.put("begin", begin); |
| | | tmp.put("end", filelen - 1); |
| | | contlist.add(tmp); |
| | |
| | | if (end < begin) { |
| | | begin = 0; |
| | | end = begin; |
| | | Map tmp = new HashMap(); |
| | | Map<String,Long> tmp = new HashMap<String,Long>(); |
| | | tmp.put("begin", begin); |
| | | tmp.put("end", end); |
| | | contlist.add(tmp); |
| | |
| | | while (end > 0) { |
| | | raf.seek(end); |
| | | if (raf.readByte() == '\n') { |
| | | Map tmp = new HashMap(); |
| | | Map<String,Long> tmp = new HashMap<String,Long>(); |
| | | tmp.put("begin", begin); |
| | | tmp.put("end", end); |
| | | contlist.add(tmp); |