@Test public void testClose() throws Exception { InputStream mockedInputStream = mock(InputStream.class); InputStreamFSInputWrapper wrapper = new InputStreamFSInputWrapper(mockedInputStream); wrapper.close(); verify(mockedInputStream).close(); }
/** * This method allows to wrap/decorate the raw {@link FSDataInputStream} for a certain file split, e.g., for decoding. * When overriding this method, also consider adapting {@link FileInputFormat#testForUnsplittable} if your * stream decoration renders the input file unsplittable. Also consider calling existing superclass implementations. * * @param inputStream is the input stream to decorated * @param fileSplit is the file split for which the input stream shall be decorated * @return the decorated input stream * @throws Throwable if the decoration fails * @see org.apache.flink.api.common.io.InputStreamFSInputWrapper */ protected FSDataInputStream decorateInputStream(FSDataInputStream inputStream, FileInputSplit fileSplit) throws Throwable { // Wrap stream in a extracting (decompressing) stream if file ends with a known compression file extension. InflaterInputStreamFactory<?> inflaterInputStreamFactory = getInflaterInputStreamFactory(fileSplit.getPath()); if (inflaterInputStreamFactory != null) { return new InputStreamFSInputWrapper(inflaterInputStreamFactory.create(stream)); } return inputStream; }
@Override protected FSDataInputStream decorateInputStream(FSDataInputStream inputStream, FileInputSplit fileSplit) throws Throwable { inputStream = super.decorateInputStream(inputStream, fileSplit); return new InputStreamFSInputWrapper(new InvertedInputStream(inputStream)); } }
/** * This method allows to wrap/decorate the raw {@link FSDataInputStream} for a certain file split, e.g., for decoding. * When overriding this method, also consider adapting {@link FileInputFormat#testForUnsplittable} if your * stream decoration renders the input file unsplittable. Also consider calling existing superclass implementations. * * @param inputStream is the input stream to decorated * @param fileSplit is the file split for which the input stream shall be decorated * @return the decorated input stream * @throws Throwable if the decoration fails * @see org.apache.flink.api.common.io.InputStreamFSInputWrapper */ protected FSDataInputStream decorateInputStream(FSDataInputStream inputStream, FileInputSplit fileSplit) throws Throwable { // Wrap stream in a extracting (decompressing) stream if file ends with a known compression file extension. InflaterInputStreamFactory<?> inflaterInputStreamFactory = getInflaterInputStreamFactory(fileSplit.getPath()); if (inflaterInputStreamFactory != null) { return new InputStreamFSInputWrapper(inflaterInputStreamFactory.create(stream)); } return inputStream; }
/** * This method allows to wrap/decorate the raw {@link FSDataInputStream} for a certain file split, e.g., for decoding. * When overriding this method, also consider adapting {@link FileInputFormat#testForUnsplittable} if your * stream decoration renders the input file unsplittable. Also consider calling existing superclass implementations. * * @param inputStream is the input stream to decorated * @param fileSplit is the file split for which the input stream shall be decorated * @return the decorated input stream * @throws Throwable if the decoration fails * @see org.apache.flink.api.common.io.InputStreamFSInputWrapper */ protected FSDataInputStream decorateInputStream(FSDataInputStream inputStream, FileInputSplit fileSplit) throws Throwable { // Wrap stream in a extracting (decompressing) stream if file ends with a known compression file extension. InflaterInputStreamFactory<?> inflaterInputStreamFactory = getInflaterInputStreamFactory(fileSplit.getPath()); if (inflaterInputStreamFactory != null) { return new InputStreamFSInputWrapper(inflaterInputStreamFactory.create(stream)); } return inputStream; }