throws HeapException {
long lastWrotePositionInFile = header.getRecordSize() - 1;
long lastRecordPositionInFile = 0;
for (Map.Entry<Long, IFileStorable> entry : heapRecordToWriteMap
.entrySet()) {
final IFileStorable heapRecord = entry.getValue();
if (heapRecord != NULL_FILE_STORABLE) {
try {
assert false;
} catch (AssertionError error) {
// ASSERTX
final long recordPositionInFile = heapRecord
.getPositionInFile();
if (recordPositionInFile != entry.getKey()) {
throw new HeapException(// NOPMD
"integrity error record position is "
+ recordPositionInFile
+ " and map key is " + entry.getKey());
}
if (recordPositionInFile <= lastWrotePositionInFile) {
throw new HeapException("last wrote position is "// NOPMD
+ lastWrotePositionInFile
+ " and record position in file is "
+ recordPositionInFile
+ " for \n"
+ heapRecord.toString());
}
final long previousRecordPositionInFile = heapRecord
.getPreviousRecordPositionInFile();
if (previousRecordPositionInFile == -1) {
if (recordPositionInFile != header.getRecordSize()) {
throw new HeapException(
"bad position of first record "// NOPMD
+ recordPositionInFile
+ " for "
+ header.getRecordSize()
+ " expected");
}
} else if (previousRecordPositionInFile < lastRecordPositionInFile) {
badPreviousRecordPositionInFileError(
lastRecordPositionInFile, recordPositionInFile,
previousRecordPositionInFile);
}
lastWrotePositionInFile = recordPositionInFile
+ heapRecord.getRecordSize() - 1;
lastRecordPositionInFile = recordPositionInFile;
}
saveHeapRecord(heapRecord, toBackupList);
}
}