Skip to content

Commit 530d6c3

Browse files
committed
PARQUET-2493. pull read policy declaration into reader code
Change-Id: I7de43d8426b56800c540a520f1fb7fef21ae60ba
1 parent 677d2fd commit 530d6c3

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

parquet-hadoop/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,11 @@
160160
<artifactId>zstd-jni</artifactId>
161161
<version>${zstd-jni.version}</version>
162162
</dependency>
163-
163+
<dependency>
164+
<groupId>com.google.code.findbugs</groupId>
165+
<artifactId>jsr305</artifactId>
166+
<version>${jsr305.version}</version>
167+
</dependency>
164168
<dependency>
165169
<groupId>com.google.guava</groupId>
166170
<artifactId>guava</artifactId>

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/HadoopInputFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public long getLength() {
7373

7474
@Override
7575
public SeekableInputStream newStream() throws IOException {
76-
return HadoopStreams.wrap(DynamicWrappedIO.openFile(fs, stat));
76+
return HadoopStreams.wrap(DynamicWrappedIO.openFile(fs, stat, DynamicWrappedIO.PARQUET_READ_POLICIES));
7777
}
7878

7979
@Override

parquet-hadoop/src/main/java/org/apache/parquet/hadoop/util/wrapped/io/DynamicWrappedIO.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,16 @@ public static boolean isAvailable() {
374374
* <p>
375375
* If the WrappedIO class is found, uses
376376
* {@link #fileSystem_openFile(FileSystem, Path, String, FileStatus, Long, Map)} with
377-
* {@link #PARQUET_READ_POLICIES} as the list of read policies and passing down
377+
* the supplied list of read policies and passing down
378378
* the file status.
379379
* <p>
380380
* If not, falls back to the classic {@code fs.open(Path)} call.
381381
* @param fs filesystem
382382
* @param status file status
383+
* @param policy read policy
383384
* @throws IOException any IO failure.
384385
*/
385-
public static FSDataInputStream openFile(FileSystem fs, FileStatus status) throws IOException {
386+
public static FSDataInputStream openFile(FileSystem fs, FileStatus status, String policy) throws IOException {
386387
final DynamicWrappedIO instance = DynamicWrappedIO.instance();
387388
FSDataInputStream stream;
388389
if (instance.fileSystem_openFile_available()) {
@@ -392,8 +393,8 @@ public static FSDataInputStream openFile(FileSystem fs, FileStatus status) throw
392393
// in open and choosing the range for GET requests.
393394
// For other stores, it ultimately invokes the classic open(Path)
394395
// call so is no more expensive than before.
395-
LOG.debug("Opening file {} through fileSystem_openFile", status);
396-
stream = instance.fileSystem_openFile(fs, status.getPath(), PARQUET_READ_POLICIES, status, null, null);
396+
LOG.debug("Opening file {} through fileSystem_openFile() with policy {}", status, policy);
397+
stream = instance.fileSystem_openFile(fs, status.getPath(), policy, status, null, null);
397398
} else {
398399
LOG.debug("Opening file {} through open()", status);
399400
stream = fs.open(status.getPath());

parquet-hadoop/src/test/java/org/apache/parquet/hadoop/TestParquetFileWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ public void testAlignmentWithPadding() throws Exception {
652652
long fileLen = stat.getLen();
653653

654654
long footerLen;
655-
try (FSDataInputStream data = DynamicWrappedIO.openFile(fs, stat)) {
655+
try (FSDataInputStream data = DynamicWrappedIO.openFile(fs, stat, DynamicWrappedIO.PARQUET_READ_POLICIES)) {
656656
data.seek(fileLen - 8); // 4-byte offset + "PAR1"
657657
footerLen = BytesUtils.readIntLittleEndian(data);
658658
}

0 commit comments

Comments
 (0)