@Override
  public LogChunk read(long chunkId) throws IOException {
    long chunkOffsetInFile = chunkIdToOffset(chunkId);

    long chunksCommittedUpTo = header.firstUnCommittedOffset();
    if (chunkOffsetInFile >= chunksCommittedUpTo) {
      throw new IllegalArgumentException(
        "Can't read chunk(id: " + chunkId + ", offset: " + chunkOffsetInFile + "): " +
        "outside of committed region [<" + chunksCommittedUpTo + "] " +
        moreDiagnosticInfo(chunkOffsetInFile));
    }


    MMappedFileStorage.Page page = storage.pageByOffset(chunkOffsetInFile);
    int chunkOffsetInPage = storage.toOffsetInPage(chunkOffsetInFile);
    ByteBuffer pageBuffer = page.rawPageBuffer();

    LogChunkImpl chunk = readChunkAt(
      pageBuffer,
      chunkOffsetInPage,
      chunkOffsetInFile
    );
    if (!chunk.isFitIntoPage()) {
      throw new CorruptedException(chunk + ".chunkLength(=" + chunk.chunkLength() + ") " +
                                   "is incorrect: page[0.." + pageBuffer.limit() + "], " +
                                   "committedUpTo: " + header.firstUnCommittedOffset() + ", " +
                                   "allocatedUpTo: " + header.firstUnAllocatedOffset() + ". " +
                                   moreDiagnosticInfo(chunkOffsetInFile) +
                                   (ADD_LOG_CONTENT ? "\n" + dumpContentAroundId(chunk.id(), DEBUG_DUMP_REGION_WIDTH) : "")
      );
    }


    if (chunk.isPadding()) {
      throw new IOException(chunk + " is a PaddingChunk -- i.e. has no data. " + moreDiagnosticInfo(chunkOffsetInFile));
    }

    return chunk;
  }
@Override
  public LogChunk read(long chunkId)