}
private void checkFreeNodeInTree(final HeapRecord heapRecord)
throws RBTException, HeapException {
if (!heapRecord.isFreeRecord()) {
throw new HeapException("must be a free node");
}
final HeapFreeNode node = (HeapFreeNode) heapRecord.getFreeNode();
if (node.getPositionInFile() != heapRecord.getPositionInFile()) {
throw new HeapException(
"position in file mismatch: heap record is "
+ heapRecord.getPositionInFile()
+ " and free node is " + node.getPositionInFile());
}
if (node.getRecordSize() != heapRecord.getRecordSize()) {
throw new HeapException("area size mismatch: heap record is "
+ heapRecord.getRecordSize() + " and free node is "
+ node.getRecordSize());
}
HeapFreeNode found;
found = (HeapFreeNode) freeNodeTree.search(heapRecord.getRecordSize());
if (found == null) {
throw new HeapException("free record must exist in free tree\n"
+ heapRecord);
}
while (found.getPositionInFile() != heapRecord.getPositionInFile()) {
found = (HeapFreeNode) freeNodeTree.next(found);
if (found == null
|| found.getRecordSize() != heapRecord.getRecordSize()) {
throw new HeapException("free record must exist in free tree");
}
}
}