private @NotNull CheckerOutputStream buildOldComparerStream(int startingOffsetInFile) throws IOException {
    if (fileLength <= startingOffsetInFile) {
      return new CheckerOutputStream() {
        private int address = startingOffsetInFile - fileLength;

        @Override
        public void write(int b) {
          if (same) {
            AppendMemoryBuffer buffer = appendBuffer;
            same = address < AppendMemoryBuffer.getBufferPosition(buffer)
                   && buffer.getAppendBuffer()[address++] == (byte)b;
          }
        }
      };
    }
    else {
      return new CheckerOutputStream() {
        private int offsetInFile = startingOffsetInFile;
        private int offsetInPage = storage.toOffsetInPage(startingOffsetInFile);
        private Page currentPage = storage.pageByOffset(startingOffsetInFile, /*forWrite: */false);
        private final int pageSize = storage.getPageSize();

        @Override
        public void write(int b) throws IOException {
          if (same) {
            if (pageSize == offsetInPage && offsetInFile < fileLength) {    // reached end of current byte buffer
              offsetInFile += offsetInPage;
              currentPage.close();
              currentPage = storage.pageByOffset(offsetInFile, /*forWrite: */ false);
              offsetInPage = 0;
            }
            same = offsetInPage < fileLength && currentPage.get(offsetInPage) == (byte)b;
            offsetInPage++;
          }
        }

        @Override
        public void close() {
          currentPage.close();
        }
      };
    }
  }
private @NotNull CheckerOutputStream buildOldComparerStream(int startingOffsetInFile)