3
3
//
4
4
package io .deephaven .parquet .base ;
5
5
6
- import io .deephaven .UncheckedDeephavenException ;
7
6
import io .deephaven .util .channel .CachedChannelProvider ;
8
7
import io .deephaven .util .channel .SeekableChannelContext ;
9
8
import io .deephaven .util .channel .SeekableChannelsProvider ;
10
- import io .deephaven .util .channel .SeekableChannelsProviderLoader ;
11
9
import org .apache .parquet .format .*;
12
10
import org .apache .parquet .format .ColumnOrder ;
13
11
import org .apache .parquet .format .Type ;
14
12
import org .apache .parquet .schema .*;
15
13
import org .jetbrains .annotations .NotNull ;
16
- import org .jetbrains .annotations .Nullable ;
17
14
18
15
import java .io .File ;
19
16
import java .io .IOException ;
20
17
import java .io .InputStream ;
18
+ import java .io .UncheckedIOException ;
21
19
import java .net .URI ;
22
20
import java .nio .channels .SeekableByteChannel ;
23
21
import java .util .*;
@@ -44,94 +42,50 @@ public class ParquetFileReader {
44
42
45
43
/**
46
44
* Make a {@link ParquetFileReader} for the supplied {@link File}. Wraps {@link IOException} as
47
- * {@link UncheckedDeephavenException }.
45
+ * {@link UncheckedIOException }.
48
46
*
49
47
* @param parquetFile The parquet file or the parquet metadata file
50
- * @param specialInstructions Optional read instructions to pass to {@link SeekableChannelsProvider} while creating
51
- * channels
48
+ * @param channelsProvider The {@link SeekableChannelsProvider} to use for reading the file
52
49
* @return The new {@link ParquetFileReader}
53
50
*/
54
51
public static ParquetFileReader create (
55
52
@ NotNull final File parquetFile ,
56
- @ Nullable final Object specialInstructions ) {
53
+ @ NotNull final SeekableChannelsProvider channelsProvider ) {
57
54
try {
58
- return createChecked ( parquetFile , specialInstructions );
59
- } catch (IOException e ) {
60
- throw new UncheckedDeephavenException ("Failed to create Parquet file reader: " + parquetFile , e );
55
+ return new ParquetFileReader ( convertToURI ( parquetFile , false ), channelsProvider );
56
+ } catch (final IOException e ) {
57
+ throw new UncheckedIOException ("Failed to create Parquet file reader: " + parquetFile , e );
61
58
}
62
59
}
63
60
64
61
/**
65
62
* Make a {@link ParquetFileReader} for the supplied {@link URI}. Wraps {@link IOException} as
66
- * {@link UncheckedDeephavenException }.
63
+ * {@link UncheckedIOException }.
67
64
*
68
65
* @param parquetFileURI The URI for the parquet file or the parquet metadata file
69
- * @param specialInstructions Optional read instructions to pass to {@link SeekableChannelsProvider} while creating
70
- * channels
66
+ * @param channelsProvider The {@link SeekableChannelsProvider} to use for reading the file
71
67
* @return The new {@link ParquetFileReader}
72
68
*/
73
69
public static ParquetFileReader create (
74
70
@ NotNull final URI parquetFileURI ,
75
- @ Nullable final Object specialInstructions ) {
71
+ @ NotNull final SeekableChannelsProvider channelsProvider ) {
76
72
try {
77
- return createChecked (parquetFileURI , specialInstructions );
78
- } catch (IOException e ) {
79
- throw new UncheckedDeephavenException ("Failed to create Parquet file reader: " + parquetFileURI , e );
73
+ return new ParquetFileReader (parquetFileURI , channelsProvider );
74
+ } catch (final IOException e ) {
75
+ throw new UncheckedIOException ("Failed to create Parquet file reader: " + parquetFileURI , e );
80
76
}
81
77
}
82
78
83
- /**
84
- * Make a {@link ParquetFileReader} for the supplied {@link File}.
85
- *
86
- * @param parquetFile The parquet file or the parquet metadata file
87
- * @param specialInstructions Optional read instructions to pass to {@link SeekableChannelsProvider} while creating
88
- * channels
89
- * @return The new {@link ParquetFileReader}
90
- * @throws IOException if an IO exception occurs
91
- */
92
- public static ParquetFileReader createChecked (
93
- @ NotNull final File parquetFile ,
94
- @ Nullable final Object specialInstructions ) throws IOException {
95
- return createChecked (convertToURI (parquetFile , false ), specialInstructions );
96
- }
97
-
98
- /**
99
- * Make a {@link ParquetFileReader} for the supplied {@link URI}.
100
- *
101
- * @param parquetFileURI The URI for the parquet file or the parquet metadata file
102
- * @param specialInstructions Optional read instructions to pass to {@link SeekableChannelsProvider} while creating
103
- * channels
104
- * @return The new {@link ParquetFileReader}
105
- * @throws IOException if an IO exception occurs
106
- */
107
- public static ParquetFileReader createChecked (
108
- @ NotNull final URI parquetFileURI ,
109
- @ Nullable final Object specialInstructions ) throws IOException {
110
- final SeekableChannelsProvider provider = SeekableChannelsProviderLoader .getInstance ().fromServiceLoader (
111
- parquetFileURI , specialInstructions );
112
- return new ParquetFileReader (parquetFileURI , new CachedChannelProvider (provider , 1 << 7 ));
113
- }
114
-
115
- /**
116
- * Create a new ParquetFileReader for the provided source.
117
- *
118
- * @param source The source path or URI for the parquet file or the parquet metadata file
119
- * @param channelsProvider The {@link SeekableChannelsProvider} to use for reading the file
120
- */
121
- public ParquetFileReader (final String source , final SeekableChannelsProvider channelsProvider )
122
- throws IOException {
123
- this (convertToURI (source , false ), channelsProvider );
124
- }
125
-
126
79
/**
127
80
* Create a new ParquetFileReader for the provided source.
128
81
*
129
82
* @param parquetFileURI The URI for the parquet file or the parquet metadata file
130
- * @param channelsProvider The {@link SeekableChannelsProvider} to use for reading the file
83
+ * @param provider The {@link SeekableChannelsProvider} to use for reading the file
131
84
*/
132
- public ParquetFileReader (final URI parquetFileURI , final SeekableChannelsProvider channelsProvider )
133
- throws IOException {
134
- this .channelsProvider = channelsProvider ;
85
+ private ParquetFileReader (
86
+ @ NotNull final URI parquetFileURI ,
87
+ @ NotNull final SeekableChannelsProvider provider ) throws IOException {
88
+ this .channelsProvider = CachedChannelProvider .create (provider , 1 << 7 );
135
89
if (!parquetFileURI .getRawPath ().endsWith (".parquet" ) && FILE_URI_SCHEME .equals (parquetFileURI .getScheme ())) {
136
90
// Construct a new file URI for the parent directory
137
91
rootURI = convertToURI (new File (parquetFileURI ).getParentFile (), true );
@@ -270,7 +224,7 @@ private Set<String> calculateColumnsWithDictionaryUsedOnEveryDataPage() {
270
224
271
225
/**
272
226
* Create a {@link RowGroupReader} object for provided row group number
273
- *
227
+ *
274
228
* @param version The "version" string from deephaven specific parquet metadata, or null if it's not present.
275
229
*/
276
230
public RowGroupReader getRowGroup (final int groupNumber , final String version ) {
@@ -506,7 +460,7 @@ private static LogicalTypeAnnotation getLogicalTypeAnnotation(final ConvertedTyp
506
460
507
461
/**
508
462
* Helper method to determine if a logical type is adjusted to UTC.
509
- *
463
+ *
510
464
* @param logicalType the logical type to check
511
465
* @return true if the logical type is a timestamp adjusted to UTC, false otherwise
512
466
*/
0 commit comments