Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.apache.parquet.HadoopReadOptions;
import org.apache.parquet.ParquetReadOptions;
import org.apache.parquet.Preconditions;
import org.apache.parquet.bytes.ByteBufferAllocator;
import org.apache.parquet.bytes.ByteBufferInputStream;
import org.apache.parquet.bytes.ByteBufferReleaser;
import org.apache.parquet.bytes.BytesInput;
Expand Down Expand Up @@ -1361,8 +1362,32 @@ private void readVectored(List<ConsecutivePartList> allParts, ChunkListBuilder b
totalSize += len;
}
LOG.debug("Reading {} bytes of data with vectored IO in {} ranges", totalSize, ranges.size());
// Request a vectored read;
f.readVectored(ranges, options.getAllocator());
// Wrap the allocator to track buffers allocated during the vectored read.
// Hadoop's vectored IO may merge ranges and return slices of merged buffers,
// so the buffers returned via CompletableFuture may differ from those originally
// allocated. We track the originals here to ensure they are properly released.
ByteBufferAllocator baseAllocator = options.getAllocator();
List<ByteBuffer> allocatedBuffers = new ArrayList<>();
ByteBufferAllocator trackingAllocator = new ByteBufferAllocator() {
@Override
public ByteBuffer allocate(int size) {
ByteBuffer buf = baseAllocator.allocate(size);
allocatedBuffers.add(buf);
return buf;
}

@Override
public void release(ByteBuffer b) {
baseAllocator.release(b);
}

@Override
public boolean isDirect() {
return baseAllocator.isDirect();
}
};
f.readVectored(ranges, trackingAllocator);
builder.addBuffersToRelease(allocatedBuffers);
int k = 0;
for (ConsecutivePartList consecutivePart : allParts) {
ParquetFileRange currRange = ranges.get(k++);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<spotless.version>2.46.1</spotless.version>
<shade.prefix>shaded.parquet</shade.prefix>
<!-- Guarantees no newer classes/methods/constants are used by parquet. -->
<hadoop.version>3.3.0</hadoop.version>
<hadoop.version>3.4.3</hadoop.version>
<parquet.format.version>2.13.0</parquet.format.version>
<previous.version>1.17.0</previous.version>
<thrift.executable>thrift</thrift.executable>
Expand Down