parquet-common/src/main/java/org/apache/parquet/io/DelegatingSeekableInputStream.java
static int readDirectBuffer(InputStream f, ByteBuffer buf, byte[] temp) throws IOException {
    // copy all the bytes that return immediately, stopping at the first
    // read that doesn't return a full buffer.
    int nextReadLength = Math.min(buf.remaining(), temp.length);
    int totalBytesRead = 0;
    int bytesRead;

    while ((bytesRead = f.read(temp, 0, nextReadLength)) == temp.length) {
      buf.put(temp);
      totalBytesRead += bytesRead;
      nextReadLength = Math.min(buf.remaining(), temp.length);
    }

    if (bytesRead < 0) {
      // return -1 if nothing was read
      return totalBytesRead == 0 ? -1 : totalBytesRead;
    } else {
      // copy the last partial buffer
      buf.put(temp, 0, bytesRead);
      totalBytesRead += bytesRead;
      return totalBytesRead;
    }
  }
static int readDirectBuffer(InputStream f, ByteBuffer buf, byte[] temp) throws IOException {
    // copy all the bytes that return immediately, stopping at the first
    // read that doesn't return a full buffer.
    int nextReadLength = Math.min(buf.remaining(), temp.length);
    int totalBytesRead = 0;
    int bytesRead;

    while ((bytesRead = f.read(temp, 0, nextReadLength)) == temp.length) {
      buf.put(temp);
      totalBytesRead += bytesRead;
      nextReadLength = Math.min(buf.remaining(), temp.length);
    }

    if (bytesRead < 0) {
      // return -1 if nothing was read
      return totalBytesRead == 0 ? -1 : totalBytesRead;
    } else {
      // copy the last partial buffer
      buf.put(temp, 0, bytesRead);
      totalBytesRead += bytesRead;
      return totalBytesRead;
    }
  }
static int readDirectBuffer ( InputStream f , ByteBuffer buf , byte [ ] temp ) throws IOException { // copy all the bytes that return immediately, stopping at the first // read that doesn't return a full buffer. int nextReadLength = Math . min ( buf . remaining ( ) , temp . length ) ; int totalBytesRead = 0 ; int bytesRead ; while ( ( bytesRead = f . read ( temp , 0 , nextReadLength ) ) == temp . length ) { buf . put ( temp ) ; totalBytesRead += bytesRead ; nextReadLength = Math . min ( buf . remaining ( ) , temp . length ) ; } if ( bytesRead < 0 ) { // return -1 if nothing was read return totalBytesRead == 0 ? - 1 : totalBytesRead ; } else { // copy the last partial buffer buf . put ( temp , 0 , bytesRead ) ; totalBytesRead += bytesRead ; return totalBytesRead ; } }
Visible for testing
Visible for testing