class GridFSDownloadStreamImpl extends GridFSDownloadStream
| Modifier and Type | Field and Description |
|---|---|
private int |
batchSize |
private byte[] |
buffer |
private int |
bufferOffset |
private int |
chunkIndex |
private MongoCollection<Document> |
chunksCollection |
private int |
chunkSizeInBytes |
private boolean |
closed |
private java.lang.Object |
closeLock |
private long |
currentPosition |
private MongoCursor<Document> |
cursor |
private java.lang.Object |
cursorLock |
private BsonValue |
fileId |
private GridFSFile |
fileInfo |
private long |
length |
private long |
markPosition |
private int |
numberOfChunks |
| Constructor and Description |
|---|
GridFSDownloadStreamImpl(GridFSFile fileInfo,
MongoCollection<Document> chunksCollection) |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
GridFSDownloadStream |
batchSize(int batchSize)
Sets the number of chunks to return per batch.
|
private void |
checkClosed() |
void |
close() |
private void |
discardCursor() |
private byte[] |
getBuffer(int chunkIndexToFetch) |
private byte[] |
getBufferFromChunk(Document chunk,
int expectedChunkIndex) |
private Document |
getChunk(int startChunkIndex) |
GridFSFile |
getGridFSFile()
Gets the corresponding
GridFSFile for the file being downloaded |
void |
mark()
Marks the current position in this input stream.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long bytesToSkip) |
private final GridFSFile fileInfo
private final MongoCollection<Document> chunksCollection
private final BsonValue fileId
private final long length
private final int chunkSizeInBytes
private final int numberOfChunks
private MongoCursor<Document> cursor
private int batchSize
private int chunkIndex
private int bufferOffset
private long currentPosition
private byte[] buffer
private long markPosition
private final java.lang.Object closeLock
private final java.lang.Object cursorLock
private boolean closed
GridFSDownloadStreamImpl(GridFSFile fileInfo, MongoCollection<Document> chunksCollection)
public GridFSFile getGridFSFile()
GridFSDownloadStreamGridFSFile for the file being downloadedgetGridFSFile in class GridFSDownloadStreampublic GridFSDownloadStream batchSize(int batchSize)
GridFSDownloadStreamCan be used to control the memory consumption of this InputStream. The smaller the batchSize the lower the memory consumption and higher latency.
batchSize in class GridFSDownloadStreambatchSize - the batch sizepublic int read()
read in class GridFSDownloadStreampublic int read(byte[] b)
read in class GridFSDownloadStreampublic int read(byte[] b,
int off,
int len)
read in class GridFSDownloadStreampublic long skip(long bytesToSkip)
skip in class GridFSDownloadStreampublic int available()
available in class GridFSDownloadStreampublic void mark()
GridFSDownloadStreamA subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads
re-read the same bytes.
mark in class GridFSDownloadStreampublic void mark(int readlimit)
mark in class java.io.InputStreampublic void reset()
reset in class GridFSDownloadStreampublic boolean markSupported()
markSupported in class java.io.InputStreampublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class GridFSDownloadStreamprivate void checkClosed()
private void discardCursor()
private Document getChunk(int startChunkIndex)
private byte[] getBufferFromChunk(Document chunk, int expectedChunkIndex)
private byte[] getBuffer(int chunkIndexToFetch)