~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/filesort.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
  Sorts a database
22
22
*/
23
23
 
24
 
#include "config.h"
 
24
#include <config.h>
25
25
 
26
26
#include <float.h>
27
27
#include <limits.h>
30
30
#include <algorithm>
31
31
#include <iostream>
32
32
 
33
 
#include "drizzled/drizzled.h"
34
 
#include "drizzled/sql_sort.h"
35
 
#include "drizzled/filesort.h"
36
 
#include "drizzled/error.h"
37
 
#include "drizzled/probes.h"
38
 
#include "drizzled/session.h"
39
 
#include "drizzled/table.h"
40
 
#include "drizzled/table_list.h"
41
 
#include "drizzled/optimizer/range.h"
42
 
#include "drizzled/records.h"
43
 
#include "drizzled/internal/iocache.h"
44
 
#include "drizzled/internal/my_sys.h"
45
 
#include "plugin/myisam/myisam.h"
46
 
#include "drizzled/plugin/transactional_storage_engine.h"
47
 
#include "drizzled/atomics.h"
48
 
#include "drizzled/global_buffer.h"
 
33
#include <drizzled/drizzled.h>
 
34
#include <drizzled/sql_sort.h>
 
35
#include <drizzled/filesort.h>
 
36
#include <drizzled/error.h>
 
37
#include <drizzled/probes.h>
 
38
#include <drizzled/session.h>
 
39
#include <drizzled/table.h>
 
40
#include <drizzled/table_list.h>
 
41
#include <drizzled/optimizer/range.h>
 
42
#include <drizzled/records.h>
 
43
#include <drizzled/internal/iocache.h>
 
44
#include <drizzled/internal/my_sys.h>
 
45
#include <plugin/myisam/myisam.h>
 
46
#include <drizzled/plugin/transactional_storage_engine.h>
 
47
#include <drizzled/atomics.h>
 
48
#include <drizzled/global_buffer.h>
 
49
 
 
50
#include <drizzled/sort_field.h>
49
51
 
50
52
 
51
53
using namespace std;
132
134
 
133
135
/* functions defined in this file */
134
136
 
135
 
static char **make_char_array(char **old_pos, register uint32_t fields,
 
137
static char **make_char_array(char **old_pos, uint32_t fields,
136
138
                              uint32_t length);
137
139
 
138
140
static unsigned char *read_buffpek_from_file(internal::IO_CACHE *buffer_file,
454
456
 
455
457
/** Make a array of string pointers. */
456
458
 
457
 
static char **make_char_array(char **old_pos, register uint32_t fields,
 
459
static char **make_char_array(char **old_pos, uint32_t fields,
458
460
                              uint32_t length)
459
461
{
460
 
  register char **pos;
 
462
  char **pos;
461
463
  char *char_pos;
462
464
 
463
465
  if (old_pos ||
564
566
  if (! indexfile && ! quick_select)
565
567
  {
566
568
    next_pos=(unsigned char*) 0;                        /* Find records in sequence */
567
 
    file->startTableScan(1);
 
569
    if (file->startTableScan(1))
 
570
      return(HA_POS_ERROR);
568
571
    file->extra_opt(HA_EXTRA_CACHE, getSession().variables.read_buff_size);
569
572
  }
570
573
 
574
577
    if (select->quick->reset())
575
578
      return(HA_POS_ERROR);
576
579
 
577
 
    read_record_info.init_read_record(&getSession(), select->quick->head, select, 1, 1);
 
580
    if (read_record_info.init_read_record(&getSession(), select->quick->head, select, 1, 1))
 
581
      return(HA_POS_ERROR);
578
582
  }
579
583
 
580
584
  /* Remember original bitmaps */
719
723
    1 Error
720
724
*/
721
725
 
722
 
int SortParam::write_keys(register unsigned char **sort_keys, uint32_t count,
 
726
int SortParam::write_keys(unsigned char **sort_keys, uint32_t count,
723
727
                          internal::IO_CACHE *buffpek_pointers, internal::IO_CACHE *tempfile)
724
728
{
725
729
  buffpek buffpek;
784
788
 
785
789
/** Make a sort-key from record. */
786
790
 
787
 
void SortParam::make_sortkey(register unsigned char *to, unsigned char *ref_pos)
 
791
void SortParam::make_sortkey(unsigned char *to, unsigned char *ref_pos)
788
792
{
789
793
  Field *field;
790
794
  SortField *sort_field;
914
918
        }
915
919
      case DECIMAL_RESULT:
916
920
        {
917
 
          my_decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf);
 
921
          type::Decimal dec_buf, *dec_val= item->val_decimal_result(&dec_buf);
918
922
          if (maybe_null)
919
923
          {
920
924
            if (item->null_value)
925
929
            }
926
930
            *to++=1;
927
931
          }
928
 
          my_decimal2binary(E_DEC_FATAL_ERROR, dec_val, to,
929
 
                            item->max_length - (item->decimals ? 1:0),
930
 
                            item->decimals);
 
932
          dec_val->val_binary(E_DEC_FATAL_ERROR, to,
 
933
                              item->max_length - (item->decimals ? 1:0),
 
934
                              item->decimals);
931
935
          break;
932
936
        }
933
937
      case REAL_RESULT:
1017
1021
 
1018
1022
 
1019
1023
/*
1020
 
  Register fields used by sorting in the sorted table's read set
 
1024
  fields used by sorting in the sorted table's read set
1021
1025
*/
1022
1026
 
1023
1027
void SortParam::register_used_fields()
1100
1104
  from_file= t_file ; to_file= &t_file2;
1101
1105
  while (*maxbuffer >= MERGEBUFF2)
1102
1106
  {
1103
 
    register uint32_t i;
 
1107
    uint32_t i;
1104
1108
 
1105
1109
    if (from_file->reinit_io_cache(internal::READ_CACHE,0L,0,0))
1106
1110
    {
1160
1164
 
1161
1165
uint32_t FileSort::read_to_buffer(internal::IO_CACHE *fromfile, buffpek *buffpek_inst, uint32_t rec_length)
1162
1166
{
1163
 
  register uint32_t count;
 
1167
  uint32_t count;
1164
1168
  uint32_t length;
1165
1169
 
1166
1170
  if ((count= (uint32_t) min((ha_rows) buffpek_inst->max_keys,buffpek_inst->count)))
1401
1405
    }
1402
1406
    else
1403
1407
    {
1404
 
      register unsigned char *end;
 
1408
      unsigned char *end;
1405
1409
      strpos= buffpek_inst->key+offset;
1406
1410
      for (end= strpos+buffpek_inst->mem_count*rec_length ;
1407
1411
           strpos != end ;
1472
1476
 
1473
1477
uint32_t FileSort::sortlength(SortField *sortorder, uint32_t s_length, bool *multi_byte_charset)
1474
1478
{
1475
 
  register uint32_t length;
 
1479
  uint32_t length;
1476
1480
  const CHARSET_INFO *cs;
1477
1481
  *multi_byte_charset= 0;
1478
1482
 
1524
1528
        break;
1525
1529
      case DECIMAL_RESULT:
1526
1530
        sortorder->length=
1527
 
          my_decimal_get_binary_size(sortorder->item->max_length -
 
1531
          class_decimal_get_binary_size(sortorder->item->max_length -
1528
1532
                                     (sortorder->item->decimals ? 1 : 0),
1529
1533
                                     sortorder->item->decimals);
1530
1534
        break;