| Class | Mongo::Grid::File::Chunk |
| In: |
lib/mongo/grid/file/chunk.rb
|
| Parent: | Object |
Encapsulates behavior around GridFS chunks of file data.
@since 2.0.0
| COLLECTION | = | 'chunks'.freeze |
Name of the chunks collection.
@since 2.0.0 |
|
| DEFAULT_SIZE | = | (255 * 1024).freeze |
Default size for chunks of data.
@since 2.0.0 |
| document | [R] |
@return [ BSON::Document ] document The document to store for the
chunk. |
Create the new chunk.
@example Create the chunk.
Chunk.new(document)
@param [ BSON::Document ] document The document to create the chunk
from.
@since 2.0.0
Split the provided data into multiple chunks.
@example Split the data into chunks.
Chunks.split(data)
@param [ String, IO ] io The raw bytes. @param [ File::Info ] file_info The files collection file doc. @param [ Integer ] offset The offset.
@return [ Array<Chunk> ] The chunks of the data.
@since 2.0.0
Check chunk equality.
@example Check chunk equality.
chunk == other
@param [ Object ] other The object ot compare to.
@return [ true, false ] If the objects are equal.
@since 2.0.0
Get the BSON type for a chunk document.
@example Get the BSON type.
chunk.bson_type
@return [ Integer ] The BSON type.
@since 2.0.0
Get the chunk position.
@example Get the chunk position.
chunk.n
@return [ Integer ] The chunk position.
@since 2.0.0
Conver the chunk to BSON for storage.
@example Convert the chunk to BSON.
chunk.to_bson
@param [ BSON::ByteBuffer ] buffer The encoded BSON buffer to append to. @param [ true, false ] validating_keys Whether keys should be validated when serializing.
@return [ String ] The raw BSON data.
@since 2.0.0