private long recoverRegion(long nextRecordToBeCommittedOffset,
                             long nextRecordToBeAllocatedOffset) throws IOException {
    int pageSize = storage.pageSize();
    for (long chunkOffsetInFile = nextRecordToBeCommittedOffset;
         chunkOffsetInFile < nextRecordToBeAllocatedOffset; ) {
      MMappedFileStorage.Page page = storage.pageByOffset(chunkOffsetInFile);
      int chunkOffsetInPage = storage.toOffsetInPage(chunkOffsetInFile);
      ByteBuffer pageBuffer = page.rawPageBuffer();

      if (pageSize - chunkOffsetInPage <= LogChunkImpl.HEADER_SIZE) {
        throw new CorruptedException(
          getClass().getSimpleName() + " corrupted: chunkOffsetInPage(=" + chunkOffsetInPage + ") less than " +
          "RECORD_HEADER(=" + LogChunkImpl.HEADER_SIZE + "b) left until " +
          "pageEnd(" + pageSize + ") -- all chunks must be 64b-aligned"
        );
      }

      int chunkHeader = LogChunkImpl.readHeader(pageBuffer, chunkOffsetInPage);

      if (!LogChunkImpl.isHeaderSet(chunkHeader)) {
        //Can't recover farther: actual length of record is unknown
        return chunkOffsetInFile;
      }


      if (LogChunkImpl.isDataChunk(chunkHeader)) {
        //FIXME RC: check chunk _content_, and zero region (committed..capacity], if committed < allocated
        //else: record OK -> move to the next one
      }
      else if (LogChunkImpl.isPaddingChunk(chunkHeader)) {
        //padding is always committed -> move to the next one
      }
      else {
        //Unrecognizable garbage: we could just stop recovering here, and erase everything from
        //  here and up -- but for now I'd prefer to know how that could even happen (could it?)
        throw new CorruptedException("header(=" + chunkHeader + "](@offset=" + chunkOffsetInFile + "): not a padding, nor a data record");
      }

      int chunkLength = LogChunkImpl.unpackChunkLength(chunkHeader);
      chunkOffsetInFile = nextChunkOffset(chunkOffsetInFile, chunkLength);
    }
    return nextRecordToBeAllocatedOffset;
  }
private long recoverRegion(long nextRecordToBeCommittedOffset,
                             long nextRecordToBeAllocatedOffset)