Learn R Programming

rmongodb (version 1.8.0)

mongo.gridfile.seek: Seek to a position in a mongo.gridfile

Description

Seek to a position in a mongo.gridfile. This sets the position at which the next mongo.gridfile.read() will start.

Usage

mongo.gridfile.seek(gridfile, offset)

Arguments

gridfile
A (mongo.gridfile) object.
offset
(as.double) The position to which to seek.

Value

(double) The position set. This may be at the length of the GridFS file if offset was greater than that.

See Also

mongo.gridfs, mongo.gridfs.find, mongo.gridfile, mongo.gridfile.get.descriptor, mongo.gridfile.get.filename, mongo.gridfile.get.length, mongo.gridfile.get.chunk.size, mongo.gridfile.get.chunk.count, mongo.gridfile.get.content.type, mongo.gridfile.get.upload.date, mongo.gridfile.get.md5, mongo.gridfile.get.metadata, mongo.gridfile.get.chunk, mongo.gridfile.get.chunks, mongo.gridfile.read, mongo.gridfile.pipe.

Examples

Run this code
mongo <- mongo.create()
if (mongo.is.connected(mongo)) {
    gridfs <- mongo.gridfs.create(mongo, "grid")
    mongo.gridfs.store.file(gridfs, "tests/test.R", "test.R")

    gf <- mongo.gridfs.find(gridfs, "test.R")
    if( !is.null(gf)){
      mongo.gridfile.seek(gf, 256*256*5)
      data <- mongo.gridfile.read(gf, 16384)

      mongo.gridfile.destroy(gf)
    }
    mongo.gridfs.destroy(gridfs)
}

Run the code above in your browser using DataLab