Module org.elasticsearch.server
Class SlicedInputStream
java.lang.Object
java.io.InputStream
org.elasticsearch.index.snapshots.blobstore.SlicedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
A
SlicedInputStream is a logical
concatenation one or more input streams. In contrast to the JDKs
SequenceInputStream this stream doesn't require the instantiation
of all logical sub-streams ahead of time. Instead, openSlice(int) is called
if a new slice is required. Each slice is closed once it's been fully consumed or if
close is called before.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSlicedInputStream(int numSlices) Creates a new SlicedInputStream -
Method Summary
Modifier and TypeMethodDescriptionfinal intvoidclose()booleanisClosed()voidmark(int readLimit) booleanprotected abstract InputStreamopenSlice(int slice) Called for each logical slice given a zero based slice ordinal.final intread()final intread(byte[] buffer, int offset, int length) voidreset()longskip(long n) Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
SlicedInputStream
protected SlicedInputStream(int numSlices) Creates a new SlicedInputStream- Parameters:
numSlices- the number of slices to consume
-
-
Method Details
-
openSlice
Called for each logical slice given a zero based slice ordinal. Note that ifInputStream.markSupported()is true (can be overridden to return false), the function may be called again to open a previous slice (which must have the same size as before). The returned InputStreams do not need to support mark/reset.- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
isClosed
public boolean isClosed() -
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
mark
public void mark(int readLimit) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-