Package alluxio.underfs.gcs
Class GCSInputStream
- java.lang.Object
-
- java.io.InputStream
-
- alluxio.underfs.gcs.GCSInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
@NotThreadSafe public final class GCSInputStream extends java.io.InputStreamA stream for reading a file from GCS. The main purpose is to provide a faster skip method, as the underlying implementation will read and discard bytes until the number to skip has been reached. This input stream returns 0 when calling read with an empty buffer.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intread()intread(byte[] b)intread(byte[] b, int off, int len)longskip(long n)This method leverages the ability to open a stream from GCS from a given offset.
-
-
-
Method Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOExceptionThis method leverages the ability to open a stream from GCS from a given offset. When the underlying stream has fewer bytes buffered than the skip request, the stream is closed, and a new stream is opened starting at the requested offset.- Overrides:
skipin classjava.io.InputStream- Parameters:
n- number of bytes to skip- Returns:
- the number of bytes skipped
- Throws:
java.io.IOException
-
-