~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/filesort.cc

  • Committer: Olaf van der Spek
  • Date: 2011-06-14 20:59:28 UTC
  • mto: (2318.6.3 refactor7)
  • mto: This revision was merged to the branch mainline in revision 2338.
  • Revision ID: olafvdspek@gmail.com-20110614205928-nfwxnx96skcvv0t9
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
 
115
115
  ~SortParam()
116
116
  {
117
 
    if (tmp_buffer)
118
 
      free(tmp_buffer);
 
117
    free(tmp_buffer);
119
118
  }
120
119
 
121
120
  int write_keys(unsigned char * *sort_keys,
126
125
  void make_sortkey(unsigned char *to,
127
126
                    unsigned char *ref_pos);
128
127
  void register_used_fields();
129
 
  bool save_index(unsigned char **sort_keys,
 
128
  void save_index(unsigned char **sort_keys,
130
129
                  uint32_t count,
131
130
                  filesort_info *table_sort);
132
131
 
342
341
 
343
342
  if (maxbuffer == 0)                   // The whole set is in memory
344
343
  {
345
 
    if (param.save_index(sort_keys,(uint32_t) records, &table_sort))
346
 
    {
347
 
      goto err;
348
 
    }
 
344
    param.save_index(sort_keys,(uint32_t) records, &table_sort);
349
345
  }
350
346
  else
351
347
  {
352
348
    if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer)
353
349
    {
354
 
      if (table_sort.buffpek)
355
 
        free(table_sort.buffpek);
 
350
      free(table_sort.buffpek);
356
351
      table_sort.buffpek = 0;
357
352
    }
358
353
    if (!(table_sort.buffpek=
1055
1050
}
1056
1051
 
1057
1052
 
1058
 
bool SortParam::save_index(unsigned char **sort_keys, uint32_t count, filesort_info *table_sort)
 
1053
void SortParam::save_index(unsigned char **sort_keys, uint32_t count, filesort_info *table_sort)
1059
1054
{
1060
 
  uint32_t offset;
1061
 
  unsigned char *to;
1062
 
 
1063
1055
  internal::my_string_ptr_sort((unsigned char*) sort_keys, (uint32_t) count, sort_length);
1064
 
  offset= rec_length - res_length;
 
1056
  uint32_t offset= rec_length - res_length;
1065
1057
 
1066
1058
  if ((ha_rows) count > max_rows)
1067
1059
    count=(uint32_t) max_rows;
1068
1060
 
1069
 
  to= table_sort->record_pointers= (unsigned char*) malloc(res_length*count);
 
1061
  unsigned char* to= table_sort->record_pointers= (unsigned char*) malloc(res_length*count);
1070
1062
 
1071
1063
  for (unsigned char **end_ptr= sort_keys+count ; sort_keys != end_ptr ; sort_keys++)
1072
1064
  {
1073
1065
    memcpy(to, *sort_keys+offset, res_length);
1074
1066
    to+= res_length;
1075
1067
  }
1076
 
 
1077
 
  return false; // return void
1078
1068
}
1079
1069
 
1080
1070