21
21
22
22
import java .io .InputStream ;
23
23
import java .util .Objects ;
24
+ import java .util .function .Function ;
24
25
import org .apache .hadoop .fs .ByteBufferReadable ;
25
26
import org .apache .hadoop .fs .FSDataInputStream ;
26
27
import org .apache .hadoop .fs .FSDataOutputStream ;
@@ -64,7 +65,7 @@ public static SeekableInputStream wrap(FSDataInputStream stream) {
64
65
}
65
66
}
66
67
67
- return unwrapByteBufferReadableLegacy (stream );
68
+ return unwrapByteBufferReadableLegacy (stream ). apply ( stream ) ;
68
69
}
69
70
70
71
/**
@@ -77,16 +78,17 @@ public static SeekableInputStream wrap(FSDataInputStream stream) {
77
78
* @param stream stream to probe
78
79
* @return A H2SeekableInputStream to access, or H1SeekableInputStream if the stream is not seekable
79
80
*/
80
- private static SeekableInputStream unwrapByteBufferReadableLegacy (FSDataInputStream stream ) {
81
+ private static Function <FSDataInputStream , SeekableInputStream > unwrapByteBufferReadableLegacy (
82
+ FSDataInputStream stream ) {
81
83
InputStream wrapped = stream .getWrappedStream ();
82
84
if (wrapped instanceof FSDataInputStream ) {
83
85
LOG .debug ("Checking on wrapped stream {} of {} whether is ByteBufferReadable" , wrapped , stream );
84
86
return unwrapByteBufferReadableLegacy (((FSDataInputStream ) wrapped ));
85
87
}
86
88
if (stream .getWrappedStream () instanceof ByteBufferReadable ) {
87
- return new H2SeekableInputStream ( stream ) ;
89
+ return H2SeekableInputStream :: new ;
88
90
} else {
89
- return new H1SeekableInputStream ( stream ) ;
91
+ return H1SeekableInputStream :: new ;
90
92
}
91
93
}
92
94
0 commit comments