@Override public void seek(long desired) throws IOException { inputStream.seek(desired); }
/** * Closes the file input stream of the input format. */ @Override public void close() throws IOException { if (this.stream != null) { // close input stream this.stream.close(); stream = null; } }
@Override public int read(byte[] b, int off, int len) throws IOException { return inputStream.read(b, off, len); }
@Override public void flatMap(Tuple3<String, Long, Long> value, Collector<String> out) throws Exception { FSDataInputStream stream = FileSystem.get(new URI(value.f0)).open(new Path(value.f0)); stream.seek(value.f1); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line; try { while ((line = reader.readLine()) != null && (value.f2 == -1L || stream.getPos() <= value.f2)) { out.collect(line); } } finally { reader.close(); } } }
final int available = 17; final boolean markSupported = true; when(mockIn.read()).thenReturn(value); when(mockIn.read(any(byte[].class), anyInt(), anyInt())).thenReturn(11); when(mockIn.getPos()).thenReturn(inPos); when(mockIn.available()).thenReturn(available); when(mockIn.markSupported()).thenReturn(markSupported); assertEquals(value, in.read()); assertEquals(bytesRead, in.read(new byte[11], 2, 5)); assertEquals(inPos, in.getPos()); in.seek(17876); verify(mockIn).seek(17876); assertEquals(available, in.available()); assertEquals(markSupported, in.markSupported()); in.mark(9876); verify(mockIn).mark(9876); in.close(); verify(mockIn).close();
@Override public long tell() throws IOException { return stream.getPos(); }
@Override public int available() throws IOException { return inputStream.available(); }
@Override public boolean markSupported() { return inputStream.markSupported(); }
@Override public void mark(int readlimit) { inputStream.mark(readlimit); }
@Override public void reset() throws IOException { inputStream.reset(); }
@Override public long getPos() throws IOException { return inputStream.getPos(); }
@Override public int available() throws IOException { try { return originalStream.available(); } catch (IOException e) { handleIOException(e); return 0; // silence the compiler } }
@Override public boolean markSupported() { return originalStream.markSupported(); }
@Override public void mark(int readlimit) { originalStream.mark(readlimit); }
@Override public void reset() throws IOException { try { originalStream.reset(); } catch (IOException e) { handleIOException(e); } }
@Override public void seek(long p) throws IOException { stream.seek(p); }
@Override public int read(byte[] b, int off, int len) throws IOException { return stream.read(b, off, len); }
@Override public void close() throws IOException { stream.close(); } }