本文整理了Java中com.mongodb.gridfs.GridFS.getChunksCollection()
方法的一些代码示例,展示了GridFS.getChunksCollection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridFS.getChunksCollection()
方法的具体详情如下:
包路径:com.mongodb.gridfs.GridFS
类名称:GridFS
方法名:getChunksCollection
[英]Gets the DBCollection in which the binary chunks are stored.
[中]获取存储二进制块的DBCollection。
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Removes file from GridFS i.e. removes documents from files and chunks collections.
*/
void remove() {
fs.getFilesCollection().remove(new BasicDBObject("_id", id));
fs.getChunksCollection().remove(new BasicDBObject("files_id", id));
}
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Dumps a new chunk into the chunks collection. Depending on the flag, also partial buffers (at the end) are going to be written
* immediately.
*
* @param writePartial Write also partial buffers full.
* @throws MongoException if there's a failure
*/
private void dumpBuffer(final boolean writePartial) {
if ((currentBufferPosition < chunkSize) && !writePartial) {
// Bail out, chunk not complete yet
return;
}
if (currentBufferPosition == 0) {
// chunk is empty, may be last chunk
return;
}
byte[] writeBuffer = buffer;
if (currentBufferPosition != chunkSize) {
writeBuffer = new byte[currentBufferPosition];
System.arraycopy(buffer, 0, writeBuffer, 0, currentBufferPosition);
}
DBObject chunk = createChunk(id, currentChunkNumber, writeBuffer);
fs.getChunksCollection().save(chunk);
currentChunkNumber++;
totalBytes += writeBuffer.length;
messageDigester.update(writeBuffer);
currentBufferPosition = 0;
}
代码示例来源:origin: org.mongodb/mongo-java-driver
private byte[] getChunk(final int chunkNumber) {
if (fs == null) {
throw new IllegalStateException("No GridFS instance defined!");
}
DBObject chunk = fs.getChunksCollection().findOne(new BasicDBObject("files_id", id).append("n", chunkNumber));
if (chunk == null) {
throw new MongoException("Can't find a chunk! file id: " + id + " chunk: " + chunkNumber);
}
return (byte[]) chunk.get("data");
}
代码示例来源:origin: org.mongodb/mongodb-driver
/**
* Removes file from GridFS i.e. removes documents from files and chunks collections.
*/
void remove() {
fs.getFilesCollection().remove(new BasicDBObject("_id", id));
fs.getChunksCollection().remove(new BasicDBObject("files_id", id));
}
代码示例来源:origin: org.mongodb/mongodb-driver
/**
* Dumps a new chunk into the chunks collection. Depending on the flag, also partial buffers (at the end) are going to be written
* immediately.
*
* @param writePartial Write also partial buffers full.
* @throws MongoException if there's a failure
*/
private void dumpBuffer(final boolean writePartial) {
if ((currentBufferPosition < chunkSize) && !writePartial) {
// Bail out, chunk not complete yet
return;
}
if (currentBufferPosition == 0) {
// chunk is empty, may be last chunk
return;
}
byte[] writeBuffer = buffer;
if (currentBufferPosition != chunkSize) {
writeBuffer = new byte[currentBufferPosition];
System.arraycopy(buffer, 0, writeBuffer, 0, currentBufferPosition);
}
DBObject chunk = createChunk(id, currentChunkNumber, writeBuffer);
fs.getChunksCollection().save(chunk);
currentChunkNumber++;
totalBytes += writeBuffer.length;
messageDigester.update(writeBuffer);
currentBufferPosition = 0;
}
代码示例来源:origin: org.mongodb/mongodb-driver
private byte[] getChunk(final int chunkNumber) {
if (fs == null) {
throw new IllegalStateException("No GridFS instance defined!");
}
DBObject chunk = fs.getChunksCollection().findOne(new BasicDBObject("files_id", id).append("n", chunkNumber));
if (chunk == null) {
throw new MongoException("Can't find a chunk! file id: " + id + " chunk: " + chunkNumber);
}
return (byte[]) chunk.get("data");
}
内容来源于网络,如有侵权,请联系作者删除!