MCPcopy Create free account
hub / github.com/cschanck/single-file-java / rebuild

Method rebuild

src/main/java/org/sfj/ChiseledMap.java:214–231  ·  view source on GitHub ↗
(FileChannel fc)

Source from the content-addressed store, hash-verified

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

Callers 1

ChiseledMapMethod · 0.95

Calls 3

fetchMethod · 0.95
putMethod · 0.45
getKeyMethod · 0.45

Tested by

no test coverage detected