dongjoon-hyun commented on code in PR #1072: URL: https://github.com/apache/orc/pull/1072#discussion_r850655084
########## java/core/src/java/org/apache/orc/impl/RecordReaderUtils.java: ########## @@ -405,72 +410,31 @@ static void zeroCopyReadRanges(FSDataInputStream file, } } - /** - * Read the data from the file based on a list of ranges in a single read. - * @param file the file to read from - * @param first the first range to read - * @param last the last range to read - * @param allocateDirect should we use direct buffers - */ - static void readRanges(FSDataInputStream file, - BufferChunk first, - BufferChunk last, - boolean allocateDirect) throws IOException { - // assume that the chunks are sorted by offset - long offset = first.getOffset(); - int readSize = (int) (computeEnd(first, last) - offset); - byte[] buffer = new byte[readSize]; - try { - file.readFully(offset, buffer, 0, buffer.length); - } catch(IOException e) { - throw new IOException(String.format("Failed while reading %s %d:%d", - file, - offset, - buffer.length), - e); - } - - // get the data into a ByteBuffer - ByteBuffer bytes; - if (allocateDirect) { - bytes = ByteBuffer.allocateDirect(readSize); - bytes.put(buffer); - bytes.flip(); - } else { - bytes = ByteBuffer.wrap(buffer); - } - - // populate each BufferChunks with the data - BufferChunk current = first; - while (current != last.next) { - ByteBuffer currentBytes = current == last ? bytes : bytes.duplicate(); - currentBytes.position((int) (current.getOffset() - offset)); - currentBytes.limit((int) (current.getEnd() - offset)); - current.setChunk(currentBytes); - current = (BufferChunk) current.next; - } - } - /** * Find the list of ranges that should be read in a single read. * The read will stop when there is a gap, one of the ranges already has data, * or we have reached the maximum read size of 2^31. * @param first the first range to read + * @param minSeekSize minimum size for seek instead of read * @return the last range to read */ - static BufferChunk findSingleRead(BufferChunk first) { + private static BufferChunk findSingleRead(BufferChunk first, long minSeekSize) { BufferChunk last = first; long currentEnd = first.getEnd(); while (last.next != null && !last.next.hasData() && - last.next.getOffset() <= currentEnd && + last.next.getOffset() <= (currentEnd + minSeekSize) && last.next.getEnd() - first.getOffset() < Integer.MAX_VALUE) { last = (BufferChunk) last.next; currentEnd = Math.max(currentEnd, last.getEnd()); } return last; } + static BufferChunk findSingleRead(BufferChunk first) { Review Comment: Please move function to the original line after the original comment because this is `public`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@orc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org