}
private RecordInfo readRecordInfo(RecordLocationImpl location) throws IOException, InvalidRecordLocationException {
if (0 > location.getSegmentIndex() || location.getSegmentIndex() > segments.length) {
throw new InvalidRecordLocationException("Invalid segment id.");
}
Segment segment = segments[location.getSegmentIndex()];
segment.seek(location.getSegmentOffset());
// There can be no record at the append offset.
if (segment.isAtAppendOffset()) {
throw new InvalidRecordLocationException("No record at end of log.");
}
// Is there a record header at the seeked location?
try {
RecordHeader header = new RecordHeader();
segment.readRecordHeader(header);
return new RecordInfo(location, header);
}
catch (IOException e) {
throw new InvalidRecordLocationException("No record at found.");
}
}