4444import org .apache .hadoop .util .functional .FunctionRaisingIOE ;
4545import org .apache .hadoop .util .functional .FutureIO ;
4646
47+ import static org .apache .hadoop .fs .Options .OpenFileOptions .FS_OPTION_OPENFILE_LENGTH ;
4748import static org .apache .hadoop .fs .Options .OpenFileOptions .FS_OPTION_OPENFILE_READ_POLICY ;
4849import static org .apache .hadoop .fs .statistics .IOStatisticsContext .getCurrentIOStatisticsContext ;
4950import static org .apache .hadoop .fs .statistics .IOStatisticsSupport .retrieveIOStatistics ;
@@ -79,7 +80,7 @@ public static boolean hasPathCapability(FileSystem fs, Path path, String capabil
7980 * @param capability capability string
8081 * @return true iff the capability is declared available.
8182 */
82- public static boolean hasStreamCapability (Object o , String capability ) {
83+ public static boolean streamCapabilities_hasStreamCapability (Object o , String capability ) {
8384 if (o instanceof StreamCapabilities ) {
8485 return false ;
8586 }
@@ -98,11 +99,12 @@ public static boolean hasStreamCapability(Object o, String capability) {
9899 * @throws IOException for any failure.
99100 */
100101 @ InterfaceStability .Stable
101- public static FSDataInputStream filesystemOpenFile (
102+ public static FSDataInputStream fileSystem_openFile (
102103 final FileSystem fs ,
103104 final Path path ,
104105 final String policy ,
105106 final FileStatus status ,
107+ final Long length ,
106108 final Map <String , String > options ) throws IOException {
107109 final FutureDataInputStreamBuilder builder = fs .openFile (path );
108110 if (policy != null ) {
@@ -111,6 +113,9 @@ public static FSDataInputStream filesystemOpenFile(
111113 if (status != null ) {
112114 builder .withFileStatus (status );
113115 }
116+ if (length != null ) {
117+ builder .opt (FS_OPTION_OPENFILE_LENGTH , Long .toString (length ));
118+ }
114119 if (options != null ) {
115120 // add all the options map entries
116121 options .forEach (builder ::opt );
@@ -128,7 +133,7 @@ public static FSDataInputStream filesystemOpenFile(
128133 * @return a path to the enclosing root
129134 * @throws IOException early checks like failure to resolve path cause IO failures
130135 */
131- public static Path filesystemGetEnclosingRoot (FileSystem fs , Path path ) throws IOException {
136+ public static Path fileSystem_getEnclosingRoot (FileSystem fs , Path path ) throws IOException {
132137 return fs .getEnclosingRoot (path );
133138 }
134139
@@ -316,7 +321,7 @@ public static Serializable iostatisticsContextSnapshot() {
316321 * the interface or, if when invoked, it is raised.
317322 * Note: that is the default behaviour of {@link FSDataInputStream#readFully(long, ByteBuffer)}.
318323 */
319- public static void byteBufferPositionedReadableReadFully (
324+ public static void byteBufferPositionedReadable_readFully (
320325 Object in ,
321326 long position ,
322327 ByteBuffer buf )
@@ -335,18 +340,18 @@ public static void byteBufferPositionedReadableReadFully(
335340 * @return true if the stream implements the interface (including a wrapped stream)
336341 * and that it declares the stream capability.
337342 */
338- public static boolean byteBufferPositionedReadableReadFullyAvailable (
343+ public static boolean byteBufferPositionedReadable_readFullyAvailable (
339344 Object in ) {
340345 if (!(in instanceof ByteBufferPositionedReadable )) {
341346 return false ;
342347 }
343348 if (in instanceof FSDataInputStream ) {
344349 // ask the wrapped stream.
345- return byteBufferPositionedReadableReadFullyAvailable (
350+ return byteBufferPositionedReadable_readFullyAvailable (
346351 ((FSDataInputStream ) in ).getWrappedStream ());
347352 }
348353 // now rely on the input stream implementing path capabilities, which
349354 // all the Hadoop FS implementations do.
350- return hasStreamCapability (in , StreamCapabilities .PREADBYTEBUFFER );
355+ return streamCapabilities_hasStreamCapability (in , StreamCapabilities .PREADBYTEBUFFER );
351356 }
352357}
0 commit comments