From 780b92ada9afcf1d58085a83a0b9e6bc982203d1 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 17 Feb 2015 17:25:57 +0000 Subject: Imported from /home/lorry/working-area/delta_berkeleydb/db-6.1.23.tar.gz. --- docs/programmer_reference/mp_warm.html | 115 ++++++++++++++++----------------- 1 file changed, 57 insertions(+), 58 deletions(-) (limited to 'docs/programmer_reference/mp_warm.html') diff --git a/docs/programmer_reference/mp_warm.html b/docs/programmer_reference/mp_warm.html index 402f4203..e4d9fa81 100644 --- a/docs/programmer_reference/mp_warm.html +++ b/docs/programmer_reference/mp_warm.html @@ -14,7 +14,7 @@ -

- Some applications find it is useful to pre-load the memory pool - upon application startup. This is a strictly optional activity that - provides faster initial access to your data at the expense of - longer application startup times. +

+ Some applications find it is useful to pre-load the memory + pool upon application startup. This is a strictly optional + activity that provides faster initial access to your data at + the expense of longer application startup times.

-

- To warm the cache, you simply have to read the records that your - application will operate on most frequently. You can do this with - normal database reads, and you can also use cursors. But the most - efficient way to warm the cache is to use memory pool APIs to get - the pages that contain your most frequently accessed records. +

+ To warm the cache, you simply have to read the records that + your application will operate on most frequently. You can do + this with normal database reads, and you can also use cursors. + But the most efficient way to warm the cache is to use memory + pool APIs to get the pages that contain your most frequently + accessed records.

-

+

You read pages into the memory pool using the - DB_MPOOLFILE->get() method. This method - acquires locks on the page, so immediately upon getting the page - you need to put it so as to release the locks. + DB_MPOOLFILE->get() method. This + method acquires locks on the page, so immediately upon getting + the page you need to put it so as to release the locks.

- Also, you obtain a memory pool file handle using a database handle. - This means that if your data is contained in more than one Berkeley - DB database, you must operate on each database handle in turn. + Also, you obtain a memory pool file handle using a database + handle. This means that if your data is contained in more than + one Berkeley DB database, you must operate on each database + handle in turn.

- The following example code illustrates this. It does the following: + The following example code illustrates this. It does the + following:

- First, we include the libraries that we need, forward declare some - functions, and intialize some variables. + First, we include the libraries that we need, forward + declare some functions, and intialize some variables.

#include <stdio.h> 
@@ -117,12 +118,12 @@ main(void)
     DB_ENV *envp = 0;
     u_int32_t env_flags, pagesize, gbytes, bytes;
     int ret = 0, ret_t = 0, numcachepages, pagecount; 
-

+

Then we open the environment and our databases. The - open_db() function that we use here simply - opens a database. We will provide that code at the end of this - example, but it should hold no surprises for you. - We only use the function so as to reuse the code. + open_db() function that we use + here simply opens a database. We will provide that code at the + end of this example, but it should hold no surprises for you. + We only use the function so as to reuse the code.

    /*
@@ -161,9 +162,9 @@ main(void)
     if (ret != 0)
         goto err; 

- Next we determine how many database pages we can fit into the - cache. We do this by finding out how large our pages are, and then - finding out how large our cache can be. + Next we determine how many database pages we can fit into + the cache. We do this by finding out how large our pages are, + and then finding out how large our cache can be.

    /* Find out how many pages can fit at most in the cache */
@@ -183,12 +184,12 @@ main(void)
     /* Avoid an overflow by first calculating pages per gigabyte. */
     numcachepages = gbytes * ((1024 * 1024 * 1024) / pagesize);
     numcachepages += bytes / pagesize; 
-

+

Now we call our warm_cache() - function. We will describe this function in a little while, but - note that we call warm_cache() + function. We will describe this function in a little while, + but note that we call warm_cache() twice. This is because our example uses two databases, and the - memory pool methods operate on a per-handle basis. + memory pool methods operate on a per-handle basis.

    /*
@@ -209,7 +210,7 @@ main(void)
             db_strerror(ret));
         goto err;
     } 
-

+

Now we close all our handles and finish our main() function. Again, this is straight-forward boilerplate code that we provide simply to be @@ -250,11 +251,11 @@ main(void) printf("I'm all done.\n"); return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } -

- As noted above, this example uses an open_db() - function, which opens a database handle inside the provided - environment. To be complete, this is the implementation of that - function: +

+ As noted above, this example uses an + open_db() function, which opens a + database handle inside the provided environment. To be + complete, this is the implementation of that function:

/* Open a database handle */
@@ -304,11 +305,11 @@ open_db(DB_ENV *envp, DB **dbpp, const char *file_name)
         
         

In this section we provide the implementation of the - warm_cache() function. This example - function simply loads all the database pages that will fit into - the memory pool. It starts from the first database page and - continues until it either runs out of database pages or it runs - out of room in the memory pool. + warm_cache() function. This + example function simply loads all the database pages that + will fit into the memory pool. It starts from the first + database page and continues until it either runs out of + database pages or it runs out of room in the memory pool.

/* Warm the cache */
@@ -378,9 +379,7 @@ warm_cache(DB *dbp, int *pagecountp, int numcachepages)
           
             Home
           
-           Chapter 19. 
-		The Transaction Subsystem
-        
+           Chapter 19.  The Transaction Subsystem 
         
       
     
-- 
cgit v1.2.1