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()
GridFSDownloadStream
GridFSFile
for the file being downloadedgetGridFSFile
in class GridFSDownloadStream
public GridFSDownloadStream batchSize(int batchSize)
GridFSDownloadStream
Can 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 GridFSDownloadStream
batchSize
- the batch sizepublic int read()
read
in class GridFSDownloadStream
public int read(byte[] b)
read
in class GridFSDownloadStream
public int read(byte[] b, int off, int len)
read
in class GridFSDownloadStream
public long skip(long bytesToSkip)
skip
in class GridFSDownloadStream
public int available()
available
in class GridFSDownloadStream
public void mark()
GridFSDownloadStream
A 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 GridFSDownloadStream
public void mark(int readlimit)
mark
in class java.io.InputStream
public void reset()
reset
in class GridFSDownloadStream
public boolean markSupported()
markSupported
in class java.io.InputStream
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class GridFSDownloadStream
private void checkClosed()
private void discardCursor()
private Document getChunk(int startChunkIndex)
private byte[] getBufferFromChunk(Document chunk, int expectedChunkIndex)
private byte[] getBuffer(int chunkIndexToFetch)