~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_preload.c

  • Committer: Brian Aker
  • Date: 2008-08-22 19:59:34 UTC
  • Revision ID: brian@tangent.org-20080822195934-c2krkt6759jct6mf
Removed dead bits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
*/
19
19
 
20
20
#include "myisamdef.h"
21
 
#include <drizzled/util/test.h>
22
 
 
23
21
 
24
22
 
25
23
/*
42
40
 
43
41
int mi_preload(MI_INFO *info, uint64_t key_map, bool ignore_leaves)
44
42
{
45
 
  uint32_t i;
 
43
  uint i;
46
44
  uint32_t length, block_length= 0;
47
 
  unsigned char *buff= NULL;
 
45
  uchar *buff= NULL;
48
46
  MYISAM_SHARE* share= info->s;
49
 
  uint32_t keys= share->state.header.keys;
 
47
  uint keys= share->state.header.keys;
50
48
  MI_KEYDEF *keyinfo= share->keyinfo;
51
49
  my_off_t key_file_length= share->state.state.key_file_length;
52
50
  my_off_t pos= share->base.keystart;
71
69
  length= info->preload_buff_size/block_length * block_length;
72
70
  set_if_bigger(length, block_length);
73
71
 
74
 
  if (!(buff= (unsigned char *) my_malloc(length, MYF(MY_WME))))
 
72
  if (!(buff= (uchar *) my_malloc(length, MYF(MY_WME))))
75
73
    return(my_errno= HA_ERR_OUT_OF_MEM);
76
74
 
77
75
  if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE))
82
80
    /* Read the next block of index file into the preload buffer */
83
81
    if ((my_off_t) length > (key_file_length-pos))
84
82
      length= (uint32_t) (key_file_length-pos);
85
 
    if (my_pread(share->kfile, (unsigned char*) buff, length, pos, MYF(MY_FAE|MY_FNABP)))
 
83
    if (my_pread(share->kfile, (uchar*) buff, length, pos, MYF(MY_FAE|MY_FNABP)))
86
84
      goto err;
87
85
 
88
86
    if (ignore_leaves)
89
87
    {
90
 
      unsigned char *end= buff+length;
 
88
      uchar *end= buff+length;
91
89
      do
92
90
      {
93
91
        if (mi_test_if_nod(buff))
94
92
        {
95
93
          if (key_cache_insert(share->key_cache,
96
94
                               share->kfile, pos, DFLT_INIT_HITS,
97
 
                              (unsigned char*) buff, block_length))
 
95
                              (uchar*) buff, block_length))
98
96
            goto err;
99
97
        }
100
98
        pos+= block_length;
106
104
    {
107
105
      if (key_cache_insert(share->key_cache,
108
106
                           share->kfile, pos, DFLT_INIT_HITS,
109
 
                           (unsigned char*) buff, length))
 
107
                           (uchar*) buff, length))
110
108
        goto err;
111
109
      pos+= length;
112
110
    }
113
111
  }
114
112
  while (pos != key_file_length);
115
113
 
116
 
  free((char*) buff);
 
114
  my_free((char*) buff, MYF(0));
117
115
  return(0);
118
116
 
119
117
err:
120
 
  free((char*) buff);
 
118
  my_free((char*) buff, MYF(MY_ALLOW_ZERO_PTR));
121
119
  return(my_errno= errno);
122
120
}
123
121