private void copy(InputStream from, OutputStream to, int length) throws IOException {
      int bytesStillToRead = length;
      final byte[] ioArray = mByteArrayPool.get(READ_SIZE);
      try {
        int bufferLength;
        while (bytesStillToRead > 0
            && (bufferLength = from.read(ioArray, 0, Math.min(READ_SIZE, bytesStillToRead))) >= 0) {
          if (bufferLength > 0) {
            to.write(ioArray, 0, bufferLength);
            bytesStillToRead -= bufferLength;
          }
        }
      } finally {
        mByteArrayPool.release(ioArray);
      }

      if (bytesStillToRead > 0) {
        throw new IOException(
            String.format(
                (Locale) null,
                "Failed to read %d bytes - finished %d short",
                length,
                bytesStillToRead));
      }
    }
Consumer that consumes results from next producer in the sequence.

<p>If the consumer receives a partial result, it caches it on disk with an appropriate key to
differentiate from the full image.

<p>If a partial image is already held, it combines new results with that partial data and
passes the combination to the next consumer.
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/PartialDiskCacheProducer.java