You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by "David Mollitor (Jira)" <ji...@apache.org> on 2021/07/20 15:20:00 UTC

[jira] [Created] (ORC-854) Optimize ReadFully for Full Reads

David Mollitor created ORC-854:
----------------------------------

             Summary: Optimize ReadFully for Full Reads
                 Key: ORC-854
                 URL: https://issues.apache.org/jira/browse/ORC-854
             Project: ORC
          Issue Type: Improvement
            Reporter: David Mollitor
            Assignee: David Mollitor


{code:java|title=SerializationUtils.java}
  private void readFully(final InputStream in, final byte[] buffer, final int off, final int len)
      throws IOException {
    int n = 0;
    while (n < len) {
      int count = in.read(buffer, off + n, len - n);
      if (count < 0) {
        throw new EOFException("Read past EOF for " + in);
      }
      n += count;
    }
  }
{code}

This code is reading only small buffers: 4/8 bytes at a time. Very unlikely that it will need to read more than once from the underlying, buffered, data stream.  Optimize this code by assuming that reading from the underlying source will always return the requested number of bytes.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)