~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/sort.cc

  • Committer: Monty Taylor
  • Date: 2009-03-22 04:46:43 UTC
  • mfrom: (960.3.1 mordred)
  • mto: (960.5.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: mordred@inaugust.com-20090322044643-efyptdz0hpfjfp0m
Merged the other way.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
/* Functions defined in this file */
47
47
 
48
 
static ha_rows  find_all_keys(MI_SORT_PARAM *info,uint32_t keys,
 
48
extern "C" 
 
49
{
 
50
ha_rows  find_all_keys(MI_SORT_PARAM *info,uint32_t keys,
49
51
                              unsigned char **sort_keys,
50
52
                              DYNAMIC_ARRAY *buffpek,
51
53
                              size_t *maxbuffer,
52
54
                              IO_CACHE *tempfile,
53
55
                              IO_CACHE *tempfile_for_exceptions);
54
 
static int  write_keys(MI_SORT_PARAM *info,unsigned char **sort_keys,
 
56
int  write_keys(MI_SORT_PARAM *info,unsigned char **sort_keys,
55
57
                             uint32_t count, BUFFPEK *buffpek,IO_CACHE *tempfile);
56
 
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
 
58
int  write_key(MI_SORT_PARAM *info, unsigned char *key,
57
59
                            IO_CACHE *tempfile);
58
 
static int  write_index(MI_SORT_PARAM *info,unsigned char * *sort_keys,
 
60
int  write_index(MI_SORT_PARAM *info,unsigned char * *sort_keys,
59
61
                              uint32_t count);
60
 
static int  merge_many_buff(MI_SORT_PARAM *info,uint32_t keys,
 
62
int  merge_many_buff(MI_SORT_PARAM *info,uint32_t keys,
61
63
                            unsigned char * *sort_keys,
62
64
                            BUFFPEK *buffpek,size_t *maxbuffer,
63
65
                            IO_CACHE *t_file);
64
 
static uint32_t  read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
 
66
uint32_t  read_to_buffer(IO_CACHE *fromfile,BUFFPEK *buffpek,
65
67
                                  uint32_t sort_length);
66
 
static int  merge_buffers(MI_SORT_PARAM *info,uint32_t keys,
 
68
int  merge_buffers(MI_SORT_PARAM *info,uint32_t keys,
67
69
                                IO_CACHE *from_file, IO_CACHE *to_file,
68
70
                                unsigned char * *sort_keys, BUFFPEK *lastbuff,
69
71
                                BUFFPEK *Fb, BUFFPEK *Tb);
70
 
static int  merge_index(MI_SORT_PARAM *,uint,unsigned char **,BUFFPEK *, int,
 
72
int  merge_index(MI_SORT_PARAM *,uint,unsigned char **,BUFFPEK *, int,
71
73
                              IO_CACHE *);
72
 
 
73
 
static int  write_keys_varlen(MI_SORT_PARAM *info,unsigned char **sort_keys,
74
 
                                    uint32_t count, BUFFPEK *buffpek,
75
 
                                    IO_CACHE *tempfile);
76
 
static uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
77
 
                                         uint32_t sort_length);
78
 
static int  write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,
79
 
                                  unsigned char *key, uint32_t sort_length, uint32_t count);
80
 
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
81
 
                                         IO_CACHE *to_file,
82
 
                                         unsigned char* key, uint32_t sort_length,
83
 
                                         uint32_t count);
84
 
static inline int
 
74
int  write_keys_varlen(MI_SORT_PARAM *info,unsigned char **sort_keys,
 
75
                       uint32_t count, BUFFPEK *buffpek,
 
76
                       IO_CACHE *tempfile);
 
77
uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile,BUFFPEK *buffpek,
 
78
                                uint32_t sort_length);
 
79
int  write_merge_key(MI_SORT_PARAM *info, IO_CACHE *to_file,
 
80
                     unsigned char *key, uint32_t sort_length, uint32_t count);
 
81
int  write_merge_key_varlen(MI_SORT_PARAM *info,
 
82
                            IO_CACHE *to_file,
 
83
                            unsigned char* key, uint32_t sort_length,
 
84
                            uint32_t count);
 
85
}
 
86
inline int
85
87
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, unsigned char *bufs);
86
88
 
87
89
/*
251
253
 
252
254
/* Search after all keys and place them in a temp. file */
253
255
 
254
 
static ha_rows  find_all_keys(MI_SORT_PARAM *info, uint32_t keys,
 
256
ha_rows  find_all_keys(MI_SORT_PARAM *info, uint32_t keys,
255
257
                              unsigned char **sort_keys,
256
258
                              DYNAMIC_ARRAY *buffpek,
257
259
                              size_t *maxbuffer, IO_CACHE *tempfile,
626
628
 
627
629
        /* Write all keys in memory to file for later merge */
628
630
 
629
 
static int  write_keys(MI_SORT_PARAM *info, register unsigned char **sort_keys,
 
631
int  write_keys(MI_SORT_PARAM *info, register unsigned char **sort_keys,
630
632
                             uint32_t count, BUFFPEK *buffpek, IO_CACHE *tempfile)
631
633
{
632
634
  unsigned char **end;
651
653
} /* write_keys */
652
654
 
653
655
 
654
 
static inline int
 
656
inline int
655
657
my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, unsigned char *bufs)
656
658
{
657
659
  int err;
666
668
}
667
669
 
668
670
 
669
 
static int  write_keys_varlen(MI_SORT_PARAM *info,
 
671
int  write_keys_varlen(MI_SORT_PARAM *info,
670
672
                                    register unsigned char **sort_keys,
671
673
                                    uint32_t count, BUFFPEK *buffpek,
672
674
                                    IO_CACHE *tempfile)
692
694
} /* write_keys_varlen */
693
695
 
694
696
 
695
 
static int  write_key(MI_SORT_PARAM *info, unsigned char *key,
 
697
int  write_key(MI_SORT_PARAM *info, unsigned char *key,
696
698
                            IO_CACHE *tempfile)
697
699
{
698
700
  uint32_t key_length=info->real_key_length;
711
713
 
712
714
/* Write index */
713
715
 
714
 
static int  write_index(MI_SORT_PARAM *info, register unsigned char **sort_keys,
 
716
int  write_index(MI_SORT_PARAM *info, register unsigned char **sort_keys,
715
717
                              register uint32_t count)
716
718
{
717
719
  my_qsort2((unsigned char*) sort_keys,(size_t) count,sizeof(unsigned char*),
727
729
 
728
730
        /* Merge buffers to make < MERGEBUFF2 buffers */
729
731
 
730
 
static int  merge_many_buff(MI_SORT_PARAM *info, uint32_t keys,
 
732
int  merge_many_buff(MI_SORT_PARAM *info, uint32_t keys,
731
733
                            unsigned char **sort_keys, BUFFPEK *buffpek,
732
734
                            size_t *maxbuffer, IO_CACHE *t_file)
733
735
{
784
786
    -1  Error
785
787
*/
786
788
 
787
 
static uint32_t  read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
 
789
uint32_t  read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
788
790
                                  uint32_t sort_length)
789
791
{
790
792
  register uint32_t count;
803
805
  return (count*sort_length);
804
806
} /* read_to_buffer */
805
807
 
806
 
static uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
 
808
uint32_t  read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
807
809
                                         uint32_t sort_length)
808
810
{
809
811
  register uint32_t count;
835
837
} /* read_to_buffer_varlen */
836
838
 
837
839
 
838
 
static int  write_merge_key_varlen(MI_SORT_PARAM *info,
 
840
int  write_merge_key_varlen(MI_SORT_PARAM *info,
839
841
                                         IO_CACHE *to_file, unsigned char* key,
840
842
                                         uint32_t sort_length, uint32_t count)
841
843
{
853
855
}
854
856
 
855
857
 
856
 
static int  write_merge_key(MI_SORT_PARAM *info,
 
858
int  write_merge_key(MI_SORT_PARAM *info,
857
859
                                  IO_CACHE *to_file, unsigned char *key,
858
860
                                  uint32_t sort_length, uint32_t count)
859
861
{
885
887
  If to_file == 0 then use info->key_write
886
888
*/
887
889
 
888
 
static int
 
890
int
889
891
merge_buffers(MI_SORT_PARAM *info, uint32_t keys, IO_CACHE *from_file,
890
892
              IO_CACHE *to_file, unsigned char **sort_keys, BUFFPEK *lastbuff,
891
893
              BUFFPEK *Fb, BUFFPEK *Tb)
1001
1003
 
1002
1004
        /* Do a merge to output-file (save only positions) */
1003
1005
 
1004
 
static int
 
1006
int
1005
1007
merge_index(MI_SORT_PARAM *info, uint32_t keys, unsigned char **sort_keys,
1006
1008
            BUFFPEK *buffpek, int maxbuffer, IO_CACHE *tempfile)
1007
1009
{