code: public ReadRecordStatus readRecord(byte[] hostBytes, final int processed)
              throws IOException {
  
          if (getBytesPrefetched() > 0) {
              // Data must be prefetched only once, before any reads
              if (residual > 0 || lastCount > 0 || processed > 0) {
                  throw new IOException(
                          "Data was prefetched after the first read");
              }
              lastCount = getBytesPrefetched();
              setBytesPrefetched(0);
          }
  
          residual = residual + lastCount - processed;
          if (residual == hostBytes.length) {
              lastCount = 0;
              // Buffer is already filled
              return new ReadRecordStatus(residual);
          } else if (residual > 0) {
              // Move residual at start of buffer
              System.arraycopy(hostBytes, processed, hostBytes, 0, residual);
          }
  
          // Fill the buffer
          lastCount = read(hostBytes, residual, hostBytes.length - residual);
          if (lastCount == -1) {
              if (residual > 0) {
                  lastCount = 0;
                  return new ReadRecordStatus(residual);
              } else {
                  return new ReadRecordStatus(lastCount);
              }
          }
          return new ReadRecordStatus(residual + lastCount);
      }
docs: Reads a record from the stream.
  <p/>
  Because this reader has no means to know the record length, it just fills
  the input buffer.
  <p/>
  We might have data read in excess last time that we still need to process
  so this will push unprocessed bytes (residual) at the start of the buffer
  and then try to fill the rest of the buffer with fresh data (if there is
  room left).
  
  @param hostBytes a buffer where to read the record
  @param processed the number of bytes that were processed following the
  previous read operation.
  @return the status of the read operation, including the number of bytes read from the stream
  @throws IOException