1<!--$Id: memp_fget.so,v 10.48 2006/09/13 14:30:54 mjc Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DbMpoolFile::get</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DbMpoolFile::get</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbMpoolFile::get(db_pgno_t *pgnoaddr, 26 DbTxn *txnid, u_int32_t flags, void **pagep); 27</pre></b> 28<hr size=1 noshade> 29<b>Description: DbMpoolFile::get</b> 30<p>The DbMpoolFile::get method returns pages from the cache.</p> 31<p>All pages returned by DbMpoolFile::get will be retained (that is, 32<i>pinned</i>), in the pool until a subsequent call to 33<a href="../api_cxx/memp_fput.html">DbMpoolFile::put</a>.</p> 34<p>The returned page is <b>size_t</b> type aligned.</p> 35<p>Fully or partially created pages have all their bytes set to a nul byte, 36unless the <a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a> method was called to specify other 37behavior before the file was opened.</p> 38<a name="2"><!--meow--></a> 39<p>The DbMpoolFile::get method 40will either return DB_PAGE_NOTFOUND or 41throw an exception that encapsulates DB_PAGE_NOTFOUND if the requested page does not exist and DB_MPOOL_CREATE was 42not set. 43Unless otherwise specified, the DbMpoolFile::get method 44either returns a non-zero error value 45or throws an exception that encapsulates a non-zero error value on 46failure, and returns 0 on success. 47</p> 48<b>Parameters</b> <br> 49 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one 50or more of the following values: 51<br> 52<b><a name="DB_MPOOL_CREATE">DB_MPOOL_CREATE</a></b><ul compact><li>If the specified page does not exist, create it. In this case, the 53<a href="memp_register.html#pgin">pgin</a> method, if specified, is 54called.</ul> 55<b><a name="DB_MPOOL_DIRTY">DB_MPOOL_DIRTY</a></b><ul compact><li>The page will be modified and must be written to the source file before 56being evicted from the pool. For files open with the 57<a href="../api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> flag set, a new copy of the page will be made 58if this is the first time the specified transaction is modifying it.</ul> 59<b><a name="DB_MPOOL_EDIT">DB_MPOOL_EDIT</a></b><ul compact><li>The page will be modified and must be written to the source file before 60being evicted from the pool. No copy of the page will be made, regardless 61of the <a href="../api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> setting. This flag is only intended for 62use in situations where a transaction handle is not available, such as during 63aborts or recovery.</ul> 64<b><a name="DB_MPOOL_LAST">DB_MPOOL_LAST</a></b><ul compact><li>Return the last page of the source file, and copy its page number into 65the memory location to which <b>pgnoaddr</b> refers.</ul> 66<b><a name="DB_MPOOL_NEW">DB_MPOOL_NEW</a></b><ul compact><li>Create a new page in the file, and copy its page number into the memory 67location to which <b>pgnoaddr</b> refers. In this case, the 68<a href="memp_register.html#pgin">pgin</a> method, if specified, is 69<b>not</b> called.</ul> 70<br> 71<p>The DB_MPOOL_CREATE, DB_MPOOL_LAST, and 72DB_MPOOL_NEW flags are mutually exclusive.</p></ul> 73 <b>pagep</b><ul compact><li>The <b>pagep</b> parameter references memory into which 74a pointer to the returned page is copied.</ul> 75 <b>pgnoaddr</b><ul compact><li>If the <b>flags</b> parameter is set to DB_MPOOL_LAST or 76DB_MPOOL_NEW, the page number of the created page is copied 77into the memory location to which the <b>pgnoaddr</b> parameter 78refers. Otherwise, the <b>pgnoaddr</b> parameter is the page to 79create or retrieve. 80<p><b>Page numbers begin at 0; that is, the first page in the file is page 81number 0, not page number 1.</b></p></ul> 82 <b>txnid</b><ul compact><li>If the operation is part of an application-specified 83transaction, the <b>txnid</b> parameter is a transaction handle 84returned from <a href="../api_cxx/txn_begin.html">DbEnv::txn_begin</a>; otherwise NULL. A transaction is 85required if the file is open for multiversion concurrency control by 86passing <a href="../api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> to <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> and the 87DB_MPOOL_DIRTY, DB_MPOOL_CREATE or 88DB_MPOOL_NEW flags were specified. Otherwise it is ignored.</ul> 89<br> 90<br><b>Errors</b> 91<p>The DbMpoolFile::get method 92may fail and throw 93<a href="../api_cxx/except_class.html">DbException</a>, 94encapsulating one of the following non-zero errors, or return one of 95the following non-zero errors:</p> 96<br> 97<b>EACCES</b><ul compact><li>The DB_MPOOL_DIRTY or DB_MPOOL_EDIT flag was set and 98the source file was not opened for writing.</ul> 99<br> 100<br> 101<b>EAGAIN</b><ul compact><li>The page reference count has overflowed. (This should never happen 102unless there is a bug in the application.)</ul> 103<br> 104<br> 105<b>EINVAL</b><ul compact><li>If the DB_MPOOL_NEW flag was set, and the source file was not 106opened for writing; 107more than one of DB_MPOOL_CREATE, DB_MPOOL_LAST, and 108DB_MPOOL_NEW was set.; or if an 109invalid flag value or parameter was specified.</ul> 110<br> 111<br> 112<b>DB_LOCK_DEADLOCK</b><ul compact><li>For transactions configured with <a href="../api_cxx/txn_begin.html#DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a>, the page has 113been modified since the transaction began.</ul> 114<br> 115<p>If the cache is full, and no more pages will fit in the pool, the DbMpoolFile::get method will fail and 116either return ENOMEM or 117throw a DbMemoryException.</p> 118<hr size=1 noshade> 119<br><b>Class</b> 120<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> 121<br><b>See Also</b> 122<a href="../api_cxx/memp_list.html">Memory Pools and Related Methods</a> 123</tt> 124<table width="100%"><tr><td><br></td><td align=right> 125<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 126</td></tr></table> 127<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 128</body> 129</html> 130