3232import org .slf4j .LoggerFactory ;
3333
3434import java .io .IOException ;
35- import java .net .URI ;
3635import java .util .List ;
3736import java .util .OptionalLong ;
3837
3938/**
4039 * S3-backed {@link RapidsInputFile} that delegates byte-range reads to
4140 * {@link IcebergS3RangeCopier}. The supplied {@link FileIO} is only used for
4241 * its property map and any per-prefix storage-credential overlays.
43- *
44- * <p>The package-private S3 file access is isolated in {@link IcebergS3InputFileAccess}.
4542 */
4643public final class IcebergS3InputFile implements RapidsInputFile {
4744 private static final Logger LOG = LoggerFactory .getLogger (IcebergS3InputFile .class );
4845
4946 private final IcebergInputFile delegate ;
50- private final URI s3Uri ;
47+ private final String s3Bucket ;
48+ private final String s3Key ;
5149 private final IcebergS3Client icebergS3Client ;
5250
5351 private IcebergS3InputFile (
54- IcebergInputFile delegate , URI s3Uri , IcebergS3Client icebergS3Client ) {
52+ IcebergInputFile delegate ,
53+ String s3Bucket ,
54+ String s3Key ,
55+ IcebergS3Client icebergS3Client ) {
5556 this .delegate = delegate ;
56- this .s3Uri = s3Uri ;
57+ this .s3Bucket = s3Bucket ;
58+ this .s3Key = s3Key ;
5759 this .icebergS3Client = icebergS3Client ;
5860 }
5961
@@ -64,25 +66,27 @@ public static RapidsInputFile maybeCreate(InputFile inputFile, FileIO fileIO) {
6466 if (!RapidsInputFiles .isS3PerfEnabled ()) {
6567 return delegate ;
6668 }
67- URI s3Uri = IcebergS3InputFileAccess .s3Uri (inputFile );
68- if (s3Uri == null ) {
69+ if (!(inputFile instanceof BaseS3File )) {
6970 return delegate ;
7071 }
72+ S3URI s3Uri = ((BaseS3File ) inputFile ).uri ();
73+ String s3Bucket = s3Uri .bucket ();
74+ String s3Key = s3Uri .key ();
7175 // Iceberg < 1.7 does not have SupportsStorageCredentials; ShimUtils returns
7276 // the per-prefix credential overlays (or an empty map on 1.6).
7377 IcebergS3Client icebergS3Client = IcebergS3RangeCopier .resolveClient (
74- s3Uri . toString (),
78+ inputFile . location (),
7579 fileIO .properties (),
7680 ShimUtils .storageCredentialOverlays (fileIO ));
7781 if (icebergS3Client == null ) {
7882 if (TaskContext .get () != null ) {
7983 GpuTaskMetrics$ .MODULE$ .get ().recordPerfioS3IcebergFallback ();
8084 }
81- LOG .debug ("IcebergS3RangeCopier path disabled for {}" , s3Uri );
85+ LOG .debug ("IcebergS3RangeCopier path disabled for {}" , inputFile . location () );
8286 return delegate ;
8387 }
84- LOG .debug ("IcebergS3RangeCopier path active for {}" , s3Uri );
85- return new IcebergS3InputFile (delegate , s3Uri , icebergS3Client );
88+ LOG .debug ("IcebergS3RangeCopier path active for {}" , inputFile . location () );
89+ return new IcebergS3InputFile (delegate , s3Bucket , s3Key , icebergS3Client );
8690 }
8791
8892 @ Override
@@ -117,7 +121,8 @@ public InputFile getDelegate() {
117121 @ Override
118122 public void readVectored (HostMemoryBuffer output , List <CopyRange > copyRanges )
119123 throws IOException {
120- IcebergS3RangeCopier .copyToHMB (icebergS3Client , output , s3Uri , copyRanges );
124+ IcebergS3RangeCopier .copyToHMB (
125+ icebergS3Client , output , s3Bucket , s3Key , copyRanges );
121126 }
122127
123128 /**
@@ -133,6 +138,7 @@ public void readTail(long length, HostMemoryBuffer output) throws IOException {
133138 if (length < 0 ) {
134139 throw new IllegalArgumentException ("length must be non-negative" );
135140 }
136- IcebergS3RangeCopier .copyTailToHMB (icebergS3Client , output , s3Uri , length , /*dstOffset*/ 0L );
141+ IcebergS3RangeCopier .copyTailToHMB (
142+ icebergS3Client , output , s3Bucket , s3Key , length , /*dstOffset*/ 0L );
137143 }
138144}
0 commit comments