docs: @SuppressWarnings("unchecked")
    private void readNext() {
      // Compute the index of the next entry in the segment.
      final long index = getNextIndex();
  
      // Mark the buffer so it can be reset if necessary.
      buffer.mark();
  
      try {
        // Read the length of the entry.
        final int length = buffer.getInt();
  
        // If the buffer length is zero then return.
        if (length <= 0 || length > maxEntrySize) {
          buffer.reset();
          nextEntry = null;
          return;
        }
  
        // Read the checksum of the entry.
        long checksum = buffer.getInt() & 0xFFFFFFFFL;
  
        // Compute the checksum for the entry bytes.
        final CRC32 crc32 = new CRC32();
        ByteBuffer slice = buffer.slice();
        slice.limit(length);
        crc32.update(slice);
  
        // If the stored checksum equals the computed checksum, return the entry.
        if (checksum == crc32.getValue()) {
          slice.rewind();
          E entry = namespace.deserialize(slice);
          nextEntry = new Indexed<>(index, entry, length);
          buffer.position(buffer.position() + length);
        } else {
          buffer.reset();
          nextEntry = null;
        }
      } catch (BufferUnderflowException e) {
        buffer.reset();
        nextEntry = null;
      }
    }