private Record readPhysicalRecord(boolean expectEnd) throws IOException {
    int bytesToBlockEnd = findBytesToBlockEnd();
    if (bytesToBlockEnd < HEADER_LENGTH) {
      readToTmp(bytesToBlockEnd, expectEnd);
      return createRecordFromTmp(RecordType.NONE);
    }
    readToTmp(HEADER_LENGTH, expectEnd);

    int checksum = tmpBuffer.getInt();
    int length = tmpBuffer.getShort();
    if (length > bytesToBlockEnd || length < 0) {
      throw new CorruptDataException("Length is too large:" + length);
    }
    RecordType type = RecordType.get(tmpBuffer.get());
    if (type == RecordType.NONE && length == 0) {
      length = bytesToBlockEnd - HEADER_LENGTH;
    }
    readToTmp(length, false);

    if (!isValidCrc(checksum, tmpBuffer, type.value())) {
      throw new CorruptDataException("Checksum doesn't validate.");
    }
    return createRecordFromTmp(type);
  }
private Record readPhysicalRecord ( boolean expectEnd ) throws IOException { int bytesToBlockEnd = findBytesToBlockEnd ( ) ; if ( bytesToBlockEnd < HEADER_LENGTH ) { readToTmp ( bytesToBlockEnd , expectEnd ) ; return createRecordFromTmp ( RecordType . NONE ) ; } readToTmp ( HEADER_LENGTH , expectEnd ) ; int checksum = tmpBuffer . getInt ( ) ; int length = tmpBuffer . getShort ( ) ; if ( length > bytesToBlockEnd || length < 0 ) { throw new CorruptDataException ( "Length is too large:" + length ) ; } RecordType type = RecordType . get ( tmpBuffer . get ( ) ) ; if ( type == RecordType . NONE && length == 0 ) { length = bytesToBlockEnd - HEADER_LENGTH ; } readToTmp ( length , false ) ; if ( ! isValidCrc ( checksum , tmpBuffer , type . value ( ) ) ) { throw new CorruptDataException ( "Checksum doesn't validate." ) ; } return createRecordFromTmp ( type ) ; }
Reads the next record from the LevelDb data stream.

@param expectEnd if end of stream encountered will throw {@link NoSuchElementException} when
true and {@link CorruptDataException} when false.
@return Record data of the physical record read.
@throws IOException