-
Notifications
You must be signed in to change notification settings - Fork 292
Use configured copy buffer for Hadoop vectored reads #15164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2025, NVIDIA CORPORATION. | ||
| * Copyright (c) 2025-2026, NVIDIA CORPORATION. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
|
|
@@ -16,14 +16,15 @@ | |
|
|
||
| package com.nvidia.spark.rapids.fileio.hadoop; | ||
|
|
||
| import ai.rapids.cudf.HostMemoryBuffer; | ||
| import com.nvidia.spark.rapids.jni.fileio.RapidsInputFile; | ||
| import com.nvidia.spark.rapids.jni.fileio.SeekableInputStream; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileStatus; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.hadoop.fs.Path; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.OptionalLong; | ||
|
|
||
|
|
@@ -34,21 +35,30 @@ | |
| * for reading the file. | ||
| */ | ||
| public class HadoopInputFile implements RapidsInputFile { | ||
| private static final String PARQUET_READ_ALLOCATION_SIZE = "parquet.read.allocation.size"; | ||
|
|
||
| private final Path filePath; | ||
| private final FileSystem fs; | ||
| private final int copyBufferSize; | ||
|
|
||
| public static HadoopInputFile create(Path filePath, Configuration conf) throws IOException { | ||
| Objects.requireNonNull(filePath, "filePath can't be null!"); | ||
| Objects.requireNonNull(conf, "Hadoop conf can't be null"); | ||
| FileSystem fs = filePath.getFileSystem(conf); | ||
| return new HadoopInputFile(filePath, fs); | ||
| int copyBufferSize = conf.getInt(PARQUET_READ_ALLOCATION_SIZE, | ||
| RapidsInputFile.DEFAULT_READ_VECTORED_COPY_BUFFER_SIZE); | ||
| return new HadoopInputFile(filePath, fs, copyBufferSize); | ||
| } | ||
|
|
||
| private HadoopInputFile(Path filePath, FileSystem fs) { | ||
| private HadoopInputFile(Path filePath, FileSystem fs, int copyBufferSize) { | ||
| Objects.requireNonNull(filePath, "filePath can't be null!"); | ||
| Objects.requireNonNull(fs, "FileSystem can't be null"); | ||
| if (copyBufferSize <= 0) { | ||
| throw new IllegalArgumentException(PARQUET_READ_ALLOCATION_SIZE + " must be positive"); | ||
| } | ||
|
Comment on lines
+56
to
+58
|
||
| this.filePath = filePath; | ||
| this.fs = fs; | ||
| this.copyBufferSize = copyBufferSize; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -70,4 +80,14 @@ public OptionalLong getLastModificationTime() throws IOException { | |
| public SeekableInputStream open() throws IOException { | ||
| return new HadoopInputStream(fs.open(filePath)); | ||
| } | ||
|
|
||
| @Override | ||
| public void readVectored(HostMemoryBuffer output, List<RapidsInputFile.CopyRange> copyRanges) | ||
| throws IOException { | ||
| if (copyRanges.isEmpty()) { | ||
| return; | ||
| } | ||
| byte[] copyBuffer = new byte[copyBufferSize]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking for a follow-up: HadoopInputFile could allocate min(copyBufferSize, largest requested range) like the JNI default path does, instead of always allocating copyBufferSize. That keeps the current per-call lifetime and thread-safety properties, while avoiding an 8 MiB allocation for small footer/range reads. |
||
| RapidsInputFile.readVectoredUsingCopyBuffer(this, output, copyRanges, copyBuffer); | ||
| } | ||
|
Comment on lines
+89
to
+92
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
RapidsInputFile.DEFAULT_READ_VECTORED_COPY_BUFFER_SIZE(line 49) andRapidsInputFile.readVectoredUsingCopyBuffer(line 91) are added inNVIDIA/cudf-spark-jni#4765, which has not yet been published in the 26.06 artifact. The PR description notes the twocannot find symbolcompile errors are expected until that JNI change ships. This PR cannot be merged independently and must be gated on the JNI PR landing first.