~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/sort.cc

  • Committer: Mark Atwood
  • Date: 2011-04-29 00:19:38 UTC
  • mto: This revision was merged to the branch mainline in revision 2297.
  • Revision ID: me@mark.atwood.name-20110429001938-ps5i74hzcic7dvr3
Merge in Fixes of Brian's IOCACHE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
                              unsigned char **sort_keys,
52
52
                              DYNAMIC_ARRAY *buffpek,
53
53
                              size_t *maxbuffer,
54
 
                              internal::IO_CACHE *tempfile,
55
 
                              internal::IO_CACHE *tempfile_for_exceptions);
 
54
                              internal::io_cache_st *tempfile,
 
55
                              internal::io_cache_st *tempfile_for_exceptions);
56
56
static int  write_keys(MI_SORT_PARAM *info,unsigned char **sort_keys,
57
 
                             uint32_t count, BUFFPEK *buffpek,internal::IO_CACHE *tempfile);
 
57
                             uint32_t count, BUFFPEK *buffpek,internal::io_cache_st *tempfile);
58
58
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
59
 
                            internal::IO_CACHE *tempfile);
 
59
                            internal::io_cache_st *tempfile);
60
60
static int  write_index(MI_SORT_PARAM *info,unsigned char * *sort_keys,
61
61
                              uint32_t count);
62
62
static int  merge_many_buff(MI_SORT_PARAM *info,uint32_t keys,
63
63
                            unsigned char * *sort_keys,
64
64
                            BUFFPEK *buffpek,size_t *maxbuffer,
65
 
                            internal::IO_CACHE *t_file);
66
 
static uint32_t  read_to_buffer(internal::IO_CACHE *fromfile,BUFFPEK *buffpek,
 
65
                            internal::io_cache_st *t_file);
 
66
static uint32_t  read_to_buffer(internal::io_cache_st *fromfile,BUFFPEK *buffpek,
67
67
                                  uint32_t sort_length);
68
68
static int  merge_buffers(MI_SORT_PARAM *info,uint32_t keys,
69
 
                                internal::IO_CACHE *from_file, internal::IO_CACHE *to_file,
 
69
                                internal::io_cache_st *from_file, internal::io_cache_st *to_file,
70
70
                                unsigned char * *sort_keys, BUFFPEK *lastbuff,
71
71
                                BUFFPEK *Fb, BUFFPEK *Tb);
72
72
static int  merge_index(MI_SORT_PARAM *,uint,unsigned char **,BUFFPEK *, int,
73
 
                              internal::IO_CACHE *);
 
73
                              internal::io_cache_st *);
74
74
static int  write_keys_varlen(MI_SORT_PARAM *info,unsigned char **sort_keys,
75
75
                       uint32_t count, BUFFPEK *buffpek,
76
 
                       internal::IO_CACHE *tempfile);
77
 
static uint32_t  read_to_buffer_varlen(internal::IO_CACHE *fromfile,BUFFPEK *buffpek,
 
76
                       internal::io_cache_st *tempfile);
 
77
static uint32_t  read_to_buffer_varlen(internal::io_cache_st *fromfile,BUFFPEK *buffpek,
78
78
                                uint32_t sort_length);
79
 
static int  write_merge_key(MI_SORT_PARAM *info, internal::IO_CACHE *to_file,
 
79
static int  write_merge_key(MI_SORT_PARAM *info, internal::io_cache_st *to_file,
80
80
                     unsigned char *key, uint32_t sort_length, uint32_t count);
81
81
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
82
 
                            internal::IO_CACHE *to_file,
 
82
                            internal::io_cache_st *to_file,
83
83
                            unsigned char* key, uint32_t sort_length,
84
84
                            uint32_t count);
85
85
 
86
86
inline int
87
 
my_var_write(MI_SORT_PARAM *info, internal::IO_CACHE *to_file, unsigned char *bufs);
 
87
my_var_write(MI_SORT_PARAM *info, internal::io_cache_st *to_file, unsigned char *bufs);
88
88
 
89
89
/*
90
90
  Creates a index of sorted keys
109
109
  DYNAMIC_ARRAY buffpek;
110
110
  ha_rows records;
111
111
  unsigned char **sort_keys;
112
 
  internal::IO_CACHE tempfile, tempfile_for_exceptions;
 
112
  internal::io_cache_st tempfile, tempfile_for_exceptions;
113
113
 
114
114
  if (info->keyinfo->flag & HA_VAR_LENGTH_KEY)
115
115
  {
256
256
static ha_rows  find_all_keys(MI_SORT_PARAM *info, uint32_t keys,
257
257
                              unsigned char **sort_keys,
258
258
                              DYNAMIC_ARRAY *buffpek,
259
 
                              size_t *maxbuffer, internal::IO_CACHE *tempfile,
260
 
                              internal::IO_CACHE *tempfile_for_exceptions)
 
259
                              size_t *maxbuffer, internal::io_cache_st *tempfile,
 
260
                              internal::io_cache_st *tempfile_for_exceptions)
261
261
{
262
262
  int error;
263
263
  uint32_t idx;
454
454
        /* Write all keys in memory to file for later merge */
