~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_preload.cc

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
/*
17
17
  Preload indexes into key cache
18
18
*/
19
19
 
20
 
#include "myisamdef.h"
 
20
#include "myisam_priv.h"
 
21
#include <stdlib.h>
21
22
#include <drizzled/util/test.h>
22
23
 
23
 
 
 
24
using namespace drizzled;
24
25
 
25
26
/*
26
27
  Preload pages of the index file for a table into the key cache
28
29
  SYNOPSIS
29
30
    mi_preload()
30
31
      info          open table
31
 
      map           map of indexes to preload into key cache 
 
32
      map           map of indexes to preload into key cache
32
33
      ignore_leaves only non-leaves pages are to be preloaded
33
34
 
34
35
  RETURN VALUE
48
49
  MYISAM_SHARE* share= info->s;
49
50
  uint32_t keys= share->state.header.keys;
50
51
  MI_KEYDEF *keyinfo= share->keyinfo;
51
 
  my_off_t key_file_length= share->state.state.key_file_length;
52
 
  my_off_t pos= share->base.keystart;
 
52
  internal::my_off_t key_file_length= share->state.state.key_file_length;
 
53
  internal::my_off_t pos= share->base.keystart;
53
54
 
54
55
  if (!keys || !mi_is_any_key_active(key_map) || key_file_length == pos)
55
56
    return(0);
62
63
    for (i= 1 ; i < keys ; i++)
63
64
    {
64
65
      if (keyinfo[i].block_length != block_length)
65
 
        return(my_errno= HA_ERR_NON_UNIQUE_BLOCK_SIZE);
 
66
        return(errno= HA_ERR_NON_UNIQUE_BLOCK_SIZE);
66
67
    }
67
68
  }
68
69
  else
69
 
    block_length= share->key_cache->key_cache_block_size;
 
70
    block_length= share->getKeyCache()->key_cache_block_size;
70
71
 
71
72
  length= info->preload_buff_size/block_length * block_length;
72
73
  set_if_bigger(length, block_length);
73
74
 
74
 
  if (!(buff= (unsigned char *) my_malloc(length, MYF(MY_WME))))
75
 
    return(my_errno= HA_ERR_OUT_OF_MEM);
 
75
  if (!(buff= (unsigned char *) malloc(length)))
 
76
    return(errno= HA_ERR_OUT_OF_MEM);
76
77
 
77
 
  if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE))
 
78
  if (flush_key_blocks(share->getKeyCache(), share->kfile, FLUSH_RELEASE))
78
79
    goto err;
79
80
 
80
81
  do
81
82
  {
82
83
    /* Read the next block of index file into the preload buffer */
83
 
    if ((my_off_t) length > (key_file_length-pos))
 
84
    if ((internal::my_off_t) length > (key_file_length-pos))
84
85
      length= (uint32_t) (key_file_length-pos);
85
86
    if (my_pread(share->kfile, (unsigned char*) buff, length, pos, MYF(MY_FAE|MY_FNABP)))
86
87
      goto err;
92
93
      {
93
94
        if (mi_test_if_nod(buff))
94
95
        {
95
 
          if (key_cache_insert(share->key_cache,
 
96
          if (key_cache_insert(share->getKeyCache(),
96
97
                               share->kfile, pos, DFLT_INIT_HITS,
97
98
                              (unsigned char*) buff, block_length))
98
99
            goto err;
104
105
    }
105
106
    else
106
107
    {
107
 
      if (key_cache_insert(share->key_cache,
 
108
      if (key_cache_insert(share->getKeyCache(),
108
109
                           share->kfile, pos, DFLT_INIT_HITS,
109
110
                           (unsigned char*) buff, length))
110
111
        goto err;
118
119
 
119
120
err:
120
121
  free((char*) buff);
121
 
  return(my_errno= errno);
 
122
  return(errno= errno);
122
123
}
123
124