DbMpoolFile::get

APIRef

#include <db_cxx.h>

int DbMpoolFile::get(db_pgno_t *pgnoaddr, u_int32_t flags, void **pagep);

Description

The DbMpoolFile::get method copies a pointer to the page with the page number specified by pgnoaddr, from the source file in the DbMpoolFile, into the memory location referenced by pagep. If the page does not exist or cannot be retrieved, DbMpoolFile::get will fail.

Page numbers begin at 0, i.e., the first page in the file is page number 0, not page number 1.

The returned page is size_t type aligned.

The flags value must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values.

DB_MPOOL_CREATE
If the specified page does not exist, create it. In this case, the pgin method, if specified, is called.

DB_MPOOL_LAST
Return the last page of the source file and copy its page number to the location referenced by pgnoaddr.

DB_MPOOL_NEW
Create a new page in the file and copy its page number to the location referenced by pgnoaddr. In this case, the pgin method, if specified, is not called.

The DB_MPOOL_CREATE, DB_MPOOL_LAST and DB_MPOOL_NEW flags are mutually exclusive.

Created pages have all their bytes set to 0, unless otherwise specified when the file was opened.

All pages returned by DbMpoolFile::get will be retained (i.e. pinned), in the pool until a subsequent call to DbMpoolFile::put.

The DbMpoolFile::get method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

Errors

The DbMpoolFile::get method may fail and throw an exception or return a non-zero error for the following conditions:

EAGAIN
The page reference count has overflowed. (This should never happen unless there's a bug in the application.)

EINVAL
An invalid flag value or parameter was specified.

The DB_MPOOL_NEW flag was set and the source file was not opened for writing.

More than one of DB_MPOOL_CREATE, DB_MPOOL_LAST and DB_MPOOL_NEW was set.

EIO
The requested page does not exist and DB_MPOOL_CREATE was not set.

ENOMEM
The cache is full and no more pages will fit in the pool.

The DbMpoolFile::get method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. If a catastrophic error has occurred, the DbMpoolFile::get method may fail and either return DB_RUNRECOVERY or throw an exception encapsulating DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail in the same way.

Classes

DbEnv, DbMpoolFile

See Also

DbEnv::set_mp_mmapsize, DbMpoolFile::close, DbMpoolFile::get, DbMpoolFile::open, DbMpoolFile::put, DbMpoolFile::set, DbMpoolFile::sync, DbEnv::memp_register, DbEnv::memp_stat, DbEnv::memp_sync and DbEnv::memp_trickle.

APIRef

Copyright Sleepycat Software