455
455
 
456
456
static int  write_keys(MI_SORT_PARAM *info, register unsigned char **sort_keys,
457
 
                             uint32_t count, BUFFPEK *buffpek, internal::IO_CACHE *tempfile)
 
457
                             uint32_t count, BUFFPEK *buffpek, internal::io_cache_st *tempfile)
458
458
{
459
459
  unsigned char **end;
460
460
  uint32_t sort_length=info->key_length;
477
477
 
478
478
 
479
479
inline int
480
 
my_var_write(MI_SORT_PARAM *info, internal::IO_CACHE *to_file, unsigned char *bufs)
 
480
my_var_write(MI_SORT_PARAM *info, internal::io_cache_st *to_file, unsigned char *bufs)
481
481
{
482
482
  int err;
483
483
  uint16_t len = _mi_keylength(info->keyinfo, (unsigned char*) bufs);
494
494
static int  write_keys_varlen(MI_SORT_PARAM *info,
495
495
                                    register unsigned char **sort_keys,
496
496
                                    uint32_t count, BUFFPEK *buffpek,
497
 
                                    internal::IO_CACHE *tempfile)
 
497
                                    internal::io_cache_st *tempfile)
498
498
{
499
499
  unsigned char **end;
500
500
  int err;
516
516
 
517
517
 
518
518
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
519
 
                            internal::IO_CACHE *tempfile)
 
519
                            internal::io_cache_st *tempfile)
520
520
{
521
521
  uint32_t key_length=info->real_key_length;
522
522
 
550
550
 
551
551
static int  merge_many_buff(MI_SORT_PARAM *info, uint32_t keys,
552
552
                            unsigned char **sort_keys, BUFFPEK *buffpek,
553
 
                            size_t *maxbuffer, internal::IO_CACHE *t_file)
 
553
                            size_t *maxbuffer, internal::io_cache_st *t_file)
554
554
{
555
555
  uint32_t i;
556
 
  internal::IO_CACHE t_file2, *from_file, *to_file, *temp;
 
556
  internal::io_cache_st t_file2, *from_file, *to_file, *temp;
557
557
  BUFFPEK *lastbuff;
558
558
 
559
559
  if (*maxbuffer < MERGEBUFF2)
604
604
    -1  Error
605
605
*/
606
606
 
607
 
static uint32_t  read_to_buffer(internal::IO_CACHE *fromfile, BUFFPEK *buffpek,
 
607
static uint32_t  read_to_buffer(internal::io_cache_st *fromfile, BUFFPEK *buffpek,
608
608
                                  uint32_t sort_length)
609
609
{
610
610
  register uint32_t count;
623
623
  return (count*sort_length);
624
624
} /* read_to_buffer */
625
625
 
626
 
static uint32_t  read_to_buffer_varlen(internal::IO_CACHE *fromfile, BUFFPEK *buffpek,
 
626
static uint32_t  read_to_buffer_varlen(internal::io_cache_st *fromfile, BUFFPEK *buffpek,
627
627
                                         uint32_t sort_length)
628
628
{
629
629
  register uint32_t count;
656
656
 
657
657
 
658
658
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
659
 
                                         internal::IO_CACHE *to_file, unsigned char* key,
 
659
                                         internal::io_cache_st *to_file, unsigned char* key,
660
660
                                         uint32_t sort_length, uint32_t count)
661
661
{
662
662
  uint32_t idx;
674
674
 
675
675
 
676
676
static int  write_merge_key(MI_SORT_PARAM *info,
677
 
                                  internal::IO_CACHE *to_file, unsigned char *key,
 
677
                                  internal::io_cache_st *to_file, unsigned char *key,
678
678
                                  uint32_t sort_length, uint32_t count)
679
679
{
680
680
  (void)info;
706
706
*/
707
707
 
708
708
static int
709
 
merge_buffers(MI_SORT_PARAM *info, uint32_t keys, internal::IO_CACHE *from_file,
710
 
              internal::IO_CACHE *to_file, unsigned char **sort_keys, BUFFPEK *lastbuff,
 
709
merge_buffers(MI_SORT_PARAM *info, uint32_t keys, internal::io_cache_st *from_file,
 
710
              internal::io_cache_st *to_file, unsigned char **sort_keys, BUFFPEK *lastbuff,
711
711
              BUFFPEK *Fb, BUFFPEK *Tb)
712
712
{
713
713
  int error;
823
823
 
824
824
static int
825
825
merge_index(MI_SORT_PARAM *info, uint32_t keys, unsigned char **sort_keys,
826
 
            BUFFPEK *buffpek, int maxbuffer, internal::IO_CACHE *tempfile)
 
826
            BUFFPEK *buffpek, int maxbuffer, internal::io_cache_st *tempfile)
827
827
{
828
 
  if (merge_buffers(info,keys,tempfile,(internal::IO_CACHE*) 0,sort_keys,buffpek,buffpek,
 
828
  if (merge_buffers(info,keys,tempfile,(internal::io_cache_st*) 0,sort_keys,buffpek,buffpek,
829
829
                    buffpek+maxbuffer))
830
830
    return(1);
831
831
  return(0);