(FileChannel fc)
| 212 | } |
| 213 | |
| 214 | private void rebuild(FileChannel fc) throws IOException { |
| 215 | // scan the entire file, loading each entry where crc matches. |
| 216 | currentWritePos = HDR.length; |
| 217 | long[] nextPos = new long[1]; |
| 218 | for (; ; ) { |
| 219 | try { |
| 220 | Entry<K, V> got = fetch(currentWritePos, true, nextPos); |
| 221 | map.put(got.getKey(), currentWritePos); |
| 222 | currentWritePos = nextPos[0]; |
| 223 | entriesOnDisk++; |
| 224 | } catch (Exception e) { |
| 225 | // truncate to end of last known good block. |
| 226 | nextWritePos = currentWritePos; |
| 227 | fc.truncate(currentWritePos); |
| 228 | break; |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | private Entry<K, V> fetch(long addr, boolean check, long[] nextPos) throws IOException { |
| 234 | // core retrieval by address code. First, flush outstanding data |
no test coverage detected