code: public void calculateChunkedSums(ByteBuffer data, ByteBuffer checksums) {
      if (size == 0) return;
      
      if (data.hasArray() && checksums.hasArray()) {
        calculateChunkedSums(data.array(), data.arrayOffset() + data.position(), data.remaining(),
            checksums.array(), checksums.arrayOffset() + checksums.position());
        return;
      }
      
      data.mark();
      checksums.mark();
      try {
        byte[] buf = new byte[bytesPerChecksum];
        while (data.remaining() > 0) {
          int n = Math.min(data.remaining(), bytesPerChecksum);
          data.get(buf, 0, n);
          summer.reset();
          summer.update(buf, 0, n);
          checksums.putInt((int)summer.getValue());
        }
      } finally {
        data.reset();
        checksums.reset();
      }
    }
docs: Calculate checksums for the given data.
  
  The 'mark' of the ByteBuffer parameters may be modified by this function,
  but the position is maintained.
  
  @param data the DirectByteBuffer pointing to the data to checksum.
  @param checksums the DirectByteBuffer into which checksums will be
  stored. Enough space must be available in this
  buffer to put the checksums.